diff options
| author | Frederick Muriuki Muriithi | 2026-08-27 10:51:16 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-08-27 12:51:31 -0500 |
| commit | 800913ddee45fcb0b0e3a9d8c3917d3cf9644ca4 (patch) | |
| tree | 30b78dca5002899cce2d2f875bffe70a74933c87 /gn_auth/auth/authentication | |
| parent | c9d6594750ad7a01b1e23af77e4f847e23f26306 (diff) | |
| download | gn-auth-800913ddee45fcb0b0e3a9d8c3917d3cf9644ca4.tar.gz | |
Cleanup deprecation warnings: Switch to gn_libs.sqlite3
The gn_auth.auth.db.sqlite3 module is deprecated and should be removed. This cleanup goes a ways towards that goal.
Diffstat (limited to 'gn_auth/auth/authentication')
8 files changed, 14 insertions, 10 deletions
diff --git a/gn_auth/auth/authentication/oauth2/endpoints/revocation.py b/gn_auth/auth/authentication/oauth2/endpoints/revocation.py index 0979694..e647214 100644 --- a/gn_auth/auth/authentication/oauth2/endpoints/revocation.py +++ b/gn_auth/auth/authentication/oauth2/endpoints/revocation.py @@ -1,9 +1,9 @@ """Handle token revocation.""" from flask import current_app +from gn_libs import sqlite3 as db from authlib.oauth2.rfc7009 import RevocationEndpoint as _RevocationEndpoint -from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.authentication.oauth2.models.oauth2token import ( save_token, OAuth2Token, revoke_token) diff --git a/gn_auth/auth/authentication/oauth2/endpoints/utilities.py b/gn_auth/auth/authentication/oauth2/endpoints/utilities.py index 490c141..82fd8e1 100644 --- a/gn_auth/auth/authentication/oauth2/endpoints/utilities.py +++ b/gn_auth/auth/authentication/oauth2/endpoints/utilities.py @@ -3,8 +3,8 @@ from typing import Optional from flask import current_app from pymonad.maybe import Nothing +from gn_libs import sqlite3 as db -from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.authentication.oauth2.models.oauth2token import ( OAuth2Token, token_by_access_token, token_by_refresh_token) diff --git a/gn_auth/auth/authentication/oauth2/models/jwt_bearer_token.py b/gn_auth/auth/authentication/oauth2/models/jwt_bearer_token.py index 71769e1..3a93265 100644 --- a/gn_auth/auth/authentication/oauth2/models/jwt_bearer_token.py +++ b/gn_auth/auth/authentication/oauth2/models/jwt_bearer_token.py @@ -3,9 +3,10 @@ import uuid import time from typing import Optional +from flask import current_app as app from authlib.oauth2.rfc7523 import JWTBearerToken as _JWTBearerToken +from gn_libs.sqlite3 import with_db_connection -from gn_auth.auth.db.sqlite3 import with_db_connection from gn_auth.auth.authentication.users import user_by_id from gn_auth.auth.authentication.oauth2.models.oauth2client import ( client as fetch_client) @@ -19,8 +20,10 @@ class JWTBearerToken(_JWTBearerToken): # OAuth2Client is a dataclass super().__init__(payload, header, options, params) self.user = with_db_connection( + app.config["SQL_URI"], lambda conn:user_by_id(conn, uuid.UUID(payload["sub"]))) self.client = with_db_connection( + app.config["SQL_URI"], lambda conn: fetch_client( conn, uuid.UUID(payload["oauth2_client_id"]) ) diff --git a/gn_auth/auth/authentication/oauth2/models/oauth2client.py b/gn_auth/auth/authentication/oauth2/models/oauth2client.py index b3ec91f..818399d 100644 --- a/gn_auth/auth/authentication/oauth2/models/oauth2client.py +++ b/gn_auth/auth/authentication/oauth2/models/oauth2client.py @@ -13,9 +13,9 @@ from requests.exceptions import JSONDecodeError from authlib.jose import KeySet, JsonWebKey from authlib.oauth2.rfc6749 import ClientMixin from pymonad.maybe import Just, Maybe, Nothing +from gn_libs import sqlite3 as db from gn_libs.debug import make_peeker -from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.errors import NotFoundError from gn_auth.auth.authentication.users import (User, fetch_users, diff --git a/gn_auth/auth/authentication/oauth2/models/oauth2token.py b/gn_auth/auth/authentication/oauth2/models/oauth2token.py index 6ec5c3d..eb13f43 100644 --- a/gn_auth/auth/authentication/oauth2/models/oauth2token.py +++ b/gn_auth/auth/authentication/oauth2/models/oauth2token.py @@ -8,8 +8,8 @@ from typing import Optional from authlib.oauth2.rfc6749 import TokenMixin from pymonad.tools import monad_from_none_or_value from pymonad.maybe import Just, Maybe, Nothing +from gn_libs import sqlite3 as db -from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.errors import NotFoundError from gn_auth.auth.authentication.users import User, user_by_id diff --git a/gn_auth/auth/authentication/oauth2/resource_server.py b/gn_auth/auth/authentication/oauth2/resource_server.py index edab02c..c09f6b6 100644 --- a/gn_auth/auth/authentication/oauth2/resource_server.py +++ b/gn_auth/auth/authentication/oauth2/resource_server.py @@ -9,8 +9,8 @@ from authlib.oauth2.rfc6750 import BearerTokenValidator as _BearerTokenValidator from authlib.oauth2.rfc7523 import ( JWTBearerTokenValidator as _JWTBearerTokenValidator) from authlib.integrations.flask_oauth2 import ResourceProtector +from gn_libs import sqlite3 as db -from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.jwks import list_jwks, jwks_directory from gn_auth.auth.authentication.oauth2.models.jwt_bearer_token import ( JWTBearerToken) diff --git a/gn_auth/auth/authentication/oauth2/views.py b/gn_auth/auth/authentication/oauth2/views.py index 8cc123f..e26fc95 100644 --- a/gn_auth/auth/authentication/oauth2/views.py +++ b/gn_auth/auth/authentication/oauth2/views.py @@ -16,9 +16,9 @@ from flask import ( Blueprint, render_template, current_app as app) +from gn_libs import sqlite3 as db +from gn_libs.sqlite3 import with_db_connection -from gn_auth.auth.db import sqlite3 as db -from gn_auth.auth.db.sqlite3 import with_db_connection from gn_auth.auth.jwks import jwks_directory, list_jwks from gn_auth.auth.errors import NotFoundError, ForbiddenAccess from gn_auth.auth.authentication.users import valid_login, user_by_email @@ -68,6 +68,7 @@ def authorise(): redirect_uri=request.args["redirect_uri"], source_uri=f"{_src.scheme}://{_src.netloc}/", display_forgot_password=with_db_connection( + app.config["SQL_URI"], __forgot_password_table_exists__)) form = request.form @@ -102,7 +103,7 @@ def authorise(): flash(email_passwd_msg, "alert alert-danger") return redirect_response # type: ignore[return-value] - return with_db_connection(__authorise__) + return with_db_connection(app.config["SQL_URI"], __authorise__) except InvalidClientError as ice: return render_template( "oauth2/oauth2_error.html", error=ice), ice.status_code diff --git a/gn_auth/auth/authentication/users.py b/gn_auth/auth/authentication/users.py index fded79f..5c6a430 100644 --- a/gn_auth/auth/authentication/users.py +++ b/gn_auth/auth/authentication/users.py @@ -7,8 +7,8 @@ from dataclasses import dataclass import sqlite3 from argon2 import PasswordHasher from argon2.exceptions import VerifyMismatchError +from gn_libs import sqlite3 as db -from gn_auth.auth.db import sqlite3 as db from gn_auth.auth.errors import NotFoundError |
