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: