This commit is contained in:
clokep 2023-01-04 20:01:14 +00:00
parent a4cbf9eb79
commit b6fd9153df
4 changed files with 708 additions and 646 deletions

View File

@ -218,88 +218,36 @@ Edit your Synapse config file and change the <code>oidc_config</code> section:</
localpart_template: &quot;{{ user.preferred_username.split('@')[0] }}&quot; localpart_template: &quot;{{ user.preferred_username.split('@')[0] }}&quot;
display_name_template: &quot;{{ user.name }}&quot; display_name_template: &quot;{{ user.name }}&quot;
</code></pre> </code></pre>
<h3 id="dex"><a class="header" href="#dex">Dex</a></h3> <h3 id="apple"><a class="header" href="#apple">Apple</a></h3>
<p><a href="https://github.com/dexidp/dex">Dex</a> is a simple, open-source OpenID Connect Provider. <p>Configuring &quot;Sign in with Apple&quot; (SiWA) requires an Apple Developer account.</p>
Although it is designed to help building a full-blown provider with an <p>You will need to create a new &quot;Services ID&quot; for SiWA, and create and download a
external database, it can be configured with static passwords in a config file.</p> private key with &quot;SiWA&quot; enabled.</p>
<p>Follow the <a href="https://dexidp.io/docs/getting-started/">Getting Started guide</a> <p>As well as the private key file, you will need:</p>
to install Dex.</p> <ul>
<p>Edit <code>examples/config-dev.yaml</code> config file from the Dex repo to add a client:</p> <li>Client ID: the &quot;identifier&quot; you gave the &quot;Services ID&quot;</li>
<pre><code class="language-yaml">staticClients: <li>Team ID: a 10-character ID associated with your developer account.</li>
- id: synapse <li>Key ID: the 10-character identifier for the key.</li>
secret: secret </ul>
redirectURIs: <p><a href="https://help.apple.com/developer-account/?lang=en#/dev77c875b7e">Apple's developer documentation</a>
- '[synapse public baseurl]/_synapse/client/oidc/callback' has more information on setting up SiWA.</p>
name: 'Synapse' <p>The synapse config will look like this:</p>
</code></pre> <pre><code class="language-yaml"> - idp_id: apple
<p>Run with <code>dex serve examples/config-dev.yaml</code>.</p> idp_name: Apple
<p>Synapse config:</p> issuer: &quot;https://appleid.apple.com&quot;
<pre><code class="language-yaml">oidc_providers: client_id: &quot;your-client-id&quot; # Set to the &quot;identifier&quot; for your &quot;ServicesID&quot;
- idp_id: dex client_auth_method: &quot;client_secret_post&quot;
idp_name: &quot;My Dex server&quot; client_secret_jwt_key:
skip_verification: true # This is needed as Dex is served on an insecure endpoint key_file: &quot;/path/to/AuthKey_KEYIDCODE.p8&quot; # point to your key file
issuer: &quot;http://127.0.0.1:5556/dex&quot; jwt_header:
client_id: &quot;synapse&quot; alg: ES256
client_secret: &quot;secret&quot; kid: &quot;KEYIDCODE&quot; # Set to the 10-char Key ID
scopes: [&quot;openid&quot;, &quot;profile&quot;] jwt_payload:
iss: TEAMIDCODE # Set to the 10-char Team ID
scopes: [&quot;name&quot;, &quot;email&quot;, &quot;openid&quot;]
authorization_endpoint: https://appleid.apple.com/auth/authorize?response_mode=form_post
user_mapping_provider: user_mapping_provider:
config: config:
localpart_template: &quot;{{ user.name }}&quot; email_template: &quot;{{ user.email }}&quot;
display_name_template: &quot;{{ user.name|capitalize }}&quot;
</code></pre>
<h3 id="keycloak"><a class="header" href="#keycloak">Keycloak</a></h3>
<p><a href="https://www.keycloak.org/docs/latest/server_admin/#sso-protocols">Keycloak</a> is an opensource IdP maintained by Red Hat.</p>
<p>Keycloak supports OIDC Back-Channel Logout, which sends logout notification to Synapse, so that Synapse users get logged out when they log out from Keycloak.
This can be optionally enabled by setting <code>backchannel_logout_enabled</code> to <code>true</code> in the Synapse configuration, and by setting the &quot;Backchannel Logout URL&quot; in Keycloak.</p>
<p>Follow the <a href="https://www.keycloak.org/getting-started">Getting Started Guide</a> to install Keycloak and set up a realm.</p>
<ol>
<li>
<p>Click <code>Clients</code> in the sidebar and click <code>Create</code></p>
</li>
<li>
<p>Fill in the fields as below:</p>
</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client ID</td><td><code>synapse</code></td></tr>
<tr><td>Client Protocol</td><td><code>openid-connect</code></td></tr>
</tbody></table>
<ol start="3">
<li>Click <code>Save</code></li>
<li>Fill in the fields as below:</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client ID</td><td><code>synapse</code></td></tr>
<tr><td>Enabled</td><td><code>On</code></td></tr>
<tr><td>Client Protocol</td><td><code>openid-connect</code></td></tr>
<tr><td>Access Type</td><td><code>confidential</code></td></tr>
<tr><td>Valid Redirect URIs</td><td><code>[synapse public baseurl]/_synapse/client/oidc/callback</code></td></tr>
<tr><td>Backchannel Logout URL (optional)</td><td> <code>[synapse public baseurl]/_synapse/client/oidc/backchannel_logout</code></td></tr>
<tr><td>Backchannel Logout Session Required (optional)</td><td> <code>On</code></td></tr>
</tbody></table>
<ol start="5">
<li>Click <code>Save</code></li>
<li>On the Credentials tab, update the fields:</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client Authenticator</td><td><code>Client ID and Secret</code></td></tr>
</tbody></table>
<ol start="7">
<li>Click <code>Regenerate Secret</code></li>
<li>Copy Secret</li>
</ol>
<pre><code class="language-yaml">oidc_providers:
- idp_id: keycloak
idp_name: &quot;My KeyCloak server&quot;
issuer: &quot;https://127.0.0.1:8443/realms/{realm_name}&quot;
client_id: &quot;synapse&quot;
client_secret: &quot;copy secret generated from above&quot;
scopes: [&quot;openid&quot;, &quot;profile&quot;]
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
backchannel_logout_enabled: true # Optional
</code></pre> </code></pre>
<h3 id="auth0"><a class="header" href="#auth0">Auth0</a></h3> <h3 id="auth0"><a class="header" href="#auth0">Auth0</a></h3>
<p><a href="https://auth0.com/">Auth0</a> is a hosted SaaS IdP solution.</p> <p><a href="https://auth0.com/">Auth0</a> is a hosted SaaS IdP solution.</p>
@ -380,253 +328,34 @@ This can be optionally enabled by setting <code>backchannel_logout_enabled</code
localpart_template: &quot;{{ user.preferred_username }}&quot; localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.preferred_username|capitalize }}&quot; # TO BE FILLED: If your users have names in Authentik and you want those in Synapse, this should be replaced with user.name|capitalize. display_name_template: &quot;{{ user.preferred_username|capitalize }}&quot; # TO BE FILLED: If your users have names in Authentik and you want those in Synapse, this should be replaced with user.name|capitalize.
</code></pre> </code></pre>
<h3 id="lemonldap"><a class="header" href="#lemonldap">LemonLDAP</a></h3> <h3 id="dex"><a class="header" href="#dex">Dex</a></h3>
<p><a href="https://lemonldap-ng.org/">LemonLDAP::NG</a> is an open-source IdP solution.</p> <p><a href="https://github.com/dexidp/dex">Dex</a> is a simple, open-source OpenID Connect Provider.
<ol> Although it is designed to help building a full-blown provider with an
<li>Create an OpenID Connect Relying Parties in LemonLDAP::NG</li> external database, it can be configured with static passwords in a config file.</p>
<li>The parameters are:</li> <p>Follow the <a href="https://dexidp.io/docs/getting-started/">Getting Started guide</a>
</ol> to install Dex.</p>
<ul> <p>Edit <code>examples/config-dev.yaml</code> config file from the Dex repo to add a client:</p>
<li>Client ID under the basic menu of the new Relying Parties (<code>Options &gt; Basic &gt; Client ID</code>)</li> <pre><code class="language-yaml">staticClients:
<li>Client secret (<code>Options &gt; Basic &gt; Client secret</code>)</li> - id: synapse
<li>JWT Algorithm: RS256 within the security menu of the new Relying Parties secret: secret
(<code>Options &gt; Security &gt; ID Token signature algorithm</code> and <code>Options &gt; Security &gt; Access Token signature algorithm</code>)</li> redirectURIs:
<li>Scopes: OpenID, Email and Profile</li> - '[synapse public baseurl]/_synapse/client/oidc/callback'
<li>Allowed redirection addresses for login (<code>Options &gt; Basic &gt; Allowed redirection addresses for login</code> ) : name: 'Synapse'
<code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li> </code></pre>
</ul> <p>Run with <code>dex serve examples/config-dev.yaml</code>.</p>
<p>Synapse config:</p> <p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers: <pre><code class="language-yaml">oidc_providers:
- idp_id: lemonldap - idp_id: dex
idp_name: lemonldap idp_name: &quot;My Dex server&quot;
discover: true skip_verification: true # This is needed as Dex is served on an insecure endpoint
issuer: &quot;https://auth.example.org/&quot; # TO BE FILLED: replace with your domain issuer: &quot;http://127.0.0.1:5556/dex&quot;
client_id: &quot;your client id&quot; # TO BE FILLED client_id: &quot;synapse&quot;
client_secret: &quot;your client secret&quot; # TO BE FILLED client_secret: &quot;secret&quot;
scopes:
- &quot;openid&quot;
- &quot;profile&quot;
- &quot;email&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}}&quot;
# TO BE FILLED: If your users have names in LemonLDAP::NG and you want those in Synapse, this should be replaced with user.name|capitalize or any valid filter.
display_name_template: &quot;{{ user.preferred_username|capitalize }}&quot;
</code></pre>
<h3 id="github"><a class="header" href="#github">GitHub</a></h3>
<p><a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps">GitHub</a> is a bit special as it is not an OpenID Connect compliant provider, but
just a regular OAuth2 provider.</p>
<p>The <a href="https://developer.github.com/v3/users/#get-the-authenticated-user"><code>/user</code> API endpoint</a>
can be used to retrieve information on the authenticated user. As the Synapse
login mechanism needs an attribute to uniquely identify users, and that endpoint
does not return a <code>sub</code> property, an alternative <code>subject_claim</code> has to be set.</p>
<ol>
<li>Create a new OAuth application: <a href="https://github.com/settings/applications/new">https://github.com/settings/applications/new</a>.</li>
<li>Set the callback URL to <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: github
idp_name: Github
idp_brand: &quot;github&quot; # optional: styling hint for clients
discover: false
issuer: &quot;https://github.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
authorization_endpoint: &quot;https://github.com/login/oauth/authorize&quot;
token_endpoint: &quot;https://github.com/login/oauth/access_token&quot;
userinfo_endpoint: &quot;https://api.github.com/user&quot;
scopes: [&quot;read:user&quot;]
user_mapping_provider:
config:
subject_claim: &quot;id&quot;
localpart_template: &quot;{{ user.login }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<h3 id="google"><a class="header" href="#google">Google</a></h3>
<p><a href="https://developers.google.com/identity/protocols/oauth2/openid-connect">Google</a> is an OpenID certified authentication and authorisation provider.</p>
<ol>
<li>Set up a project in the Google API Console (see
<a href="https://developers.google.com/identity/protocols/oauth2/openid-connect#appsetup">documentation</a>).</li>
<li>Add an &quot;OAuth Client ID&quot; for a Web Application under &quot;Credentials&quot;.</li>
<li>Copy the Client ID and Client Secret, and add the following to your synapse config:
<pre><code class="language-yaml">oidc_providers:
- idp_id: google
idp_name: Google
idp_brand: &quot;google&quot; # optional: styling hint for clients
issuer: &quot;https://accounts.google.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
scopes: [&quot;openid&quot;, &quot;profile&quot;, &quot;email&quot;] # email is optional, read below
user_mapping_provider:
config:
localpart_template: &quot;{{ user.given_name|lower }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
email_template: &quot;{{ user.email }}&quot; # needs &quot;email&quot; in scopes above
</code></pre>
</li>
<li>Back in the Google console, add this Authorized redirect URI: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
</ol>
<h3 id="twitch"><a class="header" href="#twitch">Twitch</a></h3>
<ol>
<li>Setup a developer account on <a href="https://dev.twitch.tv/">Twitch</a></li>
<li>Obtain the OAuth 2.0 credentials by <a href="https://dev.twitch.tv/console/apps/">creating an app</a></li>
<li>Add this OAuth Redirect URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: twitch
idp_name: Twitch
issuer: &quot;https://id.twitch.tv/oauth2/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: &quot;client_secret_post&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<h3 id="gitlab"><a class="header" href="#gitlab">GitLab</a></h3>
<ol>
<li>Create a <a href="https://gitlab.com/profile/applications">new application</a>.</li>
<li>Add the <code>read_user</code> and <code>openid</code> scopes.</li>
<li>Add this Callback URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: gitlab
idp_name: Gitlab
idp_brand: &quot;gitlab&quot; # optional: styling hint for clients
issuer: &quot;https://gitlab.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: &quot;client_secret_post&quot;
scopes: [&quot;openid&quot;, &quot;read_user&quot;]
user_profile_method: &quot;userinfo_endpoint&quot;
user_mapping_provider:
config:
localpart_template: '{{ user.nickname }}'
display_name_template: '{{ user.name }}'
</code></pre>
<h3 id="facebook"><a class="header" href="#facebook">Facebook</a></h3>
<ol start="0">
<li>You will need a Facebook developer account. You can register for one
<a href="https://developers.facebook.com/async/registration/">here</a>.</li>
<li>On the <a href="https://developers.facebook.com/apps/">apps</a> page of the developer
console, &quot;Create App&quot;, and choose &quot;Build Connected Experiences&quot;.</li>
<li>Once the app is created, add &quot;Facebook Login&quot; and choose &quot;Web&quot;. You don't
need to go through the whole form here.</li>
<li>In the left-hand menu, open &quot;Products&quot;/&quot;Facebook Login&quot;/&quot;Settings&quot;.
<ul>
<li>Add <code>[synapse public baseurl]/_synapse/client/oidc/callback</code> as an OAuth Redirect
URL.</li>
</ul>
</li>
<li>In the left-hand menu, open &quot;Settings/Basic&quot;. Here you can copy the &quot;App ID&quot;
and &quot;App Secret&quot; for use below.</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml"> - idp_id: facebook
idp_name: Facebook
idp_brand: &quot;facebook&quot; # optional: styling hint for clients
discover: false
issuer: &quot;https://www.facebook.com&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
scopes: [&quot;openid&quot;, &quot;email&quot;]
authorization_endpoint: &quot;https://facebook.com/dialog/oauth&quot;
token_endpoint: &quot;https://graph.facebook.com/v9.0/oauth/access_token&quot;
jwks_uri: &quot;https://www.facebook.com/.well-known/oauth/openid/jwks/&quot;
user_mapping_provider:
config:
display_name_template: &quot;{{ user.name }}&quot;
email_template: &quot;{{ user.email }}&quot;
</code></pre>
<p>Relevant documents:</p>
<ul>
<li><a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow">Manually Build a Login Flow</a></li>
<li><a href="https://developers.facebook.com/docs/graph-api/using-graph-api/">Using Facebook's Graph API</a></li>
<li><a href="https://developers.facebook.com/docs/graph-api/reference/user">Reference to the User endpoint</a></li>
</ul>
<p>Facebook do have an <a href="https://www.facebook.com/.well-known/openid-configuration">OIDC discovery endpoint</a>,
but it has a <code>response_types_supported</code> which excludes &quot;code&quot; (which we rely on, and
is even mentioned in their <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login">documentation</a>),
so we have to disable discovery and configure the URIs manually.</p>
<h3 id="gitea"><a class="header" href="#gitea">Gitea</a></h3>
<p>Gitea is, like Github, not an OpenID provider, but just an OAuth2 provider.</p>
<p>The <a href="https://try.gitea.io/api/swagger#/user/userGetCurrent"><code>/user</code> API endpoint</a>
can be used to retrieve information on the authenticated user. As the Synapse
login mechanism needs an attribute to uniquely identify users, and that endpoint
does not return a <code>sub</code> property, an alternative <code>subject_claim</code> has to be set.</p>
<ol>
<li>Create a new application.</li>
<li>Add this Callback URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: gitea
idp_name: Gitea
discover: false
issuer: &quot;https://your-gitea.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: client_secret_post
scopes: [] # Gitea doesn't support Scopes
authorization_endpoint: &quot;https://your-gitea.com/login/oauth/authorize&quot;
token_endpoint: &quot;https://your-gitea.com/login/oauth/access_token&quot;
userinfo_endpoint: &quot;https://your-gitea.com/api/v1/user&quot;
user_mapping_provider:
config:
subject_claim: &quot;id&quot;
localpart_template: &quot;{{ user.login }}&quot;
display_name_template: &quot;{{ user.full_name }}&quot;
</code></pre>
<h3 id="xwiki"><a class="header" href="#xwiki">XWiki</a></h3>
<p>Install <a href="https://extensions.xwiki.org/xwiki/bin/view/Extension/OpenID%20Connect/OpenID%20Connect%20Provider/">OpenID Connect Provider</a> extension in your <a href="https://www.xwiki.org">XWiki</a> instance.</p>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: xwiki
idp_name: &quot;XWiki&quot;
issuer: &quot;https://myxwikihost/xwiki/oidc/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_auth_method: none
scopes: [&quot;openid&quot;, &quot;profile&quot;] scopes: [&quot;openid&quot;, &quot;profile&quot;]
user_profile_method: &quot;userinfo_endpoint&quot;
user_mapping_provider: user_mapping_provider:
config: config:
localpart_template: &quot;{{ user.preferred_username }}&quot; localpart_template: &quot;{{ user.name }}&quot;
display_name_template: &quot;{{ user.name }}&quot; display_name_template: &quot;{{ user.name|capitalize }}&quot;
</code></pre>
<h3 id="apple"><a class="header" href="#apple">Apple</a></h3>
<p>Configuring &quot;Sign in with Apple&quot; (SiWA) requires an Apple Developer account.</p>
<p>You will need to create a new &quot;Services ID&quot; for SiWA, and create and download a
private key with &quot;SiWA&quot; enabled.</p>
<p>As well as the private key file, you will need:</p>
<ul>
<li>Client ID: the &quot;identifier&quot; you gave the &quot;Services ID&quot;</li>
<li>Team ID: a 10-character ID associated with your developer account.</li>
<li>Key ID: the 10-character identifier for the key.</li>
</ul>
<p><a href="https://help.apple.com/developer-account/?lang=en#/dev77c875b7e">Apple's developer documentation</a>
has more information on setting up SiWA.</p>
<p>The synapse config will look like this:</p>
<pre><code class="language-yaml"> - idp_id: apple
idp_name: Apple
issuer: &quot;https://appleid.apple.com&quot;
client_id: &quot;your-client-id&quot; # Set to the &quot;identifier&quot; for your &quot;ServicesID&quot;
client_auth_method: &quot;client_secret_post&quot;
client_secret_jwt_key:
key_file: &quot;/path/to/AuthKey_KEYIDCODE.p8&quot; # point to your key file
jwt_header:
alg: ES256
kid: &quot;KEYIDCODE&quot; # Set to the 10-char Key ID
jwt_payload:
iss: TEAMIDCODE # Set to the 10-char Team ID
scopes: [&quot;name&quot;, &quot;email&quot;, &quot;openid&quot;]
authorization_endpoint: https://appleid.apple.com/auth/authorize?response_mode=form_post
user_mapping_provider:
config:
email_template: &quot;{{ user.email }}&quot;
</code></pre> </code></pre>
<h3 id="django-oauth-toolkit"><a class="header" href="#django-oauth-toolkit">Django OAuth Toolkit</a></h3> <h3 id="django-oauth-toolkit"><a class="header" href="#django-oauth-toolkit">Django OAuth Toolkit</a></h3>
<p><a href="https://github.com/jazzband/django-oauth-toolkit">django-oauth-toolkit</a> is a <p><a href="https://github.com/jazzband/django-oauth-toolkit">django-oauth-toolkit</a> is a
@ -676,6 +405,242 @@ needed to add OAuth2 capabilities to your Django projects. It supports
display_name_template: &quot;{{ user.first_name }} {{ user.last_name }}&quot; display_name_template: &quot;{{ user.first_name }} {{ user.last_name }}&quot;
email_template: &quot;{{ user.email }}&quot; email_template: &quot;{{ user.email }}&quot;
</code></pre> </code></pre>
<h3 id="facebook"><a class="header" href="#facebook">Facebook</a></h3>
<ol start="0">
<li>You will need a Facebook developer account. You can register for one
<a href="https://developers.facebook.com/async/registration/">here</a>.</li>
<li>On the <a href="https://developers.facebook.com/apps/">apps</a> page of the developer
console, &quot;Create App&quot;, and choose &quot;Build Connected Experiences&quot;.</li>
<li>Once the app is created, add &quot;Facebook Login&quot; and choose &quot;Web&quot;. You don't
need to go through the whole form here.</li>
<li>In the left-hand menu, open &quot;Products&quot;/&quot;Facebook Login&quot;/&quot;Settings&quot;.
<ul>
<li>Add <code>[synapse public baseurl]/_synapse/client/oidc/callback</code> as an OAuth Redirect
URL.</li>
</ul>
</li>
<li>In the left-hand menu, open &quot;Settings/Basic&quot;. Here you can copy the &quot;App ID&quot;
and &quot;App Secret&quot; for use below.</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml"> - idp_id: facebook
idp_name: Facebook
idp_brand: &quot;facebook&quot; # optional: styling hint for clients
discover: false
issuer: &quot;https://www.facebook.com&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
scopes: [&quot;openid&quot;, &quot;email&quot;]
authorization_endpoint: &quot;https://facebook.com/dialog/oauth&quot;
token_endpoint: &quot;https://graph.facebook.com/v9.0/oauth/access_token&quot;
jwks_uri: &quot;https://www.facebook.com/.well-known/oauth/openid/jwks/&quot;
user_mapping_provider:
config:
display_name_template: &quot;{{ user.name }}&quot;
email_template: &quot;{{ user.email }}&quot;
</code></pre>
<p>Relevant documents:</p>
<ul>
<li><a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow">Manually Build a Login Flow</a></li>
<li><a href="https://developers.facebook.com/docs/graph-api/using-graph-api/">Using Facebook's Graph API</a></li>
<li><a href="https://developers.facebook.com/docs/graph-api/reference/user">Reference to the User endpoint</a></li>
</ul>
<p>Facebook do have an <a href="https://www.facebook.com/.well-known/openid-configuration">OIDC discovery endpoint</a>,
but it has a <code>response_types_supported</code> which excludes &quot;code&quot; (which we rely on, and
is even mentioned in their <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login">documentation</a>),
so we have to disable discovery and configure the URIs manually.</p>
<h3 id="github"><a class="header" href="#github">GitHub</a></h3>
<p><a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps">GitHub</a> is a bit special as it is not an OpenID Connect compliant provider, but
just a regular OAuth2 provider.</p>
<p>The <a href="https://developer.github.com/v3/users/#get-the-authenticated-user"><code>/user</code> API endpoint</a>
can be used to retrieve information on the authenticated user. As the Synapse
login mechanism needs an attribute to uniquely identify users, and that endpoint
does not return a <code>sub</code> property, an alternative <code>subject_claim</code> has to be set.</p>
<ol>
<li>Create a new OAuth application: <a href="https://github.com/settings/applications/new">https://github.com/settings/applications/new</a>.</li>
<li>Set the callback URL to <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: github
idp_name: Github
idp_brand: &quot;github&quot; # optional: styling hint for clients
discover: false
issuer: &quot;https://github.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
authorization_endpoint: &quot;https://github.com/login/oauth/authorize&quot;
token_endpoint: &quot;https://github.com/login/oauth/access_token&quot;
userinfo_endpoint: &quot;https://api.github.com/user&quot;
scopes: [&quot;read:user&quot;]
user_mapping_provider:
config:
subject_claim: &quot;id&quot;
localpart_template: &quot;{{ user.login }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<h3 id="gitlab"><a class="header" href="#gitlab">GitLab</a></h3>
<ol>
<li>Create a <a href="https://gitlab.com/profile/applications">new application</a>.</li>
<li>Add the <code>read_user</code> and <code>openid</code> scopes.</li>
<li>Add this Callback URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: gitlab
idp_name: Gitlab
idp_brand: &quot;gitlab&quot; # optional: styling hint for clients
issuer: &quot;https://gitlab.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: &quot;client_secret_post&quot;
scopes: [&quot;openid&quot;, &quot;read_user&quot;]
user_profile_method: &quot;userinfo_endpoint&quot;
user_mapping_provider:
config:
localpart_template: '{{ user.nickname }}'
display_name_template: '{{ user.name }}'
</code></pre>
<h3 id="gitea"><a class="header" href="#gitea">Gitea</a></h3>
<p>Gitea is, like Github, not an OpenID provider, but just an OAuth2 provider.</p>
<p>The <a href="https://try.gitea.io/api/swagger#/user/userGetCurrent"><code>/user</code> API endpoint</a>
can be used to retrieve information on the authenticated user. As the Synapse
login mechanism needs an attribute to uniquely identify users, and that endpoint
does not return a <code>sub</code> property, an alternative <code>subject_claim</code> has to be set.</p>
<ol>
<li>Create a new application.</li>
<li>Add this Callback URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: gitea
idp_name: Gitea
discover: false
issuer: &quot;https://your-gitea.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: client_secret_post
scopes: [] # Gitea doesn't support Scopes
authorization_endpoint: &quot;https://your-gitea.com/login/oauth/authorize&quot;
token_endpoint: &quot;https://your-gitea.com/login/oauth/access_token&quot;
userinfo_endpoint: &quot;https://your-gitea.com/api/v1/user&quot;
user_mapping_provider:
config:
subject_claim: &quot;id&quot;
localpart_template: &quot;{{ user.login }}&quot;
display_name_template: &quot;{{ user.full_name }}&quot;
</code></pre>
<h3 id="google"><a class="header" href="#google">Google</a></h3>
<p><a href="https://developers.google.com/identity/protocols/oauth2/openid-connect">Google</a> is an OpenID certified authentication and authorisation provider.</p>
<ol>
<li>Set up a project in the Google API Console (see
<a href="https://developers.google.com/identity/protocols/oauth2/openid-connect#appsetup">documentation</a>).</li>
<li>Add an &quot;OAuth Client ID&quot; for a Web Application under &quot;Credentials&quot;.</li>
<li>Copy the Client ID and Client Secret, and add the following to your synapse config:
<pre><code class="language-yaml">oidc_providers:
- idp_id: google
idp_name: Google
idp_brand: &quot;google&quot; # optional: styling hint for clients
issuer: &quot;https://accounts.google.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
scopes: [&quot;openid&quot;, &quot;profile&quot;, &quot;email&quot;] # email is optional, read below
user_mapping_provider:
config:
localpart_template: &quot;{{ user.given_name|lower }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
email_template: &quot;{{ user.email }}&quot; # needs &quot;email&quot; in scopes above
</code></pre>
</li>
<li>Back in the Google console, add this Authorized redirect URI: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
</ol>
<h3 id="keycloak"><a class="header" href="#keycloak">Keycloak</a></h3>
<p><a href="https://www.keycloak.org/docs/latest/server_admin/#sso-protocols">Keycloak</a> is an opensource IdP maintained by Red Hat.</p>
<p>Keycloak supports OIDC Back-Channel Logout, which sends logout notification to Synapse, so that Synapse users get logged out when they log out from Keycloak.
This can be optionally enabled by setting <code>backchannel_logout_enabled</code> to <code>true</code> in the Synapse configuration, and by setting the &quot;Backchannel Logout URL&quot; in Keycloak.</p>
<p>Follow the <a href="https://www.keycloak.org/getting-started">Getting Started Guide</a> to install Keycloak and set up a realm.</p>
<ol>
<li>
<p>Click <code>Clients</code> in the sidebar and click <code>Create</code></p>
</li>
<li>
<p>Fill in the fields as below:</p>
</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client ID</td><td><code>synapse</code></td></tr>
<tr><td>Client Protocol</td><td><code>openid-connect</code></td></tr>
</tbody></table>
<ol start="3">
<li>Click <code>Save</code></li>
<li>Fill in the fields as below:</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client ID</td><td><code>synapse</code></td></tr>
<tr><td>Enabled</td><td><code>On</code></td></tr>
<tr><td>Client Protocol</td><td><code>openid-connect</code></td></tr>
<tr><td>Access Type</td><td><code>confidential</code></td></tr>
<tr><td>Valid Redirect URIs</td><td><code>[synapse public baseurl]/_synapse/client/oidc/callback</code></td></tr>
<tr><td>Backchannel Logout URL (optional)</td><td> <code>[synapse public baseurl]/_synapse/client/oidc/backchannel_logout</code></td></tr>
<tr><td>Backchannel Logout Session Required (optional)</td><td> <code>On</code></td></tr>
</tbody></table>
<ol start="5">
<li>Click <code>Save</code></li>
<li>On the Credentials tab, update the fields:</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client Authenticator</td><td><code>Client ID and Secret</code></td></tr>
</tbody></table>
<ol start="7">
<li>Click <code>Regenerate Secret</code></li>
<li>Copy Secret</li>
</ol>
<pre><code class="language-yaml">oidc_providers:
- idp_id: keycloak
idp_name: &quot;My KeyCloak server&quot;
issuer: &quot;https://127.0.0.1:8443/realms/{realm_name}&quot;
client_id: &quot;synapse&quot;
client_secret: &quot;copy secret generated from above&quot;
scopes: [&quot;openid&quot;, &quot;profile&quot;]
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
backchannel_logout_enabled: true # Optional
</code></pre>
<h3 id="lemonldap"><a class="header" href="#lemonldap">LemonLDAP</a></h3>
<p><a href="https://lemonldap-ng.org/">LemonLDAP::NG</a> is an open-source IdP solution.</p>
<ol>
<li>Create an OpenID Connect Relying Parties in LemonLDAP::NG</li>
<li>The parameters are:</li>
</ol>
<ul>
<li>Client ID under the basic menu of the new Relying Parties (<code>Options &gt; Basic &gt; Client ID</code>)</li>
<li>Client secret (<code>Options &gt; Basic &gt; Client secret</code>)</li>
<li>JWT Algorithm: RS256 within the security menu of the new Relying Parties
(<code>Options &gt; Security &gt; ID Token signature algorithm</code> and <code>Options &gt; Security &gt; Access Token signature algorithm</code>)</li>
<li>Scopes: OpenID, Email and Profile</li>
<li>Allowed redirection addresses for login (<code>Options &gt; Basic &gt; Allowed redirection addresses for login</code> ) :
<code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ul>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: lemonldap
idp_name: lemonldap
discover: true
issuer: &quot;https://auth.example.org/&quot; # TO BE FILLED: replace with your domain
client_id: &quot;your client id&quot; # TO BE FILLED
client_secret: &quot;your client secret&quot; # TO BE FILLED
scopes:
- &quot;openid&quot;
- &quot;profile&quot;
- &quot;email&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}}&quot;
# TO BE FILLED: If your users have names in LemonLDAP::NG and you want those in Synapse, this should be replaced with user.name|capitalize or any valid filter.
display_name_template: &quot;{{ user.preferred_username|capitalize }}&quot;
</code></pre>
<h3 id="mastodon"><a class="header" href="#mastodon">Mastodon</a></h3> <h3 id="mastodon"><a class="header" href="#mastodon">Mastodon</a></h3>
<p><a href="https://docs.joinmastodon.org/">Mastodon</a> instances provide an <a href="https://docs.joinmastodon.org/spec/oauth/">OAuth API</a>, allowing those instances to be used as a single sign-on provider for Synapse.</p> <p><a href="https://docs.joinmastodon.org/">Mastodon</a> instances provide an <a href="https://docs.joinmastodon.org/spec/oauth/">OAuth API</a>, allowing those instances to be used as a single sign-on provider for Synapse.</p>
<p>The first step is to register Synapse as an application with your Mastodon instance, using the <a href="https://docs.joinmastodon.org/methods/apps/#create">Create an application API</a> (see also <a href="https://docs.joinmastodon.org/client/token/">here</a>). There are several ways to do this, but in the example below we are using CURL.</p> <p>The first step is to register Synapse as an application with your Mastodon instance, using the <a href="https://docs.joinmastodon.org/methods/apps/#create">Create an application API</a> (see also <a href="https://docs.joinmastodon.org/client/token/">here</a>). There are several ways to do this, but in the example below we are using CURL.</p>
@ -707,6 +672,72 @@ needed to add OAuth2 capabilities to your Django projects. It supports
subject_claim: &quot;id&quot; subject_claim: &quot;id&quot;
</code></pre> </code></pre>
<p>Note that the fields <code>client_id</code> and <code>client_secret</code> are taken from the CURL response above.</p> <p>Note that the fields <code>client_id</code> and <code>client_secret</code> are taken from the CURL response above.</p>
<h3 id="twitch"><a class="header" href="#twitch">Twitch</a></h3>
<ol>
<li>Setup a developer account on <a href="https://dev.twitch.tv/">Twitch</a></li>
<li>Obtain the OAuth 2.0 credentials by <a href="https://dev.twitch.tv/console/apps/">creating an app</a></li>
<li>Add this OAuth Redirect URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: twitch
idp_name: Twitch
issuer: &quot;https://id.twitch.tv/oauth2/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: &quot;client_secret_post&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<h3 id="twitter"><a class="header" href="#twitter">Twitter</a></h3>
<p><em>Using Twitter as an identity provider requires using Synapse 1.75.0 or later.</em></p>
<ol>
<li>Setup a developer account on <a href="https://developer.twitter.com/en/portal/dashboard">Twitter</a></li>
<li>Create a project &amp; app.</li>
<li>Enable user authentication and under &quot;Type of App&quot; choose &quot;Web App, Automated App or Bot&quot;.</li>
<li>Under &quot;App info&quot; set the callback URL to <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
<li>Obtain the OAuth 2.0 credentials under the &quot;Keys and tokens&quot; tab, copy the &quot;OAuth 2.0 Client ID and Client Secret&quot;</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: twitter
idp_name: Twitter
idp_brand: &quot;twitter&quot; # optional: styling hint for clients
discover: false # Twitter is not OpenID compliant.
issuer: &quot;https://twitter.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
pkce_method: &quot;always&quot;
# offline.access providers refresh tokens, tweet.read and users.read needed for userinfo request.
scopes: [&quot;offline.access&quot;, &quot;tweet.read&quot;, &quot;users.read&quot;]
authorization_endpoint: https://twitter.com/i/oauth2/authorize
token_endpoint: https://api.twitter.com/2/oauth2/token
userinfo_endpoint: https://api.twitter.com/2/users/me?user.fields=profile_image_url
user_mapping_provider:
config:
subject_template: &quot;{{ user.data.id }}&quot;
localpart_template: &quot;{{ user.data.username }}&quot;
display_name_template: &quot;{{ user.data.name }}&quot;
picture_template: &quot;{{ user.data.profile_image_url }}&quot;
</code></pre>
<h3 id="xwiki"><a class="header" href="#xwiki">XWiki</a></h3>
<p>Install <a href="https://extensions.xwiki.org/xwiki/bin/view/Extension/OpenID%20Connect/OpenID%20Connect%20Provider/">OpenID Connect Provider</a> extension in your <a href="https://www.xwiki.org">XWiki</a> instance.</p>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: xwiki
idp_name: &quot;XWiki&quot;
issuer: &quot;https://myxwikihost/xwiki/oidc/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_auth_method: none
scopes: [&quot;openid&quot;, &quot;profile&quot;]
user_profile_method: &quot;userinfo_endpoint&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
</main> </main>

View File

@ -7515,88 +7515,36 @@ Edit your Synapse config file and change the <code>oidc_config</code> section:</
localpart_template: &quot;{{ user.preferred_username.split('@')[0] }}&quot; localpart_template: &quot;{{ user.preferred_username.split('@')[0] }}&quot;
display_name_template: &quot;{{ user.name }}&quot; display_name_template: &quot;{{ user.name }}&quot;
</code></pre> </code></pre>
<h3 id="dex"><a class="header" href="#dex">Dex</a></h3> <h3 id="apple"><a class="header" href="#apple">Apple</a></h3>
<p><a href="https://github.com/dexidp/dex">Dex</a> is a simple, open-source OpenID Connect Provider. <p>Configuring &quot;Sign in with Apple&quot; (SiWA) requires an Apple Developer account.</p>
Although it is designed to help building a full-blown provider with an <p>You will need to create a new &quot;Services ID&quot; for SiWA, and create and download a
external database, it can be configured with static passwords in a config file.</p> private key with &quot;SiWA&quot; enabled.</p>
<p>Follow the <a href="https://dexidp.io/docs/getting-started/">Getting Started guide</a> <p>As well as the private key file, you will need:</p>
to install Dex.</p> <ul>
<p>Edit <code>examples/config-dev.yaml</code> config file from the Dex repo to add a client:</p> <li>Client ID: the &quot;identifier&quot; you gave the &quot;Services ID&quot;</li>
<pre><code class="language-yaml">staticClients: <li>Team ID: a 10-character ID associated with your developer account.</li>
- id: synapse <li>Key ID: the 10-character identifier for the key.</li>
secret: secret </ul>
redirectURIs: <p><a href="https://help.apple.com/developer-account/?lang=en#/dev77c875b7e">Apple's developer documentation</a>
- '[synapse public baseurl]/_synapse/client/oidc/callback' has more information on setting up SiWA.</p>
name: 'Synapse' <p>The synapse config will look like this:</p>
</code></pre> <pre><code class="language-yaml"> - idp_id: apple
<p>Run with <code>dex serve examples/config-dev.yaml</code>.</p> idp_name: Apple
<p>Synapse config:</p> issuer: &quot;https://appleid.apple.com&quot;
<pre><code class="language-yaml">oidc_providers: client_id: &quot;your-client-id&quot; # Set to the &quot;identifier&quot; for your &quot;ServicesID&quot;
- idp_id: dex client_auth_method: &quot;client_secret_post&quot;
idp_name: &quot;My Dex server&quot; client_secret_jwt_key:
skip_verification: true # This is needed as Dex is served on an insecure endpoint key_file: &quot;/path/to/AuthKey_KEYIDCODE.p8&quot; # point to your key file
issuer: &quot;http://127.0.0.1:5556/dex&quot; jwt_header:
client_id: &quot;synapse&quot; alg: ES256
client_secret: &quot;secret&quot; kid: &quot;KEYIDCODE&quot; # Set to the 10-char Key ID
scopes: [&quot;openid&quot;, &quot;profile&quot;] jwt_payload:
iss: TEAMIDCODE # Set to the 10-char Team ID
scopes: [&quot;name&quot;, &quot;email&quot;, &quot;openid&quot;]
authorization_endpoint: https://appleid.apple.com/auth/authorize?response_mode=form_post
user_mapping_provider: user_mapping_provider:
config: config:
localpart_template: &quot;{{ user.name }}&quot; email_template: &quot;{{ user.email }}&quot;
display_name_template: &quot;{{ user.name|capitalize }}&quot;
</code></pre>
<h3 id="keycloak"><a class="header" href="#keycloak">Keycloak</a></h3>
<p><a href="https://www.keycloak.org/docs/latest/server_admin/#sso-protocols">Keycloak</a> is an opensource IdP maintained by Red Hat.</p>
<p>Keycloak supports OIDC Back-Channel Logout, which sends logout notification to Synapse, so that Synapse users get logged out when they log out from Keycloak.
This can be optionally enabled by setting <code>backchannel_logout_enabled</code> to <code>true</code> in the Synapse configuration, and by setting the &quot;Backchannel Logout URL&quot; in Keycloak.</p>
<p>Follow the <a href="https://www.keycloak.org/getting-started">Getting Started Guide</a> to install Keycloak and set up a realm.</p>
<ol>
<li>
<p>Click <code>Clients</code> in the sidebar and click <code>Create</code></p>
</li>
<li>
<p>Fill in the fields as below:</p>
</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client ID</td><td><code>synapse</code></td></tr>
<tr><td>Client Protocol</td><td><code>openid-connect</code></td></tr>
</tbody></table>
<ol start="3">
<li>Click <code>Save</code></li>
<li>Fill in the fields as below:</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client ID</td><td><code>synapse</code></td></tr>
<tr><td>Enabled</td><td><code>On</code></td></tr>
<tr><td>Client Protocol</td><td><code>openid-connect</code></td></tr>
<tr><td>Access Type</td><td><code>confidential</code></td></tr>
<tr><td>Valid Redirect URIs</td><td><code>[synapse public baseurl]/_synapse/client/oidc/callback</code></td></tr>
<tr><td>Backchannel Logout URL (optional)</td><td> <code>[synapse public baseurl]/_synapse/client/oidc/backchannel_logout</code></td></tr>
<tr><td>Backchannel Logout Session Required (optional)</td><td> <code>On</code></td></tr>
</tbody></table>
<ol start="5">
<li>Click <code>Save</code></li>
<li>On the Credentials tab, update the fields:</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client Authenticator</td><td><code>Client ID and Secret</code></td></tr>
</tbody></table>
<ol start="7">
<li>Click <code>Regenerate Secret</code></li>
<li>Copy Secret</li>
</ol>
<pre><code class="language-yaml">oidc_providers:
- idp_id: keycloak
idp_name: &quot;My KeyCloak server&quot;
issuer: &quot;https://127.0.0.1:8443/realms/{realm_name}&quot;
client_id: &quot;synapse&quot;
client_secret: &quot;copy secret generated from above&quot;
scopes: [&quot;openid&quot;, &quot;profile&quot;]
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
backchannel_logout_enabled: true # Optional
</code></pre> </code></pre>
<h3 id="auth0"><a class="header" href="#auth0">Auth0</a></h3> <h3 id="auth0"><a class="header" href="#auth0">Auth0</a></h3>
<p><a href="https://auth0.com/">Auth0</a> is a hosted SaaS IdP solution.</p> <p><a href="https://auth0.com/">Auth0</a> is a hosted SaaS IdP solution.</p>
@ -7677,253 +7625,34 @@ This can be optionally enabled by setting <code>backchannel_logout_enabled</code
localpart_template: &quot;{{ user.preferred_username }}&quot; localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.preferred_username|capitalize }}&quot; # TO BE FILLED: If your users have names in Authentik and you want those in Synapse, this should be replaced with user.name|capitalize. display_name_template: &quot;{{ user.preferred_username|capitalize }}&quot; # TO BE FILLED: If your users have names in Authentik and you want those in Synapse, this should be replaced with user.name|capitalize.
</code></pre> </code></pre>
<h3 id="lemonldap"><a class="header" href="#lemonldap">LemonLDAP</a></h3> <h3 id="dex"><a class="header" href="#dex">Dex</a></h3>
<p><a href="https://lemonldap-ng.org/">LemonLDAP::NG</a> is an open-source IdP solution.</p> <p><a href="https://github.com/dexidp/dex">Dex</a> is a simple, open-source OpenID Connect Provider.
<ol> Although it is designed to help building a full-blown provider with an
<li>Create an OpenID Connect Relying Parties in LemonLDAP::NG</li> external database, it can be configured with static passwords in a config file.</p>
<li>The parameters are:</li> <p>Follow the <a href="https://dexidp.io/docs/getting-started/">Getting Started guide</a>
</ol> to install Dex.</p>
<ul> <p>Edit <code>examples/config-dev.yaml</code> config file from the Dex repo to add a client:</p>
<li>Client ID under the basic menu of the new Relying Parties (<code>Options &gt; Basic &gt; Client ID</code>)</li> <pre><code class="language-yaml">staticClients:
<li>Client secret (<code>Options &gt; Basic &gt; Client secret</code>)</li> - id: synapse
<li>JWT Algorithm: RS256 within the security menu of the new Relying Parties secret: secret
(<code>Options &gt; Security &gt; ID Token signature algorithm</code> and <code>Options &gt; Security &gt; Access Token signature algorithm</code>)</li> redirectURIs:
<li>Scopes: OpenID, Email and Profile</li> - '[synapse public baseurl]/_synapse/client/oidc/callback'
<li>Allowed redirection addresses for login (<code>Options &gt; Basic &gt; Allowed redirection addresses for login</code> ) : name: 'Synapse'
<code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li> </code></pre>
</ul> <p>Run with <code>dex serve examples/config-dev.yaml</code>.</p>
<p>Synapse config:</p> <p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers: <pre><code class="language-yaml">oidc_providers:
- idp_id: lemonldap - idp_id: dex
idp_name: lemonldap idp_name: &quot;My Dex server&quot;
discover: true skip_verification: true # This is needed as Dex is served on an insecure endpoint
issuer: &quot;https://auth.example.org/&quot; # TO BE FILLED: replace with your domain issuer: &quot;http://127.0.0.1:5556/dex&quot;
client_id: &quot;your client id&quot; # TO BE FILLED client_id: &quot;synapse&quot;
client_secret: &quot;your client secret&quot; # TO BE FILLED client_secret: &quot;secret&quot;
scopes:
- &quot;openid&quot;
- &quot;profile&quot;
- &quot;email&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}}&quot;
# TO BE FILLED: If your users have names in LemonLDAP::NG and you want those in Synapse, this should be replaced with user.name|capitalize or any valid filter.
display_name_template: &quot;{{ user.preferred_username|capitalize }}&quot;
</code></pre>
<h3 id="github"><a class="header" href="#github">GitHub</a></h3>
<p><a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps">GitHub</a> is a bit special as it is not an OpenID Connect compliant provider, but
just a regular OAuth2 provider.</p>
<p>The <a href="https://developer.github.com/v3/users/#get-the-authenticated-user"><code>/user</code> API endpoint</a>
can be used to retrieve information on the authenticated user. As the Synapse
login mechanism needs an attribute to uniquely identify users, and that endpoint
does not return a <code>sub</code> property, an alternative <code>subject_claim</code> has to be set.</p>
<ol>
<li>Create a new OAuth application: <a href="https://github.com/settings/applications/new">https://github.com/settings/applications/new</a>.</li>
<li>Set the callback URL to <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: github
idp_name: Github
idp_brand: &quot;github&quot; # optional: styling hint for clients
discover: false
issuer: &quot;https://github.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
authorization_endpoint: &quot;https://github.com/login/oauth/authorize&quot;
token_endpoint: &quot;https://github.com/login/oauth/access_token&quot;
userinfo_endpoint: &quot;https://api.github.com/user&quot;
scopes: [&quot;read:user&quot;]
user_mapping_provider:
config:
subject_claim: &quot;id&quot;
localpart_template: &quot;{{ user.login }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<h3 id="google"><a class="header" href="#google">Google</a></h3>
<p><a href="https://developers.google.com/identity/protocols/oauth2/openid-connect">Google</a> is an OpenID certified authentication and authorisation provider.</p>
<ol>
<li>Set up a project in the Google API Console (see
<a href="https://developers.google.com/identity/protocols/oauth2/openid-connect#appsetup">documentation</a>).</li>
<li>Add an &quot;OAuth Client ID&quot; for a Web Application under &quot;Credentials&quot;.</li>
<li>Copy the Client ID and Client Secret, and add the following to your synapse config:
<pre><code class="language-yaml">oidc_providers:
- idp_id: google
idp_name: Google
idp_brand: &quot;google&quot; # optional: styling hint for clients
issuer: &quot;https://accounts.google.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
scopes: [&quot;openid&quot;, &quot;profile&quot;, &quot;email&quot;] # email is optional, read below
user_mapping_provider:
config:
localpart_template: &quot;{{ user.given_name|lower }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
email_template: &quot;{{ user.email }}&quot; # needs &quot;email&quot; in scopes above
</code></pre>
</li>
<li>Back in the Google console, add this Authorized redirect URI: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
</ol>
<h3 id="twitch"><a class="header" href="#twitch">Twitch</a></h3>
<ol>
<li>Setup a developer account on <a href="https://dev.twitch.tv/">Twitch</a></li>
<li>Obtain the OAuth 2.0 credentials by <a href="https://dev.twitch.tv/console/apps/">creating an app</a></li>
<li>Add this OAuth Redirect URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: twitch
idp_name: Twitch
issuer: &quot;https://id.twitch.tv/oauth2/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: &quot;client_secret_post&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<h3 id="gitlab"><a class="header" href="#gitlab">GitLab</a></h3>
<ol>
<li>Create a <a href="https://gitlab.com/profile/applications">new application</a>.</li>
<li>Add the <code>read_user</code> and <code>openid</code> scopes.</li>
<li>Add this Callback URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: gitlab
idp_name: Gitlab
idp_brand: &quot;gitlab&quot; # optional: styling hint for clients
issuer: &quot;https://gitlab.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: &quot;client_secret_post&quot;
scopes: [&quot;openid&quot;, &quot;read_user&quot;]
user_profile_method: &quot;userinfo_endpoint&quot;
user_mapping_provider:
config:
localpart_template: '{{ user.nickname }}'
display_name_template: '{{ user.name }}'
</code></pre>
<h3 id="facebook"><a class="header" href="#facebook">Facebook</a></h3>
<ol start="0">
<li>You will need a Facebook developer account. You can register for one
<a href="https://developers.facebook.com/async/registration/">here</a>.</li>
<li>On the <a href="https://developers.facebook.com/apps/">apps</a> page of the developer
console, &quot;Create App&quot;, and choose &quot;Build Connected Experiences&quot;.</li>
<li>Once the app is created, add &quot;Facebook Login&quot; and choose &quot;Web&quot;. You don't
need to go through the whole form here.</li>
<li>In the left-hand menu, open &quot;Products&quot;/&quot;Facebook Login&quot;/&quot;Settings&quot;.
<ul>
<li>Add <code>[synapse public baseurl]/_synapse/client/oidc/callback</code> as an OAuth Redirect
URL.</li>
</ul>
</li>
<li>In the left-hand menu, open &quot;Settings/Basic&quot;. Here you can copy the &quot;App ID&quot;
and &quot;App Secret&quot; for use below.</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml"> - idp_id: facebook
idp_name: Facebook
idp_brand: &quot;facebook&quot; # optional: styling hint for clients
discover: false
issuer: &quot;https://www.facebook.com&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
scopes: [&quot;openid&quot;, &quot;email&quot;]
authorization_endpoint: &quot;https://facebook.com/dialog/oauth&quot;
token_endpoint: &quot;https://graph.facebook.com/v9.0/oauth/access_token&quot;
jwks_uri: &quot;https://www.facebook.com/.well-known/oauth/openid/jwks/&quot;
user_mapping_provider:
config:
display_name_template: &quot;{{ user.name }}&quot;
email_template: &quot;{{ user.email }}&quot;
</code></pre>
<p>Relevant documents:</p>
<ul>
<li><a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow">Manually Build a Login Flow</a></li>
<li><a href="https://developers.facebook.com/docs/graph-api/using-graph-api/">Using Facebook's Graph API</a></li>
<li><a href="https://developers.facebook.com/docs/graph-api/reference/user">Reference to the User endpoint</a></li>
</ul>
<p>Facebook do have an <a href="https://www.facebook.com/.well-known/openid-configuration">OIDC discovery endpoint</a>,
but it has a <code>response_types_supported</code> which excludes &quot;code&quot; (which we rely on, and
is even mentioned in their <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login">documentation</a>),
so we have to disable discovery and configure the URIs manually.</p>
<h3 id="gitea"><a class="header" href="#gitea">Gitea</a></h3>
<p>Gitea is, like Github, not an OpenID provider, but just an OAuth2 provider.</p>
<p>The <a href="https://try.gitea.io/api/swagger#/user/userGetCurrent"><code>/user</code> API endpoint</a>
can be used to retrieve information on the authenticated user. As the Synapse
login mechanism needs an attribute to uniquely identify users, and that endpoint
does not return a <code>sub</code> property, an alternative <code>subject_claim</code> has to be set.</p>
<ol>
<li>Create a new application.</li>
<li>Add this Callback URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: gitea
idp_name: Gitea
discover: false
issuer: &quot;https://your-gitea.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: client_secret_post
scopes: [] # Gitea doesn't support Scopes
authorization_endpoint: &quot;https://your-gitea.com/login/oauth/authorize&quot;
token_endpoint: &quot;https://your-gitea.com/login/oauth/access_token&quot;
userinfo_endpoint: &quot;https://your-gitea.com/api/v1/user&quot;
user_mapping_provider:
config:
subject_claim: &quot;id&quot;
localpart_template: &quot;{{ user.login }}&quot;
display_name_template: &quot;{{ user.full_name }}&quot;
</code></pre>
<h3 id="xwiki"><a class="header" href="#xwiki">XWiki</a></h3>
<p>Install <a href="https://extensions.xwiki.org/xwiki/bin/view/Extension/OpenID%20Connect/OpenID%20Connect%20Provider/">OpenID Connect Provider</a> extension in your <a href="https://www.xwiki.org">XWiki</a> instance.</p>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: xwiki
idp_name: &quot;XWiki&quot;
issuer: &quot;https://myxwikihost/xwiki/oidc/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_auth_method: none
scopes: [&quot;openid&quot;, &quot;profile&quot;] scopes: [&quot;openid&quot;, &quot;profile&quot;]
user_profile_method: &quot;userinfo_endpoint&quot;
user_mapping_provider: user_mapping_provider:
config: config:
localpart_template: &quot;{{ user.preferred_username }}&quot; localpart_template: &quot;{{ user.name }}&quot;
display_name_template: &quot;{{ user.name }}&quot; display_name_template: &quot;{{ user.name|capitalize }}&quot;
</code></pre>
<h3 id="apple"><a class="header" href="#apple">Apple</a></h3>
<p>Configuring &quot;Sign in with Apple&quot; (SiWA) requires an Apple Developer account.</p>
<p>You will need to create a new &quot;Services ID&quot; for SiWA, and create and download a
private key with &quot;SiWA&quot; enabled.</p>
<p>As well as the private key file, you will need:</p>
<ul>
<li>Client ID: the &quot;identifier&quot; you gave the &quot;Services ID&quot;</li>
<li>Team ID: a 10-character ID associated with your developer account.</li>
<li>Key ID: the 10-character identifier for the key.</li>
</ul>
<p><a href="https://help.apple.com/developer-account/?lang=en#/dev77c875b7e">Apple's developer documentation</a>
has more information on setting up SiWA.</p>
<p>The synapse config will look like this:</p>
<pre><code class="language-yaml"> - idp_id: apple
idp_name: Apple
issuer: &quot;https://appleid.apple.com&quot;
client_id: &quot;your-client-id&quot; # Set to the &quot;identifier&quot; for your &quot;ServicesID&quot;
client_auth_method: &quot;client_secret_post&quot;
client_secret_jwt_key:
key_file: &quot;/path/to/AuthKey_KEYIDCODE.p8&quot; # point to your key file
jwt_header:
alg: ES256
kid: &quot;KEYIDCODE&quot; # Set to the 10-char Key ID
jwt_payload:
iss: TEAMIDCODE # Set to the 10-char Team ID
scopes: [&quot;name&quot;, &quot;email&quot;, &quot;openid&quot;]
authorization_endpoint: https://appleid.apple.com/auth/authorize?response_mode=form_post
user_mapping_provider:
config:
email_template: &quot;{{ user.email }}&quot;
</code></pre> </code></pre>
<h3 id="django-oauth-toolkit"><a class="header" href="#django-oauth-toolkit">Django OAuth Toolkit</a></h3> <h3 id="django-oauth-toolkit"><a class="header" href="#django-oauth-toolkit">Django OAuth Toolkit</a></h3>
<p><a href="https://github.com/jazzband/django-oauth-toolkit">django-oauth-toolkit</a> is a <p><a href="https://github.com/jazzband/django-oauth-toolkit">django-oauth-toolkit</a> is a
@ -7973,6 +7702,242 @@ needed to add OAuth2 capabilities to your Django projects. It supports
display_name_template: &quot;{{ user.first_name }} {{ user.last_name }}&quot; display_name_template: &quot;{{ user.first_name }} {{ user.last_name }}&quot;
email_template: &quot;{{ user.email }}&quot; email_template: &quot;{{ user.email }}&quot;
</code></pre> </code></pre>
<h3 id="facebook"><a class="header" href="#facebook">Facebook</a></h3>
<ol start="0">
<li>You will need a Facebook developer account. You can register for one
<a href="https://developers.facebook.com/async/registration/">here</a>.</li>
<li>On the <a href="https://developers.facebook.com/apps/">apps</a> page of the developer
console, &quot;Create App&quot;, and choose &quot;Build Connected Experiences&quot;.</li>
<li>Once the app is created, add &quot;Facebook Login&quot; and choose &quot;Web&quot;. You don't
need to go through the whole form here.</li>
<li>In the left-hand menu, open &quot;Products&quot;/&quot;Facebook Login&quot;/&quot;Settings&quot;.
<ul>
<li>Add <code>[synapse public baseurl]/_synapse/client/oidc/callback</code> as an OAuth Redirect
URL.</li>
</ul>
</li>
<li>In the left-hand menu, open &quot;Settings/Basic&quot;. Here you can copy the &quot;App ID&quot;
and &quot;App Secret&quot; for use below.</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml"> - idp_id: facebook
idp_name: Facebook
idp_brand: &quot;facebook&quot; # optional: styling hint for clients
discover: false
issuer: &quot;https://www.facebook.com&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
scopes: [&quot;openid&quot;, &quot;email&quot;]
authorization_endpoint: &quot;https://facebook.com/dialog/oauth&quot;
token_endpoint: &quot;https://graph.facebook.com/v9.0/oauth/access_token&quot;
jwks_uri: &quot;https://www.facebook.com/.well-known/oauth/openid/jwks/&quot;
user_mapping_provider:
config:
display_name_template: &quot;{{ user.name }}&quot;
email_template: &quot;{{ user.email }}&quot;
</code></pre>
<p>Relevant documents:</p>
<ul>
<li><a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow">Manually Build a Login Flow</a></li>
<li><a href="https://developers.facebook.com/docs/graph-api/using-graph-api/">Using Facebook's Graph API</a></li>
<li><a href="https://developers.facebook.com/docs/graph-api/reference/user">Reference to the User endpoint</a></li>
</ul>
<p>Facebook do have an <a href="https://www.facebook.com/.well-known/openid-configuration">OIDC discovery endpoint</a>,
but it has a <code>response_types_supported</code> which excludes &quot;code&quot; (which we rely on, and
is even mentioned in their <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login">documentation</a>),
so we have to disable discovery and configure the URIs manually.</p>
<h3 id="github"><a class="header" href="#github">GitHub</a></h3>
<p><a href="https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps">GitHub</a> is a bit special as it is not an OpenID Connect compliant provider, but
just a regular OAuth2 provider.</p>
<p>The <a href="https://developer.github.com/v3/users/#get-the-authenticated-user"><code>/user</code> API endpoint</a>
can be used to retrieve information on the authenticated user. As the Synapse
login mechanism needs an attribute to uniquely identify users, and that endpoint
does not return a <code>sub</code> property, an alternative <code>subject_claim</code> has to be set.</p>
<ol>
<li>Create a new OAuth application: <a href="https://github.com/settings/applications/new">https://github.com/settings/applications/new</a>.</li>
<li>Set the callback URL to <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: github
idp_name: Github
idp_brand: &quot;github&quot; # optional: styling hint for clients
discover: false
issuer: &quot;https://github.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
authorization_endpoint: &quot;https://github.com/login/oauth/authorize&quot;
token_endpoint: &quot;https://github.com/login/oauth/access_token&quot;
userinfo_endpoint: &quot;https://api.github.com/user&quot;
scopes: [&quot;read:user&quot;]
user_mapping_provider:
config:
subject_claim: &quot;id&quot;
localpart_template: &quot;{{ user.login }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<h3 id="gitlab"><a class="header" href="#gitlab">GitLab</a></h3>
<ol>
<li>Create a <a href="https://gitlab.com/profile/applications">new application</a>.</li>
<li>Add the <code>read_user</code> and <code>openid</code> scopes.</li>
<li>Add this Callback URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: gitlab
idp_name: Gitlab
idp_brand: &quot;gitlab&quot; # optional: styling hint for clients
issuer: &quot;https://gitlab.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: &quot;client_secret_post&quot;
scopes: [&quot;openid&quot;, &quot;read_user&quot;]
user_profile_method: &quot;userinfo_endpoint&quot;
user_mapping_provider:
config:
localpart_template: '{{ user.nickname }}'
display_name_template: '{{ user.name }}'
</code></pre>
<h3 id="gitea"><a class="header" href="#gitea">Gitea</a></h3>
<p>Gitea is, like Github, not an OpenID provider, but just an OAuth2 provider.</p>
<p>The <a href="https://try.gitea.io/api/swagger#/user/userGetCurrent"><code>/user</code> API endpoint</a>
can be used to retrieve information on the authenticated user. As the Synapse
login mechanism needs an attribute to uniquely identify users, and that endpoint
does not return a <code>sub</code> property, an alternative <code>subject_claim</code> has to be set.</p>
<ol>
<li>Create a new application.</li>
<li>Add this Callback URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: gitea
idp_name: Gitea
discover: false
issuer: &quot;https://your-gitea.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: client_secret_post
scopes: [] # Gitea doesn't support Scopes
authorization_endpoint: &quot;https://your-gitea.com/login/oauth/authorize&quot;
token_endpoint: &quot;https://your-gitea.com/login/oauth/access_token&quot;
userinfo_endpoint: &quot;https://your-gitea.com/api/v1/user&quot;
user_mapping_provider:
config:
subject_claim: &quot;id&quot;
localpart_template: &quot;{{ user.login }}&quot;
display_name_template: &quot;{{ user.full_name }}&quot;
</code></pre>
<h3 id="google"><a class="header" href="#google">Google</a></h3>
<p><a href="https://developers.google.com/identity/protocols/oauth2/openid-connect">Google</a> is an OpenID certified authentication and authorisation provider.</p>
<ol>
<li>Set up a project in the Google API Console (see
<a href="https://developers.google.com/identity/protocols/oauth2/openid-connect#appsetup">documentation</a>).</li>
<li>Add an &quot;OAuth Client ID&quot; for a Web Application under &quot;Credentials&quot;.</li>
<li>Copy the Client ID and Client Secret, and add the following to your synapse config:
<pre><code class="language-yaml">oidc_providers:
- idp_id: google
idp_name: Google
idp_brand: &quot;google&quot; # optional: styling hint for clients
issuer: &quot;https://accounts.google.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
scopes: [&quot;openid&quot;, &quot;profile&quot;, &quot;email&quot;] # email is optional, read below
user_mapping_provider:
config:
localpart_template: &quot;{{ user.given_name|lower }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
email_template: &quot;{{ user.email }}&quot; # needs &quot;email&quot; in scopes above
</code></pre>
</li>
<li>Back in the Google console, add this Authorized redirect URI: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
</ol>
<h3 id="keycloak"><a class="header" href="#keycloak">Keycloak</a></h3>
<p><a href="https://www.keycloak.org/docs/latest/server_admin/#sso-protocols">Keycloak</a> is an opensource IdP maintained by Red Hat.</p>
<p>Keycloak supports OIDC Back-Channel Logout, which sends logout notification to Synapse, so that Synapse users get logged out when they log out from Keycloak.
This can be optionally enabled by setting <code>backchannel_logout_enabled</code> to <code>true</code> in the Synapse configuration, and by setting the &quot;Backchannel Logout URL&quot; in Keycloak.</p>
<p>Follow the <a href="https://www.keycloak.org/getting-started">Getting Started Guide</a> to install Keycloak and set up a realm.</p>
<ol>
<li>
<p>Click <code>Clients</code> in the sidebar and click <code>Create</code></p>
</li>
<li>
<p>Fill in the fields as below:</p>
</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client ID</td><td><code>synapse</code></td></tr>
<tr><td>Client Protocol</td><td><code>openid-connect</code></td></tr>
</tbody></table>
<ol start="3">
<li>Click <code>Save</code></li>
<li>Fill in the fields as below:</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client ID</td><td><code>synapse</code></td></tr>
<tr><td>Enabled</td><td><code>On</code></td></tr>
<tr><td>Client Protocol</td><td><code>openid-connect</code></td></tr>
<tr><td>Access Type</td><td><code>confidential</code></td></tr>
<tr><td>Valid Redirect URIs</td><td><code>[synapse public baseurl]/_synapse/client/oidc/callback</code></td></tr>
<tr><td>Backchannel Logout URL (optional)</td><td> <code>[synapse public baseurl]/_synapse/client/oidc/backchannel_logout</code></td></tr>
<tr><td>Backchannel Logout Session Required (optional)</td><td> <code>On</code></td></tr>
</tbody></table>
<ol start="5">
<li>Click <code>Save</code></li>
<li>On the Credentials tab, update the fields:</li>
</ol>
<table><thead><tr><th>Field</th><th>Value</th></tr></thead><tbody>
<tr><td>Client Authenticator</td><td><code>Client ID and Secret</code></td></tr>
</tbody></table>
<ol start="7">
<li>Click <code>Regenerate Secret</code></li>
<li>Copy Secret</li>
</ol>
<pre><code class="language-yaml">oidc_providers:
- idp_id: keycloak
idp_name: &quot;My KeyCloak server&quot;
issuer: &quot;https://127.0.0.1:8443/realms/{realm_name}&quot;
client_id: &quot;synapse&quot;
client_secret: &quot;copy secret generated from above&quot;
scopes: [&quot;openid&quot;, &quot;profile&quot;]
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
backchannel_logout_enabled: true # Optional
</code></pre>
<h3 id="lemonldap"><a class="header" href="#lemonldap">LemonLDAP</a></h3>
<p><a href="https://lemonldap-ng.org/">LemonLDAP::NG</a> is an open-source IdP solution.</p>
<ol>
<li>Create an OpenID Connect Relying Parties in LemonLDAP::NG</li>
<li>The parameters are:</li>
</ol>
<ul>
<li>Client ID under the basic menu of the new Relying Parties (<code>Options &gt; Basic &gt; Client ID</code>)</li>
<li>Client secret (<code>Options &gt; Basic &gt; Client secret</code>)</li>
<li>JWT Algorithm: RS256 within the security menu of the new Relying Parties
(<code>Options &gt; Security &gt; ID Token signature algorithm</code> and <code>Options &gt; Security &gt; Access Token signature algorithm</code>)</li>
<li>Scopes: OpenID, Email and Profile</li>
<li>Allowed redirection addresses for login (<code>Options &gt; Basic &gt; Allowed redirection addresses for login</code> ) :
<code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ul>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: lemonldap
idp_name: lemonldap
discover: true
issuer: &quot;https://auth.example.org/&quot; # TO BE FILLED: replace with your domain
client_id: &quot;your client id&quot; # TO BE FILLED
client_secret: &quot;your client secret&quot; # TO BE FILLED
scopes:
- &quot;openid&quot;
- &quot;profile&quot;
- &quot;email&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}}&quot;
# TO BE FILLED: If your users have names in LemonLDAP::NG and you want those in Synapse, this should be replaced with user.name|capitalize or any valid filter.
display_name_template: &quot;{{ user.preferred_username|capitalize }}&quot;
</code></pre>
<h3 id="mastodon"><a class="header" href="#mastodon">Mastodon</a></h3> <h3 id="mastodon"><a class="header" href="#mastodon">Mastodon</a></h3>
<p><a href="https://docs.joinmastodon.org/">Mastodon</a> instances provide an <a href="https://docs.joinmastodon.org/spec/oauth/">OAuth API</a>, allowing those instances to be used as a single sign-on provider for Synapse.</p> <p><a href="https://docs.joinmastodon.org/">Mastodon</a> instances provide an <a href="https://docs.joinmastodon.org/spec/oauth/">OAuth API</a>, allowing those instances to be used as a single sign-on provider for Synapse.</p>
<p>The first step is to register Synapse as an application with your Mastodon instance, using the <a href="https://docs.joinmastodon.org/methods/apps/#create">Create an application API</a> (see also <a href="https://docs.joinmastodon.org/client/token/">here</a>). There are several ways to do this, but in the example below we are using CURL.</p> <p>The first step is to register Synapse as an application with your Mastodon instance, using the <a href="https://docs.joinmastodon.org/methods/apps/#create">Create an application API</a> (see also <a href="https://docs.joinmastodon.org/client/token/">here</a>). There are several ways to do this, but in the example below we are using CURL.</p>
@ -8004,6 +7969,72 @@ needed to add OAuth2 capabilities to your Django projects. It supports
subject_claim: &quot;id&quot; subject_claim: &quot;id&quot;
</code></pre> </code></pre>
<p>Note that the fields <code>client_id</code> and <code>client_secret</code> are taken from the CURL response above.</p> <p>Note that the fields <code>client_id</code> and <code>client_secret</code> are taken from the CURL response above.</p>
<h3 id="twitch"><a class="header" href="#twitch">Twitch</a></h3>
<ol>
<li>Setup a developer account on <a href="https://dev.twitch.tv/">Twitch</a></li>
<li>Obtain the OAuth 2.0 credentials by <a href="https://dev.twitch.tv/console/apps/">creating an app</a></li>
<li>Add this OAuth Redirect URL: <code>[synapse public baseurl]/_synapse/client/oidc/callback</code></li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: twitch
idp_name: Twitch
issuer: &quot;https://id.twitch.tv/oauth2/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
client_auth_method: &quot;client_secret_post&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<h3 id="twitter"><a class="header" href="#twitter">Twitter</a></h3>
<p><em>Using Twitter as an identity provider requires using Synapse 1.75.0 or later.</em></p>
<ol>
<li>Setup a developer account on <a href="https://developer.twitter.com/en/portal/dashboard">Twitter</a></li>
<li>Create a project &amp; app.</li>
<li>Enable user authentication and under &quot;Type of App&quot; choose &quot;Web App, Automated App or Bot&quot;.</li>
<li>Under &quot;App info&quot; set the callback URL to <code>[synapse public baseurl]/_synapse/client/oidc/callback</code>.</li>
<li>Obtain the OAuth 2.0 credentials under the &quot;Keys and tokens&quot; tab, copy the &quot;OAuth 2.0 Client ID and Client Secret&quot;</li>
</ol>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: twitter
idp_name: Twitter
idp_brand: &quot;twitter&quot; # optional: styling hint for clients
discover: false # Twitter is not OpenID compliant.
issuer: &quot;https://twitter.com/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_secret: &quot;your-client-secret&quot; # TO BE FILLED
pkce_method: &quot;always&quot;
# offline.access providers refresh tokens, tweet.read and users.read needed for userinfo request.
scopes: [&quot;offline.access&quot;, &quot;tweet.read&quot;, &quot;users.read&quot;]
authorization_endpoint: https://twitter.com/i/oauth2/authorize
token_endpoint: https://api.twitter.com/2/oauth2/token
userinfo_endpoint: https://api.twitter.com/2/users/me?user.fields=profile_image_url
user_mapping_provider:
config:
subject_template: &quot;{{ user.data.id }}&quot;
localpart_template: &quot;{{ user.data.username }}&quot;
display_name_template: &quot;{{ user.data.name }}&quot;
picture_template: &quot;{{ user.data.profile_image_url }}&quot;
</code></pre>
<h3 id="xwiki"><a class="header" href="#xwiki">XWiki</a></h3>
<p>Install <a href="https://extensions.xwiki.org/xwiki/bin/view/Extension/OpenID%20Connect/OpenID%20Connect%20Provider/">OpenID Connect Provider</a> extension in your <a href="https://www.xwiki.org">XWiki</a> instance.</p>
<p>Synapse config:</p>
<pre><code class="language-yaml">oidc_providers:
- idp_id: xwiki
idp_name: &quot;XWiki&quot;
issuer: &quot;https://myxwikihost/xwiki/oidc/&quot;
client_id: &quot;your-client-id&quot; # TO BE FILLED
client_auth_method: none
scopes: [&quot;openid&quot;, &quot;profile&quot;]
user_profile_method: &quot;userinfo_endpoint&quot;
user_mapping_provider:
config:
localpart_template: &quot;{{ user.preferred_username }}&quot;
display_name_template: &quot;{{ user.name }}&quot;
</code></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="saml"><a class="header" href="#saml">SAML</a></h1> <div style="break-before: page; page-break-before: always;"></div><h1 id="saml"><a class="header" href="#saml">SAML</a></h1>
<p>Synapse supports authenticating users via the <a href="https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language">Security Assertion <p>Synapse supports authenticating users via the <a href="https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language">Security Assertion
Markup Language</a> Markup Language</a>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long