From 392d9bb10be32898466f64cd2eecd8327b6f4c0c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 22 Apr 2021 23:29:49 +0200 Subject: [PATCH] providers/oauth2: fix misleading name of cors_allow_any Signed-off-by: Jens Langhammer #771 --- authentik/providers/oauth2/utils.py | 4 ++-- authentik/providers/oauth2/views/provider.py | 4 ++-- authentik/providers/oauth2/views/userinfo.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/authentik/providers/oauth2/utils.py b/authentik/providers/oauth2/utils.py index 919633788..18a62411c 100644 --- a/authentik/providers/oauth2/utils.py +++ b/authentik/providers/oauth2/utils.py @@ -26,8 +26,8 @@ class TokenResponse(JsonResponse): self["Pragma"] = "no-cache" -def cors_allow_any(request: HttpRequest, response: HttpResponse, *allowed_origins: str): - """Add headers to permit CORS requests from any origin, with or without credentials, +def cors_allow(request: HttpRequest, response: HttpResponse, *allowed_origins: str): + """Add headers to permit CORS requests from allowed_origins, with or without credentials, with any headers.""" origin = request.META.get("HTTP_ORIGIN") if not origin: diff --git a/authentik/providers/oauth2/views/provider.py b/authentik/providers/oauth2/views/provider.py index 3adb6c436..aafa69958 100644 --- a/authentik/providers/oauth2/views/provider.py +++ b/authentik/providers/oauth2/views/provider.py @@ -19,7 +19,7 @@ from authentik.providers.oauth2.models import ( ResponseTypes, ScopeMapping, ) -from authentik.providers.oauth2.utils import cors_allow_any +from authentik.providers.oauth2.utils import cors_allow LOGGER = get_logger() @@ -112,5 +112,5 @@ class ProviderInfoView(View): OAuth2Provider, pk=application.provider_id ) response = super().dispatch(request, *args, **kwargs) - cors_allow_any(request, response, *self.provider.redirect_uris.split("\n")) + cors_allow(request, response, *self.provider.redirect_uris.split("\n")) return response diff --git a/authentik/providers/oauth2/views/userinfo.py b/authentik/providers/oauth2/views/userinfo.py index fe7d7e121..75f5135dd 100644 --- a/authentik/providers/oauth2/views/userinfo.py +++ b/authentik/providers/oauth2/views/userinfo.py @@ -14,7 +14,7 @@ from authentik.providers.oauth2.constants import ( SCOPE_GITHUB_USER_READ, ) from authentik.providers.oauth2.models import RefreshToken, ScopeMapping -from authentik.providers.oauth2.utils import TokenResponse, cors_allow_any +from authentik.providers.oauth2.utils import TokenResponse, cors_allow LOGGER = get_logger() @@ -88,7 +88,7 @@ class UserInfoView(View): allowed_origins = [] if self.token: allowed_origins = self.token.provider.redirect_uris.split("\n") - cors_allow_any(self.request, response, *allowed_origins) + cors_allow(self.request, response, *allowed_origins) return response def options(self, request: HttpRequest) -> HttpResponse: