python-3.x - 从 Auth0 对 JSON Web key 集 (JWKS) 进行服务器端 (python3/flask) 缓存一分钟左右是否安全?

标签 python-3.x flask jwt auth0

我正在获取 JWKShttps://X.auth0.com/.well-known/jwks.json 服务器端。我想知道将它们缓存几分钟是否安全,因为不断地用 gets 攻击那个端点似乎很浪费。

我正在使用 Flask 并计划通过做一些简单的事情来缓存它:

@cache.cached(timeout=60, key_prefix='auth0/%s')
def get_jwks():
    return requests.get("https://" + AUTH0_DOMAIN + "/.well-known/jwks.json").json()

其余的实现很大程度上受到 auth0 tutorial 的启发。 .

缓存机制来自库flask_caching,里面说:

You are able to use this decorator with any function by changing the key_prefix

最佳答案

JWKS 是一个 Auth0 概念。它包含用于验证已发行 token 签名的公钥集

At the most basic level, the JWKS is a set of keys containing the public keys that should be used to verify any JWT issued by the authorization server.

可以安全地发布公钥。它只会在生成新的 key 对时发生变化。我不知道更新 key 的过程是怎样的:手动还是自动。但是你可以完美地缓存它。如果原因是错误的公钥,请确保在验证失败后下载公钥

关于python-3.x - 从 Auth0 对 JSON Web key 集 (JWKS) 进行服务器端 (python3/flask) 缓存一分钟左右是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47439842/

相关文章:

c# - 如何使用 PEM key 在 C# 中对 JWT 进行签名/加密?

c# - 从 JWT 中删除 "issuer"导致 401 Unauthorized

python-3.x - 并行进程覆盖进度条 (tqdm)

python - 阿姆斯特朗/自恋数字,以 16 为底/十六进制

django - 无效的 HTTP_HOST header : The domain name provided is not valid -- requests to dockerized django app using container name

python-3.x - Flask-restplus:如何使用 'allOf' 操作定义嵌套模型?

jwt - 为什么 id_token 通过带有片段标识符而不是查询字符串的 url 传递?

python-3.x - Django urls.py 设置

python - 使用一组规则替换字符串中的多个字符

javascript - 一个网站与另一个网站的内容交替