Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在服务器端编写 OAuth 协议的提供者部分,并且我正在研究我需要缓存的 OAuth 消费者发送的随机数。
根据推特的文档,
Twitter 将只允许您的应用程序使用一次随机数。防止重放请求。
问题:我的实现只是简单地将收到的每个 nonce 添加到 memcached 中。但这会占用大量的内存空间。理想情况下我应该缓存多少随机数以及多长时间?
Nonce 只需要对于使用相同时间戳的所有请求是唯一的。您应该拒绝时间戳早于 5 分钟的请求,因此您只需将 nonce 存储 5 分钟。
https://www.rfc-editor.org/rfc/rfc5849#section-3.3