From 3d9f7ee27e79b959d4fc6e9e8b60a0cfd3c5101e Mon Sep 17 00:00:00 2001 From: Jens L Date: Fri, 3 Nov 2023 00:11:30 +0100 Subject: [PATCH] providers/oauth2: set auth_via for token and other endpoints (#7417) Signed-off-by: Jens Langhammer --- authentik/providers/oauth2/utils.py | 1 + authentik/providers/oauth2/views/token.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/authentik/providers/oauth2/utils.py b/authentik/providers/oauth2/utils.py index cc7a86519..513994b80 100644 --- a/authentik/providers/oauth2/utils.py +++ b/authentik/providers/oauth2/utils.py @@ -188,6 +188,7 @@ def authenticate_provider(request: HttpRequest) -> Optional[OAuth2Provider]: if client_id != provider.client_id or client_secret != provider.client_secret: LOGGER.debug("(basic) Provider for basic auth does not exist") return None + CTX_AUTH_VIA.set("oauth_client_secret") return provider diff --git a/authentik/providers/oauth2/views/token.py b/authentik/providers/oauth2/views/token.py index dc08eb526..146978fe1 100644 --- a/authentik/providers/oauth2/views/token.py +++ b/authentik/providers/oauth2/views/token.py @@ -17,6 +17,7 @@ from jwt import PyJWK, PyJWT, PyJWTError, decode from sentry_sdk.hub import Hub from structlog.stdlib import get_logger +from authentik.core.middleware import CTX_AUTH_VIA from authentik.core.models import ( USER_ATTRIBUTE_EXPIRES, USER_ATTRIBUTE_GENERATED, @@ -448,6 +449,7 @@ class TokenView(View): if not self.provider: LOGGER.warning("OAuth2Provider does not exist", client_id=client_id) raise TokenError("invalid_client") + CTX_AUTH_VIA.set("oauth_client_secret") self.params = TokenParams.parse(request, self.provider, client_id, client_secret) with Hub.current.start_span(