首页 \ 问答 \ 高效的OAuth2.0服务器/提供商如何运作?(How would an efficient OAuth2.0 server / provider work?)

高效的OAuth2.0服务器/提供商如何运作?(How would an efficient OAuth2.0 server / provider work?)

我可能需要为我正在创建的API实现OAuth2.0服务器。 此API允许第三方代表用户执行操作。

OAuth2.0有3个主电话。 首先,有一个提示用户同意的电话。 这将返回一个code 。 第二个是code交换access token 。 最后, access token用于代表用户调用API。

为了实现,我想第一个调用生成一个随机字符串作为code 。 然后将code存储在具有指向当前用户和随机HMAC Key的指针的数据库中,然后将随机数据作为code返回给第三方。

当第三方请求access token ,生成另一条随机数据并与code连接。 使用步骤1中的HMAC key对此字符串进行签名,然后返回此签名字符串和签名以及签名以形成access token

当API调用发生时,从数据库中检索对应于提供的access_tokenhmac key 。 使用hmac密钥验证access_token的签名。

用户可以通过简单地从他们的授权HMAC密钥列表中删除HMAC密钥来撤销第三方访问。 此外,但只是签署随机数据,我可以避免存储每个创建的每个access_token,而是维护一个简短的hmac键列表。

无论如何,这是我第一次尝试思考这个问题。 令人惊讶的是,关于有效实施OAuth2.0服务器端的信息很少。 我宁愿在数据库中保留尽可能少的信息。 签署随机数据然后撤销HMAC密钥的优点是我不必存储每个授权调用生成的每个access token

需要的想法! 必须有一个更好的方法!

编辑:

我不是在寻找实施方案。 谢谢你! 此外,我假设整个系统将运行HTTPs。 另外,我在谈论纯OAuth2.0流程,我不是在谈论带有签名和客户端密钥的OAuth1.0。 我问的是如何在OAuth2.0服务器后面设计密码术,该服务器的工作方式与(例如)Google的OAuth2.0流程类似。


I may need to implement an OAuth2.0 server for an API I'm creating. This API would allow 3rd parties to perform actions on the user's behalf.

OAuth2.0 has 3 mains calls. First, there is a call to prompt the user for consent. This returns a code. The second is where the code is exchanged for a access token. Finally, the access token is used to call the API on the user's behalf.

For implementation, I was thinking the first call generates a random string which acts as a code. The code is then stored in a database with a pointer to the current User and a random HMAC Key, then the random data is returned to the 3rd party as the code.

When the 3rd party requests an access token, another piece of random data is generated and concatenated with the code. This string is signed using the HMAC key from Step 1, then this signed string and signature is returned with the signature to form the access token.

When the API call occurs, the hmac key corresponding to the provided access_token is retrieved from the database. The signature of the access_token is verified using the hmac key.

The user can revoke 3rd party access by simply removing an HMAC key from their list of authorized HMAC keys. Furthermore, but just signing random data, I can avoid storing every single access_token every created, and instead maintain a short list of hmac keys.

Anyway, this is my first attempt as thinking through this. Surprisingly, there is little information about implementing the server side of OAuth2.0 efficiently. I would prefer to keep as little information as possible in the database. The advantage of signing random data then later revoking the HMAC key is that I don't have to store every single access token generated by every single authorization call.

Thoughts needed! There has got to be a better way!

EDIT:

I'm NOT looking for an implementation. Thank you though! Also, I assume this whole system will run over HTTPs. Also, I'm talking about the pure OAuth2.0 flow, I'm not talking about OAuth1.0 with signatures and client keys. I'm asking how to design the cryptography behind an OAuth2.0 server that would work in a similar fashion to (for example) Google's OAuth2.0 flow works.


原文:https://stackoverflow.com/questions/16200528
更新时间:2024-03-25 13:03

相关问答

更多
  • 对于你使用的Hadoop版本(0.21.0)似乎是这样。 您所遇到的问题已针对下一版本修复,请参阅此处: https : //issues.apache.org/jira/browse/HDFS-96 For the Hadoop version you are using(0.21.0) seems so. The issue you have was fixed for the next version, see more here: https://issues.apache.org/jira/bro ...
  • 您可能会混淆“连续”和“顺序”这两个术语。 我们有顺序读/写(从/到磁盘)和“连续”磁盘空间分配。 单个64 MB的HDFS块将按顺序写入磁盘。 因此,数据很可能被写入磁盘上的连续空间(由多个彼此相邻的块组成)。 因此,与随机磁盘写入相比,磁盘/块碎片会低得多。 此外,顺序读/写比使用多个磁盘搜索的随机写更快。 有关详细信息,请参阅顺序写入和随机写入之间的区别 You may be confusing the terms "contiguous" and "sequential". We have sequ ...
  • 块在HDFS和HBase中用于不同的事物。 HDFS中的块是磁盘上的存储单元。 HBase中的块是存储器的一个存储单元。 有许多HBase块可以放入一个HBase文件中。 HBase旨在最大限度地提高HDFS文件系统的效率,并充分利用该块的大小。 有些人甚至将HDFS调整为20GB的块大小,以使HBase更高效。 阅读更多内容以了解HBase背后的情况是: http : //hbase.apache.org/book.html#regionserver.arch 如果你在一张比内存大得多的表上有完全随机访问 ...
  • 我不确定您的XML结构是什么样的,但是例如,如果您有XML结构: 102A5RET Blue-Moon-12-PK-BTTLE 2
  • 不,数据只是在64MB边界上分割。 元数据存储在一个小的单独文件和Namenode上 不,它正是您指定的大小,并且数据在64MB的精确边界上分割。 如果你有5个部分 - 64 MB + 64 MB + 64 MB + 64 MB + 9 MB,那么最后一个文件将是9MB,其他所有文件都是64MB 是的,块被存储为文件,每个块被表示为单独的文件,其中少量元数据存储在单独的文件中 hdfs fsck / -files -blocks -locations 以下是块文件以128MB块大小存储的示例: -rw-r- ...
  • hdfs块的默认大小并不意味着它将使用我们指定的所有空间,即60 MB。 如果数据超过60 MB,那么它将数据拆分为块(数据/ 60 MB),将创建该块数。 如果您正在执行ls命令,那么它将仅显示您当前正在使用空间。 例如: - 我已经在hdfs中上传了test.txt文件,块大小我已设置为128 MB,复制为2但我们的实际文件大小仅为193 B. **权限所有者组大小上次修改的复制块大小名称 -rw-r - r-- hduser supergroup 193 B 10/27/2016,2:58:41 PM ...
  • 您可以使用CLI: hadoop fs -D dfs.block.size=file-size -put local_name remote_location 或者,如果要创建或复制文件,可以使用Java API指定dfs.block.size。 Configuration conf = new Configuration(); conf.setInt("dfs.block.size",file-size); you can use CLI: hadoop fs -D dfs.block.size=fi ...
  • 它只消耗1 MB。 剩下的可以用来存储一些其他文件块。 例如:考虑您的HDFS数据节点总大小为128MB,块大小为64MB。 然后HDFS可以存储2个,64MB块或128个1MB块或任意数量的可以消耗128MB数据节点的块。 It will consume only 1 MB. That remaining can be used to store some other files block. Ex: Consider your HDFS Data node total size is 128MB and ...
  • 正如您已经注意到的那样,HDFS文件不会占用超出其需要的空间,但是在HDFS集群中存在小文件还有其他缺点。 让我们首先解决问题,而不考虑批处理: NameNode(NN)内存消耗。 我不知道Hadoop 3(目前正在开发中),但在以前的版本中,NN是单点故障(您可以添加辅助NN,但最终不会替换或增强主要NN)。 NN负责维护内存和磁盘上的文件系统结构,并且资源有限。 由NN维护的文件系统对象中的每个条目被认为是150个字节( 请查看此博客文章 )。 更多文件= NN消耗更多RAM。 MapReduce范例( ...
  • 块大小64MB表示块的上限大小。 这并不意味着小于64MB的文件块将消耗64MB。 它不会消耗64MB来存储1MB的大块。 如果文件是160兆字节 , 希望这可以帮助。 Block size 64MB means an upper bound size for a block. It doesn't mean that file blocks less than 64MB will consume 64MB. It will not consume 64MB to store a chunk of 1MB. ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。