Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 444b040

Browse files
authored
Document why auth providers aren't validated in the admin API. (#12004)
Since it is reasonable to give a future or past auth provider, which might not be in the current configuration.
1 parent 284ea20 commit 444b040

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

Diff for: changelog.d/12004.doc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clarify information about external Identity Provider IDs.

Diff for: docs/admin_api/user_admin_api.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ Body parameters:
126126
[Sample Configuration File](../usage/configuration/homeserver_sample_config.html)
127127
section `sso` and `oidc_providers`.
128128
- `auth_provider` - string. ID of the external identity provider. Value of `idp_id`
129-
in homeserver configuration.
129+
in the homeserver configuration. Note that no error is raised if the provided
130+
value is not in the homeserver configuration.
130131
- `external_id` - string, user ID in the external identity provider.
131132
- `avatar_url` - string, optional, must be a
132133
[MXC URI](https://matrix.org/docs/spec/client_server/r0.6.0#matrix-content-mxc-uris).

Diff for: synapse/module_api/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,11 @@ def record_user_external_id(
653653
Added in Synapse v1.9.0.
654654
655655
Args:
656-
auth_provider: identifier for the remote auth provider
656+
auth_provider: identifier for the remote auth provider, see `sso` and
657+
`oidc_providers` in the homeserver configuration.
658+
659+
Note that no error is raised if the provided value is not in the
660+
homeserver configuration.
657661
external_id: id on that system
658662
user_id: complete mxid that it is mapped to
659663
"""

Diff for: synapse/storage/databases/main/registration.py

+21
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,13 @@ async def record_user_external_id(
622622
) -> None:
623623
"""Record a mapping from an external user id to a mxid
624624
625+
See notes in _record_user_external_id_txn about what constitutes valid data.
626+
625627
Args:
626628
auth_provider: identifier for the remote auth provider
627629
external_id: id on that system
628630
user_id: complete mxid that it is mapped to
631+
629632
Raises:
630633
ExternalIDReuseException if the new external_id could not be mapped.
631634
"""
@@ -648,6 +651,21 @@ def _record_user_external_id_txn(
648651
external_id: str,
649652
user_id: str,
650653
) -> None:
654+
"""
655+
Record a mapping from an external user id to a mxid.
656+
657+
Note that the auth provider IDs (and the external IDs) are not validated
658+
against configured IdPs as Synapse does not know its relationship to
659+
external systems. For example, it might be useful to pre-configure users
660+
before enabling a new IdP or an IdP might be temporarily offline, but
661+
still valid.
662+
663+
Args:
664+
txn: The database transaction.
665+
auth_provider: identifier for the remote auth provider
666+
external_id: id on that system
667+
user_id: complete mxid that it is mapped to
668+
"""
651669

652670
self.db_pool.simple_insert_txn(
653671
txn,
@@ -687,10 +705,13 @@ async def replace_user_external_id(
687705
"""Replace mappings from external user ids to a mxid in a single transaction.
688706
All mappings are deleted and the new ones are created.
689707
708+
See notes in _record_user_external_id_txn about what constitutes valid data.
709+
690710
Args:
691711
record_external_ids:
692712
List with tuple of auth_provider and external_id to record
693713
user_id: complete mxid that it is mapped to
714+
694715
Raises:
695716
ExternalIDReuseException if the new external_id could not be mapped.
696717
"""

0 commit comments

Comments
 (0)