Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
51fb0fc2
Unverified
Commit
51fb0fc2
authored
4 years ago
by
Patrick Cloke
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update documentation about SSO mapping providers (#7458)
parent
1a1da60a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/7458.doc
+1
-0
1 addition, 0 deletions
changelog.d/7458.doc
docs/sso_mapping_providers.md
+146
-0
146 additions, 0 deletions
docs/sso_mapping_providers.md
with
147 additions
and
0 deletions
changelog.d/7458.doc
0 → 100644
+
1
−
0
View file @
51fb0fc2
Update information about mapping providers for SAML and OpenID.
This diff is collapsed.
Click to expand it.
docs/s
aml
_mapping_providers.md
→
docs/s
so
_mapping_providers.md
+
146
−
0
View file @
51fb0fc2
# S
AML
Mapping Providers
# S
SO
Mapping Providers
A
SAML
mapping provider is a Python class (loaded via a Python module) that
works out how to map attributes of a S
AML
response
object
to Matrix-specific
A mapping provider is a Python class (loaded via a Python module) that
works out how to map attributes of a S
SO
response to Matrix-specific
user attributes. Details such as user ID localpart, displayname, and even avatar
URLs are all things that can be mapped from talking to a SSO service.
...
...
@@ -12,11 +12,70 @@ It may choose `John Smith`, or `Smith, John [Example.com]` or any number of
variations. As each Synapse configuration may want something different, this is
where SAML mapping providers come into play.
## Enabling Providers
SSO mapping providers are currently supported for OpenID and SAML SSO
configurations. Please see the details below for how to implement your own.
External mapping providers are provided to Synapse in the form of an external
Python module. Retrieve this module from
[
PyPi
](
https://pypi.org
)
or elsewhere,
then tell Synapse where to look for the handler class by editing the
Python module. You can retrieve this module from
[
PyPi
](
https://pypi.org
)
or elsewhere,
but it must be importable via Synapse (e.g. it must be in the same virtualenv
as Synapse). The Synapse config is then modified to point to the mapping provider
(and optionally provide additional configuration for it).
## OpenID Mapping Providers
The OpenID mapping provider can be customized by editing the
`oidc_config.user_mapping_provider.module`
config option.
`oidc_config.user_mapping_provider.config`
allows you to provide custom
configuration options to the module. Check with the module's documentation for
what options it provides (if any). The options listed by default are for the
user mapping provider built in to Synapse. If using a custom module, you should
comment these options out and use those specified by the module instead.
### Building a Custom OpenID Mapping Provider
A custom mapping provider must specify the following methods:
*
`__init__(self, parsed_config)`
-
Arguments:
-
`parsed_config`
- A configuration object that is the return value of the
`parse_config`
method. You should set any configuration options needed by
the module here.
*
`parse_config(config)`
-
This method should have the
`@staticmethod`
decoration.
-
Arguments:
-
`config`
- A
`dict`
representing the parsed content of the
`oidc_config.user_mapping_provider.config`
homeserver config option.
Runs on homeserver startup. Providers should extract and validate
any option values they need here.
-
Whatever is returned will be passed back to the user mapping provider module's
`__init__`
method during construction.
*
`get_remote_user_id(self, userinfo)`
-
Arguments:
-
`userinfo`
- A
`authlib.oidc.core.claims.UserInfo`
object to extract user
information from.
-
This method must return a string, which is the unique identifier for the
user. Commonly the
``sub``
claim of the response.
*
`map_user_attributes(self, userinfo, token)`
-
This method should be async.
-
Arguments:
-
`userinfo`
- A
`authlib.oidc.core.claims.UserInfo`
object to extract user
information from.
-
`token`
- A dictionary which includes information necessary to make
further requests to the OpenID provider.
-
Returns a dictionary with two keys:
-
localpart: A required string, used to generate the Matrix ID.
-
displayname: An optional string, the display name for the user.
### Default OpenID Mapping Provider
Synapse has a built-in OpenID mapping provider if a custom provider isn't
specified in the config. It is located at
[
`synapse.handlers.oidc_handler.JinjaOidcMappingProvider`
](
../synapse/handlers/oidc_handler.py
)
.
## SAML Mapping Providers
The SAML mapping provider can be customized by editing the
`saml2_config.user_mapping_provider.module`
config option.
`saml2_config.user_mapping_provider.config`
allows you to provide custom
...
...
@@ -25,7 +84,7 @@ what options it provides (if any). The options listed by default are for the
user mapping provider built in to Synapse. If using a custom module, you should
comment these options out and use those specified by the module instead.
## Building a Custom Mapping Provider
##
#
Building a Custom
SAML
Mapping Provider
A custom mapping provider must specify the following methods:
...
...
@@ -34,7 +93,32 @@ A custom mapping provider must specify the following methods:
-
`parsed_config`
- A configuration object that is the return value of the
`parse_config`
method. You should set any configuration options needed by
the module here.
*
`saml_response_to_user_attributes(self, saml_response, failures)`
*
`parse_config(config)`
-
This method should have the
`@staticmethod`
decoration.
-
Arguments:
-
`config`
- A
`dict`
representing the parsed content of the
`saml_config.user_mapping_provider.config`
homeserver config option.
Runs on homeserver startup. Providers should extract and validate
any option values they need here.
-
Whatever is returned will be passed back to the user mapping provider module's
`__init__`
method during construction.
*
`get_saml_attributes(config)`
-
This method should have the
`@staticmethod`
decoration.
-
Arguments:
-
`config`
- A object resulting from a call to
`parse_config`
.
-
Returns a tuple of two sets. The first set equates to the SAML auth
response attributes that are required for the module to function, whereas
the second set consists of those attributes which can be used if available,
but are not necessary.
*
`get_remote_user_id(self, saml_response, client_redirect_url)`
-
Arguments:
-
`saml_response`
- A
`saml2.response.AuthnResponse`
object to extract user
information from.
-
`client_redirect_url`
- A string, the URL that the client will be
redirected to.
-
This method must return a string, which is the unique identifier for the
user. Commonly the
``uid``
claim of the response.
*
`saml_response_to_user_attributes(self, saml_response, failures, client_redirect_url)`
-
Arguments:
-
`saml_response`
- A
`saml2.response.AuthnResponse`
object to extract user
information from.
...
...
@@ -47,30 +131,15 @@ A custom mapping provider must specify the following methods:
method will be called again with the same parameters but
with failures=1. The method should then return a different
`mxid_localpart`
value, such as
`john.doe1`
.
-
`client_redirect_url`
- A string, the URL that the client will be
redirected to.
-
This method must return a dictionary, which will then be used by Synapse
to build a new user. The following keys are allowed:
*
`mxid_localpart`
- Required. The mxid localpart of the new user.
*
`displayname`
- The displayname of the new user. If not provided, will default to
the value of
`mxid_localpart`
.
*
`parse_config(config)`
-
This method should have the
`@staticmethod`
decoration.
-
Arguments:
-
`config`
- A
`dict`
representing the parsed content of the
`saml2_config.user_mapping_provider.config`
homeserver config option.
Runs on homeserver startup. Providers should extract any option values
they need here.
-
Whatever is returned will be passed back to the user mapping provider module's
`__init__`
method during construction.
*
`get_saml_attributes(config)`
-
This method should have the
`@staticmethod`
decoration.
-
Arguments:
-
`config`
- A object resulting from a call to
`parse_config`
.
-
Returns a tuple of two sets. The first set equates to the saml auth
response attributes that are required for the module to function, whereas
the second set consists of those attributes which can be used if available,
but are not necessary.
##
Synapse's Default
Provider
##
# Default SAML Mapping
Provider
Synapse has a built-in SAML mapping provider if a custom provider isn't
specified in the config. It is located at
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment