@@ -69,7 +69,9 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
6969 #
7070 # idp_icon: An optional icon for this identity provider, which is presented
7171 # by identity picker pages. If given, must be an MXC URI of the format
72- # mxc://<server-name>/<media-id>
72+ # mxc://<server-name>/<media-id>. (An easy way to obtain such an MXC URI
73+ # is to upload an image to an (unencrypted) room and then copy the "url"
74+ # from the source of the event.)
7375 #
7476 # discover: set to 'false' to disable the use of the OIDC discovery mechanism
7577 # to discover endpoints. Defaults to true.
@@ -155,13 +157,16 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
155157 #
156158 # For backwards compatibility, it is also possible to configure a single OIDC
157159 # provider via an 'oidc_config' setting. This is now deprecated and admins are
158- # advised to migrate to the 'oidc_providers' format.
160+ # advised to migrate to the 'oidc_providers' format. (When doing that migration,
161+ # use 'oidc' for the idp_id to ensure that existing users continue to be
162+ # recognised.)
159163 #
160164 oidc_providers:
161165 # Generic example
162166 #
163167 #- idp_id: my_idp
164168 # idp_name: "My OpenID provider"
169+ # idp_icon: "mxc://example.com/mediaid"
165170 # discover: false
166171 # issuer: "https://accounts.example.com/"
167172 # client_id: "provided-by-your-issuer"
@@ -185,8 +190,8 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
185190
186191 # For use with Github
187192 #
188- #- idp_id: google
189- # idp_name: Google
193+ #- idp_id: github
194+ # idp_name: Github
190195 # discover: false
191196 # issuer: "https://github.com/"
192197 # client_id: "your-client-id" # TO BE FILLED
@@ -210,6 +215,8 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
210215 "type" : "object" ,
211216 "required" : ["issuer" , "client_id" , "client_secret" ],
212217 "properties" : {
218+ # TODO: fix the maxLength here depending on what MSC2528 decides
219+ # remember that we prefix the ID given here with `oidc-`
213220 "idp_id" : {"type" : "string" , "minLength" : 1 , "maxLength" : 128 },
214221 "idp_name" : {"type" : "string" },
215222 "idp_icon" : {"type" : "string" },
@@ -335,6 +342,8 @@ def _parse_oidc_config_dict(
335342 # enforce those limits now.
336343 # TODO: factor out this stuff to a generic function
337344 idp_id = oidc_config .get ("idp_id" , "oidc" )
345+
346+ # TODO: update this validity check based on what MSC2858 decides.
338347 valid_idp_chars = set (string .ascii_lowercase + string .digits + "-._" )
339348
340349 if any (c not in valid_idp_chars for c in idp_id ):
@@ -348,6 +357,17 @@ def _parse_oidc_config_dict(
348357 "idp_id must start with a-z" , config_path + ("idp_id" ,),
349358 )
350359
360+ # prefix the given IDP with a prefix specific to the SSO mechanism, to avoid
361+ # clashes with other mechs (such as SAML, CAS).
362+ #
363+ # We allow "oidc" as an exception so that people migrating from old-style
364+ # "oidc_config" format (which has long used "oidc" as its idp_id) can migrate to
365+ # a new-style "oidc_providers" entry without changing the idp_id for their provider
366+ # (and thereby invalidating their user_external_ids data).
367+
368+ if idp_id != "oidc" :
369+ idp_id = "oidc-" + idp_id
370+
351371 # MSC2858 also specifies that the idp_icon must be a valid MXC uri
352372 idp_icon = oidc_config .get ("idp_icon" )
353373 if idp_icon is not None :
0 commit comments