Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to pass in alternative signing algoritm to RFC7523 authentication methods #447

Merged
merged 1 commit into from Apr 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion authlib/oauth2/rfc7523/auth.py
Expand Up @@ -24,17 +24,21 @@ class ClientSecretJWT(object):
:param claims: Extra JWT claims
"""
name = 'client_secret_jwt'
alg = 'HS256'

def __init__(self, token_endpoint=None, claims=None):
def __init__(self, token_endpoint=None, claims=None, alg=None):
self.token_endpoint = token_endpoint
self.claims = claims
if alg is not None:
self.alg = alg

def sign(self, auth, token_endpoint):
return client_secret_jwt_sign(
auth.client_secret,
client_id=auth.client_id,
token_endpoint=token_endpoint,
claims=self.claims,
alg=self.alg,
)

def __call__(self, auth, method, uri, headers, body):
Expand Down Expand Up @@ -71,11 +75,13 @@ class PrivateKeyJWT(ClientSecretJWT):
:param claims: Extra JWT claims
"""
name = 'private_key_jwt'
alg = 'RS256'

def sign(self, auth, token_endpoint):
return private_key_jwt_sign(
auth.client_secret,
client_id=auth.client_id,
token_endpoint=token_endpoint,
claims=self.claims,
alg=self.alg,
)