aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authentication/oauth2/server.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-04-18 20:15:25 +0300
committerFrederick Muriuki Muriithi2024-04-20 15:28:59 +0300
commitcfda9d6cd15763e65fa851d964033e37f377239c (patch)
tree23e0dac4c1e7ab62a21fadac7b82a2d418373d29 /gn_auth/auth/authentication/oauth2/server.py
parentd9b8b05a460535dfb09168d1958c047255ff0fa2 (diff)
downloadgn-auth-cfda9d6cd15763e65fa851d964033e37f377239c.tar.gz
Define and register grant for JWT tokens.
Diffstat (limited to 'gn_auth/auth/authentication/oauth2/server.py')
-rw-r--r--gn_auth/auth/authentication/oauth2/server.py6
1 files changed, 6 insertions, 0 deletions
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)