本文整理汇总了Python中jwkest.jwk.KEYS.add方法的典型用法代码示例。如果您正苦于以下问题:Python KEYS.add方法的具体用法?Python KEYS.add怎么用?Python KEYS.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jwkest.jwk.KEYS
的用法示例。
在下文中一共展示了KEYS.add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_jwks_keys
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import add [as 别名]
def get_jwks_keys(self):
keys = KEYS()
keys.load_from_url(self.jwks_uri())
# Add client secret as oct key so it can be used for HMAC signatures
client_id, client_secret = self.get_key_and_secret()
keys.add({'key': client_secret, 'kty': 'oct'})
return keys
示例2: setUp
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import add [as 别名]
def setUp(self):
self.user = User.objects.create(username='henk')
mock_get = self.patch('requests.get')
mock_get.return_value.json.return_value = {"jwks_uri": "http://example.com/jwks",
"issuer": "http://example.com"}
keys = KEYS()
keys.add({'key': key, 'kty': 'RSA'})
self.patch('jwkest.jwk.request', return_value=Mock(status_code=200,
text=keys.dump_jwks()))
api_settings.OIDC_ENDPOINT = 'http://example.com'
api_settings.OIDC_AUDIENCE = 'you'
示例3: setUp
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import add [as 别名]
def setUp(self):
self.user = User.objects.create(username='henk')
self.responder = FakeRequests()
self.responder.set_response("http://example.com/.well-known/openid-configuration",
{"jwks_uri": "http://example.com/jwks",
"issuer": "http://example.com",
"userinfo_endpoint": "http://example.com/userinfo"})
self.mock_get = self.patch('requests.get')
self.mock_get.side_effect = self.responder.get
keys = KEYS()
keys.add({'key': key, 'kty': 'RSA', 'kid': key.kid})
self.patch('jwkest.jwk.request', return_value=Mock(status_code=200,
text=keys.dump_jwks()))
示例4: get_jwks_keys
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import add [as 别名]
def get_jwks_keys(self):
"""
Returns the keys used by the IdP.
Merges client secret into JWK set from server
Response is cached for 24 hours.
"""
keys = KEYS()
keys.load_from_url(self.JWKS_URI)
# Add client secret as oct key so it can be used for HMAC signatures
_client_id, client_secret = self.get_key_and_secret()
keys.add({'key': client_secret, 'kty': 'oct'})
return keys
示例5: encode
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import add [as 别名]
def encode(self, payload):
"""Encode the provided payload."""
keys = KEYS()
if self.asymmetric:
keys.add(RSAKey(key=RSA.importKey(settings.JWT_PRIVATE_SIGNING_KEY)))
algorithm = 'RS512'
else:
key = self.secret if self.secret else self.jwt_auth['JWT_SECRET_KEY']
keys.add({'key': key, 'kty': 'oct'})
algorithm = self.jwt_auth['JWT_ALGORITHM']
data = json.dumps(payload)
jws = JWS(data, alg=algorithm)
return jws.sign_compact(keys=keys)
示例6: _get_signing_jwk_key_set
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import add [as 别名]
def _get_signing_jwk_key_set(jwt_issuer):
"""
Returns a JWK Keyset containing all active keys that are configured
for verifying signatures.
"""
key_set = KEYS()
# asymmetric keys
signing_jwk_set = settings.JWT_AUTH.get('JWT_PUBLIC_SIGNING_JWK_SET')
if signing_jwk_set:
key_set.load_jwks(signing_jwk_set)
# symmetric key
key_set.add({'key': jwt_issuer['SECRET_KEY'], 'kty': 'oct'})
return key_set
示例7: _decode_jwt
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import add [as 别名]
def _decode_jwt(verify_expiration):
"""
Helper method to decode a JWT with the ability to
verify the expiration of said token
"""
keys = KEYS()
if should_be_asymmetric_key:
keys.load_jwks(settings.JWT_AUTH['JWT_PUBLIC_SIGNING_JWK_SET'])
else:
keys.add({'key': secret_key, 'kty': 'oct'})
_ = JWS().verify_compact(access_token.encode('utf-8'), keys)
return jwt.decode(
access_token,
secret_key,
algorithms=[settings.JWT_AUTH['JWT_ALGORITHM']],
audience=audience,
issuer=issuer,
verify_expiration=verify_expiration,
options={'verify_signature': False},
)
示例8: jwks
# 需要导入模块: from jwkest.jwk import KEYS [as 别名]
# 或者: from jwkest.jwk.KEYS import add [as 别名]
def jwks(_request, _uri, headers):
ks = KEYS()
ks.add(self.key.serialize())
return 200, headers, ks.dump_jwks()