🩹(backend) enable resource server authentication if properly configured

Tests are missing, let's ship it, I'll open an issue.

Without such protection, the whole app would crash if the resource server is
not configured. The fallback backend would return an appropriate error to
the client if the resource server is improperly configured.
This commit is contained in:
lebaudantoine
2024-07-29 19:26:50 +02:00
committed by aleb_the_flash
parent f1a2b7c603
commit 78818ba541
3 changed files with 43 additions and 11 deletions

View File

@@ -1,5 +1,7 @@
"""Resource Server Clients classes"""
from django.core.exceptions import ImproperlyConfigured
import requests
from joserfc.jwk import KeySet
@@ -28,6 +30,11 @@ class AuthorizationServerClient:
timeout,
proxy,
):
if not url or not url_jwks or not url_introspection:
raise ImproperlyConfigured(
"Could not instantiate AuthorizationServerClient, some parameters are missing."
)
self.url = url
self._url_introspection = url_introspection
self._url_jwks = url_jwks