aboutsummaryrefslogtreecommitdiff
path: root/gn_auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-11-08 12:01:43 -0600
committerFrederick Muriuki Muriithi2024-11-08 12:01:43 -0600
commit4c21d0e43cf0de1084d0e0a243e441c6e72236eb (patch)
tree20d6aba7c2465a5d1e7749edec7d252bae5ce70c /gn_auth
parent5a6dc1fb81bf223750f42f4697f3cd7d86b39e71 (diff)
downloadgn-auth-4c21d0e43cf0de1084d0e0a243e441c6e72236eb.tar.gz
Revert "Debug: Add debug logging to trace JWK fetching."
This reverts commit 5a6dc1fb81bf223750f42f4697f3cd7d86b39e71. Remove debugging statements and restore original code.
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/auth/authentication/oauth2/models/oauth2client.py25
1 files changed, 7 insertions, 18 deletions
diff --git a/gn_auth/auth/authentication/oauth2/models/oauth2client.py b/gn_auth/auth/authentication/oauth2/models/oauth2client.py
index 615d0ee..df5d564 100644
--- a/gn_auth/auth/authentication/oauth2/models/oauth2client.py
+++ b/gn_auth/auth/authentication/oauth2/models/oauth2client.py
@@ -13,7 +13,6 @@ from authlib.jose import KeySet, JsonWebKey
from authlib.oauth2.rfc6749 import ClientMixin
from pymonad.maybe import Just, Maybe, Nothing
-from gn_auth.debug import __pk__, getLogger
from gn_auth.auth.db import sqlite3 as db
from gn_auth.auth.errors import NotFoundError
from gn_auth.auth.authentication.users import (User,
@@ -62,19 +61,10 @@ class OAuth2Client(ClientMixin):
def jwks(self) -> KeySet:
"""Return this client's KeySet."""
- logger = getLogger(__name__)
jwksuri = self.client_metadata.get("public-jwks-uri")
- ### ----- DEBUG: Remove this section ----- ###
- import os
- from pathlib import Path
- ca_bundle = Path(os.environ.get("REQUESTS_CA_BUNDLE"))
- __pk__(f"{ca_bundle} exists?", ca_bundle.exists())
- ### ----- DEBUG: Remove this section ----- ###
- if not bool(__pk__(
- f"CLIENT'S ({self.client_id}) JWKs URI =======> ", jwksuri)):
- logger.debug("No Public JWKs URI set for client!")
- return __pk__("Return empty KeySet since URI is not set =====>",
- KeySet([]))
+ if not bool(jwksuri):
+ logging.debug("No Public JWKs URI set for client!")
+ return KeySet([])
try:
## IMPORTANT: This can cause a deadlock if the client is working in
## single-threaded mode, i.e. can only serve one request
@@ -82,16 +72,15 @@ class OAuth2Client(ClientMixin):
return KeySet([JsonWebKey.import_key(key)
for key in requests.get(jwksuri).json()["jwks"]])
except requests.ConnectionError as _connerr:
- logger.debug(
+ logging.debug(
"Could not connect to provided URI: %s", jwksuri, exc_info=True)
except JSONDecodeError as _jsonerr:
- logger.debug(
+ logging.debug(
"Could not convert response to JSON", exc_info=True)
except Exception as _exc:# pylint: disable=[broad-except]
- logger.debug(
+ logging.debug(
"Error retrieving the JWKs for the client.", exc_info=True)
- return __pk__("Return empty KeySet after failure =====>",
- KeySet([]))
+ return KeySet([])
def check_endpoint_auth_method(self, method: str, endpoint: str) -> bool: