Skip to content

Commit

Permalink
Merge pull request #447 from mikemonteith-livi/master
Browse files Browse the repository at this point in the history
allow to pass in alternative signing algoritm to RFC7523 authentication methods
  • Loading branch information
lepture committed Apr 5, 2022
2 parents 1735d03 + 1f6aea6 commit 6058a35
Showing 1 changed file with 7 additions and 1 deletion.
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,
)

0 comments on commit 6058a35

Please sign in to comment.