mirror of
https://github.com/suitenumerique/django-lasuite
synced 2026-04-25 17:15:14 +02:00
🔊(oidc) improve logging for improperly configured authorization clients
Enhance the log message to explicitly list which configuration parameters are missing. The previous message was too vague and required searching the repository to understand its origin. This was made harder because the class name is dynamically injected, preventing a direct search of the full log string. Note: instantiating JWTAuthorizationServerClient may emit two logs when all required parameters are missing. This behavior can be refined in a future change.
This commit is contained in:
committed by
Lebaud Antoine
parent
1534cbffd1
commit
d87d7059bc
@@ -20,6 +20,7 @@ and this project adheres to
|
||||
### Changed
|
||||
|
||||
- 🚸(oidc) ignore case when fallback on email #61
|
||||
- 🔊(oidc) improve logging for improperly configured authorization clients #66
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -30,8 +30,19 @@ class AuthorizationServerClient:
|
||||
self._proxy = settings.OIDC_PROXY
|
||||
self._url_introspection = settings.OIDC_OP_INTROSPECTION_ENDPOINT
|
||||
|
||||
if not self.url or not self._url_introspection:
|
||||
raise ImproperlyConfigured(f"Could not instantiate {self.__class__.__name__}, some parameters are missing.")
|
||||
missing = [
|
||||
name
|
||||
for name, value in [
|
||||
("OIDC_OP_URL", self.url),
|
||||
("OIDC_OP_INTROSPECTION_ENDPOINT", self._url_introspection),
|
||||
]
|
||||
if not value
|
||||
]
|
||||
|
||||
if missing:
|
||||
raise ImproperlyConfigured(
|
||||
f"Could not instantiate {self.__class__.__name__}: missing required settings: {', '.join(missing)}"
|
||||
)
|
||||
|
||||
@property
|
||||
def _introspection_headers(self):
|
||||
@@ -90,7 +101,9 @@ class JWTAuthorizationServerClient(AuthorizationServerClient):
|
||||
self._url_jwks = settings.OIDC_OP_JWKS_ENDPOINT
|
||||
|
||||
if not self._url_jwks:
|
||||
raise ImproperlyConfigured(f"Could not instantiate {self.__class__.__name__}, some parameters are missing.")
|
||||
raise ImproperlyConfigured(
|
||||
f"Could not instantiate {self.__class__.__name__}, OIDC_OP_JWKS_ENDPOINT is missing."
|
||||
)
|
||||
|
||||
def get_jwks(self):
|
||||
"""Retrieve Authorization Server JWKS."""
|
||||
|
||||
Reference in New Issue
Block a user