providers/oauth2: fix misleading name of cors_allow_any
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> #771
This commit is contained in:
parent
82f6c515ea
commit
392d9bb10b
|
@ -26,8 +26,8 @@ class TokenResponse(JsonResponse):
|
||||||
self["Pragma"] = "no-cache"
|
self["Pragma"] = "no-cache"
|
||||||
|
|
||||||
|
|
||||||
def cors_allow_any(request: HttpRequest, response: HttpResponse, *allowed_origins: str):
|
def cors_allow(request: HttpRequest, response: HttpResponse, *allowed_origins: str):
|
||||||
"""Add headers to permit CORS requests from any origin, with or without credentials,
|
"""Add headers to permit CORS requests from allowed_origins, with or without credentials,
|
||||||
with any headers."""
|
with any headers."""
|
||||||
origin = request.META.get("HTTP_ORIGIN")
|
origin = request.META.get("HTTP_ORIGIN")
|
||||||
if not origin:
|
if not origin:
|
||||||
|
|
|
@ -19,7 +19,7 @@ from authentik.providers.oauth2.models import (
|
||||||
ResponseTypes,
|
ResponseTypes,
|
||||||
ScopeMapping,
|
ScopeMapping,
|
||||||
)
|
)
|
||||||
from authentik.providers.oauth2.utils import cors_allow_any
|
from authentik.providers.oauth2.utils import cors_allow
|
||||||
|
|
||||||
LOGGER = get_logger()
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
@ -112,5 +112,5 @@ class ProviderInfoView(View):
|
||||||
OAuth2Provider, pk=application.provider_id
|
OAuth2Provider, pk=application.provider_id
|
||||||
)
|
)
|
||||||
response = super().dispatch(request, *args, **kwargs)
|
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
|
return response
|
||||||
|
|
|
@ -14,7 +14,7 @@ from authentik.providers.oauth2.constants import (
|
||||||
SCOPE_GITHUB_USER_READ,
|
SCOPE_GITHUB_USER_READ,
|
||||||
)
|
)
|
||||||
from authentik.providers.oauth2.models import RefreshToken, ScopeMapping
|
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()
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class UserInfoView(View):
|
||||||
allowed_origins = []
|
allowed_origins = []
|
||||||
if self.token:
|
if self.token:
|
||||||
allowed_origins = self.token.provider.redirect_uris.split("\n")
|
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
|
return response
|
||||||
|
|
||||||
def options(self, request: HttpRequest) -> HttpResponse:
|
def options(self, request: HttpRequest) -> HttpResponse:
|
||||||
|
|
Reference in New Issue