从 Auth0 对 JSON Web 密钥集 (JWKS) 进行服务器端 (python3/flask) 缓存一分钟左右是否安全?
Is it safe to do server side (python3/flask) caching of JSON Web Key Sets (JWKS) from Auth0 for a minute or so?
我正在从 https://X.auth0.com/.well-known/jwks.json
服务器端获取 JWKS。我想知道将它们缓存几分钟是否安全,因为不断地用 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 概念。它包含 public 密钥集,用于验证已发行令牌的签名
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.
public 密钥可以安全发布。它只会在生成新的密钥对时发生变化。我不知道更新密钥的过程是怎样的:手动还是自动。但是你可以完美地缓存它。如果原因是错误的 public 密钥
,请确保在验证失败后下载 public 密钥
我正在从 https://X.auth0.com/.well-known/jwks.json
服务器端获取 JWKS。我想知道将它们缓存几分钟是否安全,因为不断地用 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 概念。它包含 public 密钥集,用于验证已发行令牌的签名
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.
public 密钥可以安全发布。它只会在生成新的密钥对时发生变化。我不知道更新密钥的过程是怎样的:手动还是自动。但是你可以完美地缓存它。如果原因是错误的 public 密钥
,请确保在验证失败后下载 public 密钥