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

Document why auth providers aren't validated in the admin API #12004

Merged
merged 5 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12004.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify information about external Identity Provider IDs.
3 changes: 2 additions & 1 deletion docs/admin_api/user_admin_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ Body parameters:
[Sample Configuration File](../usage/configuration/homeserver_sample_config.html)
section `sso` and `oidc_providers`.
- `auth_provider` - string. ID of the external identity provider. Value of `idp_id`
in homeserver configuration.
in the homeserver configuration. Note that no error is raised if the provided
value is not in the homeserver configuration.
- `external_id` - string, user ID in the external identity provider.
- `avatar_url` - string, optional, must be a
[MXC URI](https://matrix.org/docs/spec/client_server/r0.6.0#matrix-content-mxc-uris).
Expand Down
6 changes: 5 additions & 1 deletion synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,11 @@ def record_user_external_id(
Added in Synapse v1.9.0.

Args:
auth_provider: identifier for the remote auth provider
auth_provider: identifier for the remote auth provider, see `sso` and
`oidc_providers` in the homeserver configuration.

Note that no error is raised if the provided value is not in the
homeserver configuration.
external_id: id on that system
user_id: complete mxid that it is mapped to
"""
Expand Down
21 changes: 21 additions & 0 deletions synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,10 +622,13 @@ async def record_user_external_id(
) -> None:
"""Record a mapping from an external user id to a mxid

See notes in _record_user_external_id_txn about what constitutes valid data.

Args:
auth_provider: identifier for the remote auth provider
external_id: id on that system
user_id: complete mxid that it is mapped to

Raises:
ExternalIDReuseException if the new external_id could not be mapped.
"""
Expand All @@ -648,6 +651,21 @@ def _record_user_external_id_txn(
external_id: str,
user_id: str,
) -> None:
"""
Record a mapping from an external user id to a mxid.

Note that the auth provider IDs (and the external IDs) are not validated
against configured IdPs as Synapse does not know its relationship to
external systems. For example, it might be useful to pre-configure users
before enabling a new IdP or an IdP might be temporarily offline, but
still valid.

Args:
txn: The database transaction.
auth_provider: identifier for the remote auth provider
external_id: id on that system
user_id: complete mxid that it is mapped to
"""

self.db_pool.simple_insert_txn(
txn,
Expand Down Expand Up @@ -687,10 +705,13 @@ async def replace_user_external_id(
"""Replace mappings from external user ids to a mxid in a single transaction.
All mappings are deleted and the new ones are created.

See notes in _record_user_external_id_txn about what constitutes valid data.

Args:
record_external_ids:
List with tuple of auth_provider and external_id to record
user_id: complete mxid that it is mapped to

Raises:
ExternalIDReuseException if the new external_id could not be mapped.
"""
Expand Down