summary refs log tree commit diff
diff options
context:
space:
mode:
authorHugh Nimmo-Smith <hughns@matrix.org>2022-09-20 12:54:18 +0100
committerPatrick Cloke <clokep@users.noreply.github.com>2023-05-30 09:43:06 -0400
commitd20669971a5be17776a2991c77f5348662bb3902 (patch)
treed2ccd8d9b6d06e391dd68d8e25fddd1605288549
parentRecord the `sub` claims as an external_id (diff)
downloadsynapse-d20669971a5be17776a2991c77f5348662bb3902.tar.xz
Use `name` claim as display name when registering users on the fly.
This makes is so that the `name` claim got when introspecting the token
is used as the display name when registering a user on the fly.
-rw-r--r--synapse/api/auth/oauth_delegated.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/api/auth/oauth_delegated.py b/synapse/api/auth/oauth_delegated.py
index 5565ef0a1a..9e01e3fadc 100644
--- a/synapse/api/auth/oauth_delegated.py
+++ b/synapse/api/auth/oauth_delegated.py
@@ -200,7 +200,14 @@ class OAuthDelegatedAuth(BaseAuth):
                 # TODO: we could use SCIM to provision users ahead of time and listen
                 # for SCIM SET events if those ever become standard:
                 # https://datatracker.ietf.org/doc/html/draft-hunt-scim-notify-00
-                await self.store.register_user(user_id=user_id.to_string())
+
+                # TODO: claim mapping should be configurable
+                # If present, use the name claim as the displayname
+                name: Optional[str] = introspection_result.get("name")
+
+                await self.store.register_user(
+                    user_id=user_id.to_string(), create_profile_with_displayname=name
+                )
 
             # And record the sub as external_id
             await self.store.record_user_external_id(