diff options
author | Frederick Muriuki Muriithi | 2025-02-26 12:59:09 -0600 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-02-26 13:18:19 -0600 |
commit | d35b73fb0924ebf1f1e43f42eba0f8fe9bfd6dc8 (patch) | |
tree | e0f04ae7c25e16d9bf3f6a33fc02669e9f1e1f01 /gn_auth/auth/authentication/oauth2 | |
parent | 287822eeec02194dd50b00615be7cde98f6a0cbe (diff) | |
download | gn-auth-d35b73fb0924ebf1f1e43f42eba0f8fe9bfd6dc8.tar.gz |
Remove use of obsolete flask_helpers module.
Create the requests in the class, as appropriate, checking for
content-type.
Diffstat (limited to 'gn_auth/auth/authentication/oauth2')
-rw-r--r-- | gn_auth/auth/authentication/oauth2/server.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gn_auth/auth/authentication/oauth2/server.py b/gn_auth/auth/authentication/oauth2/server.py index e6d1e01..c2a175d 100644 --- a/gn_auth/auth/authentication/oauth2/server.py +++ b/gn_auth/auth/authentication/oauth2/server.py @@ -5,10 +5,10 @@ from datetime import datetime from flask import Flask, current_app, request as flask_request from authlib.jose import KeySet +from authlib.oauth2.rfc6749 import OAuth2Request from authlib.oauth2.rfc6749.errors import InvalidClientError from authlib.integrations.flask_oauth2 import AuthorizationServer -from authlib.oauth2.rfc6749 import OAuth2Request -from authlib.integrations.flask_helpers import create_oauth_request +from authlib.integrations.flask_oauth2.requests import FlaskOAuth2Request from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.jwks import ( @@ -102,8 +102,16 @@ class JsonAuthorizationServer(AuthorizationServer): def create_oauth2_request(self, request): """Create an OAuth2 Request from the flask request.""" - res = create_oauth_request(request, OAuth2Request, True) - return res + match flask_request.headers.get("Content-Type"): + case "application/json": + req = OAuth2Request(flask_request.method, + flask_request.url, + flask_request.get_json(), + flask_request.headers) + case _: + req = FlaskOAuth2Request(flask_request) + + return req def setup_oauth2_server(app: Flask) -> None: |