providers/oauth2: include source's user path in M2M created users

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-06-15 14:07:28 +02:00
parent 093a67525a
commit e892ed14da
1 changed files with 3 additions and 2 deletions

View File

@ -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: