From cfda9d6cd15763e65fa851d964033e37f377239c Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 18 Apr 2024 20:15:25 +0300 Subject: Define and register grant for JWT tokens. --- gn_auth/auth/authentication/oauth2/server.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gn_auth/auth/authentication/oauth2/server.py') diff --git a/gn_auth/auth/authentication/oauth2/server.py b/gn_auth/auth/authentication/oauth2/server.py index 0bce3d3..09a3449 100644 --- a/gn_auth/auth/authentication/oauth2/server.py +++ b/gn_auth/auth/authentication/oauth2/server.py @@ -14,6 +14,7 @@ from .models.oauth2token import OAuth2Token, save_token from .grants.password_grant import PasswordGrant from .grants.authorisation_code_grant import AuthorisationCodeGrant +from .grants.jwt_bearer_grant import JWTBearerGrant, JWTBearerTokenGenerator from .endpoints.revocation import RevocationEndpoint from .endpoints.introspection import IntrospectionEndpoint @@ -59,6 +60,11 @@ def setup_oauth2_server(app: Flask) -> None: # below server.register_grant(AuthorisationCodeGrant) + server.register_grant(JWTBearerGrant) + server.register_token_generator( + "urn:ietf:params:oauth:grant-type:jwt-bearer", + JWTBearerTokenGenerator(app.config["JWT_PRIVATE_KEY"])) + # register endpoints server.register_endpoint(RevocationEndpoint) server.register_endpoint(IntrospectionEndpoint) -- cgit v1.2.3