diff options
Diffstat (limited to 'gn_auth')
4 files changed, 12 insertions, 11 deletions
diff --git a/gn_auth/auth/authentication/oauth2/grants/jwt_bearer_grant.py b/gn_auth/auth/authentication/oauth2/grants/jwt_bearer_grant.py index d663aaf..b0f2cc7 100644 --- a/gn_auth/auth/authentication/oauth2/grants/jwt_bearer_grant.py +++ b/gn_auth/auth/authentication/oauth2/grants/jwt_bearer_grant.py @@ -35,8 +35,10 @@ class JWTBearerTokenGenerator(_JWTBearerTokenGenerator): } - def __call__(self, grant_type, client, user=None, scope=None, - expires_in=None, include_refresh_token=True): + def __call__(# pylint: disable=[too-many-arguments] + self, grant_type, client, user=None, scope=None, expires_in=None, + include_refresh_token=True + ): # there is absolutely no refresh token in JWT format """ The default generator does not provide refresh tokens with JWT. It goes diff --git a/gn_auth/auth/authentication/oauth2/models/oauth2client.py b/gn_auth/auth/authentication/oauth2/models/oauth2client.py index f48cbce..d31faf6 100644 --- a/gn_auth/auth/authentication/oauth2/models/oauth2client.py +++ b/gn_auth/auth/authentication/oauth2/models/oauth2client.py @@ -60,8 +60,8 @@ class OAuth2Client(ClientMixin): @cached_property def jwks(self) -> KeySet: """Return this client's KeySet.""" - def __parse_key__(keypath: Path) -> JsonWebKey:# pylint: disable=[unspecified-encoding] - with open(keypath) as _key: + def __parse_key__(keypath: Path) -> JsonWebKey: + with open(keypath) as _key:# pylint: disable=[unspecified-encoding] return JsonWebKey.import_key(_key.read()) return KeySet([ diff --git a/gn_auth/auth/authentication/oauth2/server.py b/gn_auth/auth/authentication/oauth2/server.py index 75d6e1b..d845c60 100644 --- a/gn_auth/auth/authentication/oauth2/server.py +++ b/gn_auth/auth/authentication/oauth2/server.py @@ -11,7 +11,7 @@ from authlib.integrations.flask_oauth2 import AuthorizationServer from gn_auth.auth.db import sqlite3 as db -from .models.oauth2client import client +from .models.oauth2client import client as fetch_client from .models.oauth2token import OAuth2Token, save_token from .models.jwtrefreshtoken import ( JWTRefreshToken, @@ -36,7 +36,7 @@ def create_query_client_func() -> Callable: # use current_app rather than passing the db_uri to avoid issues # when config changes, e.g. while testing. with db.connection(current_app.config["AUTH_DB"]) as conn: - _client = client(conn, client_id).maybe( + _client = fetch_client(conn, client_id).maybe( None, lambda clt: clt) # type: ignore[misc] if bool(_client): return _client diff --git a/gn_auth/auth/authorisation/users/admin/views.py b/gn_auth/auth/authorisation/users/admin/views.py index f004027..73e808a 100644 --- a/gn_auth/auth/authorisation/users/admin/views.py +++ b/gn_auth/auth/authorisation/users/admin/views.py @@ -18,7 +18,6 @@ from flask import ( url_for, redirect, Blueprint, - current_app, render_template, current_app as app) @@ -91,7 +90,7 @@ def login(): email = validate_email(form.get("email", "").strip(), check_deliverability=False) password = form.get("password") - with db.connection(current_app.config["AUTH_DB"]) as conn: + with db.connection(app.config["AUTH_DB"]) as conn: user = user_by_email(conn, email["email"]) if valid_login(conn, user, password): session.update_session_info( @@ -195,7 +194,7 @@ def register_client(): if request.method == "GET": return render_template( "admin/register-client.html", - scope=current_app.config["OAUTH2_SCOPE"], + scope=app.config["OAUTH2_SCOPE"], users=with_db_connection(__list_users__), granttypes=_FORM_GRANT_TYPES_, current_user=session.session_user()) @@ -259,7 +258,7 @@ def view_client(client_id: uuid.UUID): return render_template( "admin/view-oauth2-client.html", client=with_db_connection(partial(oauth2_client, client_id=client_id)), - scope=current_app.config["OAUTH2_SCOPE"], + scope=app.config["OAUTH2_SCOPE"], granttypes=_FORM_GRANT_TYPES_) @admin.route("/register-client-public-key", methods=["POST"]) @@ -358,7 +357,7 @@ def delete_client_public_key(): client_metadata={ **_client.client_metadata, "public_keys": list(set( - keysdir.joinpath(f"{_key.thumbprint()}.pem") + _keysdir.joinpath(f"{_key.thumbprint()}.pem") for _key in _keys))}, user=_client.user))) flash("Key deleted.", "alert-success") |