From fb015a2c4a6b176030e29bdc299c5213200dcf29 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Wed, 6 Mar 2024 13:28:54 +0300 Subject: Explicitly add keyword arguments to AuthorisationCode. This improves readability. * gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py (AuthorisationCodeGrant.save_authorization_code): Use keyword arguments. * gn_auth/auth/authentication/oauth2/models/authorization_code.py (authorisation_code): Ditto. Signed-off-by: Munyoki Kilyungi --- .../oauth2/grants/authorisation_code_grant.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'gn_auth/auth/authentication/oauth2/grants') diff --git a/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py b/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py index e866c41..98c36ee 100644 --- a/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py +++ b/gn_auth/auth/authentication/oauth2/grants/authorisation_code_grant.py @@ -31,11 +31,21 @@ class AuthorisationCodeGrant(grants.AuthorizationCodeGrant): client = request.client nonce = "".join(random.sample(string.ascii_letters + string.digits, k=self.AUTHORIZATION_CODE_LENGTH)) - return __save_authorization_code__(AuthorisationCode( - uuid.uuid4(), code, client, request.redirect_uri, request.scope, - nonce, int(datetime.now().timestamp()), - create_s256_code_challenge(app.config["SECRET_KEY"]), - "S256", request.user)) + return __save_authorization_code__( + AuthorisationCode( + code_id=uuid.uuid4(), + code=code, + client=client, + redirect_uri=request.redirect_uri, + scope=request.scope, + nonce=nonce, + auth_time=int(datetime.now().timestamp()), + code_challenge=create_s256_code_challenge( + app.config["SECRET_KEY"] + ), + code_challenge_method="S256", + user=request.user) + ) def query_authorization_code(self, code, client): """Retrieve the code from the database.""" -- cgit v1.2.3