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:
parent
093a67525a
commit
e892ed14da
|
@ -329,7 +329,7 @@ class TokenParams:
|
||||||
raise TokenError("invalid_grant")
|
raise TokenError("invalid_grant")
|
||||||
|
|
||||||
self.__check_policy_access(app, request, oauth_jwt=token)
|
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 = {
|
method_args = {
|
||||||
"jwt": token,
|
"jwt": token,
|
||||||
|
@ -345,7 +345,7 @@ class TokenParams:
|
||||||
PLAN_CONTEXT_APPLICATION=app,
|
PLAN_CONTEXT_APPLICATION=app,
|
||||||
).from_http(request, user=self.user)
|
).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"""
|
"""Create user from JWT"""
|
||||||
exp = token.get("exp")
|
exp = token.get("exp")
|
||||||
self.user, created = User.objects.update_or_create(
|
self.user, created = User.objects.update_or_create(
|
||||||
|
@ -356,6 +356,7 @@ class TokenParams:
|
||||||
},
|
},
|
||||||
"last_login": now(),
|
"last_login": now(),
|
||||||
"name": f"Autogenerated user from application {app.name} (client credentials JWT)",
|
"name": f"Autogenerated user from application {app.name} (client credentials JWT)",
|
||||||
|
"path": source.get_user_path(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if created and exp:
|
if created and exp:
|
||||||
|
|
Reference in New Issue