From e892ed14da71e2a9204fb841e66aa654017afe0c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 15 Jun 2022 14:07:28 +0200 Subject: [PATCH] providers/oauth2: include source's user path in M2M created users Signed-off-by: Jens Langhammer --- authentik/providers/oauth2/views/token.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/authentik/providers/oauth2/views/token.py b/authentik/providers/oauth2/views/token.py index a82b8f1a0..8aeb5d548 100644 --- a/authentik/providers/oauth2/views/token.py +++ b/authentik/providers/oauth2/views/token.py @@ -329,7 +329,7 @@ class TokenParams: raise TokenError("invalid_grant") self.__check_policy_access(app, request, oauth_jwt=token) - self.__create_user_from_jwt(token, app) + self.__create_user_from_jwt(token, app, source) method_args = { "jwt": token, @@ -345,7 +345,7 @@ class TokenParams: PLAN_CONTEXT_APPLICATION=app, ).from_http(request, user=self.user) - def __create_user_from_jwt(self, token: dict[str, Any], app: Application): + def __create_user_from_jwt(self, token: dict[str, Any], app: Application, source: OAuthSource): """Create user from JWT""" exp = token.get("exp") self.user, created = User.objects.update_or_create( @@ -356,6 +356,7 @@ class TokenParams: }, "last_login": now(), "name": f"Autogenerated user from application {app.name} (client credentials JWT)", + "path": source.get_user_path(), }, ) if created and exp: