diff options
| author | Frederick Muriuki Muriithi | 2026-08-28 17:40:09 +0000 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-08-28 12:43:48 -0500 |
| commit | cdf3daefaa6b7870b2f36da440c59c327ea1d62f (patch) | |
| tree | c497dcef75fc64677664c6efba60b0baa76c8e4e | |
| parent | 800913ddee45fcb0b0e3a9d8c3917d3cf9644ca4 (diff) | |
| download | gn-auth-cdf3daefaa6b7870b2f36da440c59c327ea1d62f.tar.gz | |
fix(jwt-bearer-token): use AUTH_DB instead of SQL_URI for user/client lookup
JWTBearerToken.__init__ was calling with_db_connection with app.config["SQL_URI"] (the GeneNetwork MariaDB URI) to look up the authenticated user and OAuth2 client. gn_libs.sqlite3.with_db_connection expects a SQLite file path, so passing a MySQL URI causes an OperationalError: unable to open database file every time a JWT is validated through require_oauth.acquire(). Use app.config["AUTH_DB"] (the gn-auth SQLite database) for both lookups. Also normalise the whitespace in the user lookup lambda while here. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
| -rw-r--r-- | gn_auth/auth/authentication/oauth2/models/jwt_bearer_token.py | 6 |
1 files changed, 3 insertions, 3 deletions
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 3a93265..39249ba 100644 --- a/gn_auth/auth/authentication/oauth2/models/jwt_bearer_token.py +++ b/gn_auth/auth/authentication/oauth2/models/jwt_bearer_token.py @@ -20,10 +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"]))) + app.config["AUTH_DB"], + lambda conn: user_by_id(conn, uuid.UUID(payload["sub"]))) self.client = with_db_connection( - app.config["SQL_URI"], + app.config["AUTH_DB"], lambda conn: fetch_client( conn, uuid.UUID(payload["oauth2_client_id"]) ) |
