Configuring Authentication
See how to download example files from the helm chart here.
Overview
The chart components authentication is managed by the top-level key authentication.
The configuration is similar if you use standalone Synapse (legacy authentication) or if you enable Matrix Authentication Service.
You can find configurations examples in charts/matrix-stack/ci/fragments/authentication-secrets-externally.yaml and charts/matrix-stack/ci/fragments/authentication-secrets-in-helm.yaml.
Registration and Password Authentication
The charts come with:
- registration disabled by default
- password authentication enabled by default
To change this default behaviour, you will have to configure it through the synapse.additional or matrixAuthenticationService.additional key. See Synapse documentation or Matrix Authentication Service documentation for more details.
Restricting allowed clients
When using Matrix Authentication Service in ESS Pro 26.10.6+lts or later, the clients that can be used to login can be restricted using Helm values.
matrixAuthentictionService:
restrictAllowedClients:
## Whether restrictions are in place or not.
## All other settings below are ignored if this is disabled
enabled: false
## Whether the Element Pro clients are allowed to login.
## Allowed by default
allowElementProClients: true
## Whether the FOSS Element X clients are allowed to login
## Blocked by default
allowElementFossClients: false
## A list of arbitrary other client URIs that are allowed to login
## This is useful if you use a custom/branded client
additionalClientUris: []
## Whether older clients that don't fully support Matrix Authentication Service are allowed to login
## Allowed by default
allowLegacyClients: true
## Whether the device code grant (RFC 8628) is enabled or not
## Disabling this also disables QR code login
allowDeviceCodeGrant: true
ESS Pro releases between 26.6.0 and 26.10.5 supported configuring some of this via matrixAuthenticationService.additional and synapse.additional configuration.
Customers should migrate to using the Helm values to configure client restrictions.
These restrictions are being introduced in two steps. The first step with this release just introduces the settings but keeps them disabled by default. In the vein of security by default, the defaults will change in later releases to only allow supported Element clients. Please make sure to follow this topic in order to make sure that required clients will not be locked-out accidentally (if you're using legacy or non-Element clients). It is best is to put configuration in place actively.
Configuring LDAP
You can configure a list of LDAP providers to use in the chart. Please refer to the description of the authentication.ldap key in the values file for details.
If LDAP is configured, and Advanced Identity and Access Management is enabled, it will use the first LDAP provider configured in the list as the source of its users.
SAML
Warning
Matrix Authentication Service does not support SAML and it is recommended to switch to OIDC.
Customers can deploy their own Dex or similar software to act as a bridge between SAML and OIDC if no other option exists.
Configuring OIDC
You can configure a list of OIDC providers to use in the chart. Please refer to the description of the authentication.oidc key in the values file for details.
This section contains sample configurations for popular OIDC providers.
Apple
Sign-in with Apple uses special non-standard for authenticating clients, which requires a special configuration.
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
Authelia
These instructions assume that you have already enabled the OIDC provider support in Authelia.
Add a client for MAS to Authelia's configuration.yaml (see the Authelia OIDC documentation for full details):
identity_providers:
oidc:
claims_policies:
matrix:
id_token: ['email', 'name', 'groups', 'preferred_username']
clients:
- client_id: "<client-id>" # TO BE FILLED
client_name: Matrix
client_secret: "<client-secret>" # TO BE FILLED
public: false
claims_policy: 'matrix'
redirect_uris:
- https://<mas-fqdn>/upstream/callback/<id>
scopes:
- openid
- groups
- profile
- email
grant_types:
- 'refresh_token'
- 'authorization_code'
response_types:
- code
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
Authentik
Authentik is an open-source IdP solution.
- Create a provider in Authentik, with type OAuth2/OpenID.
- The parameters are:
- Client Type: Confidential
- Redirect URIs:
https://<auth-service-domain>/upstream/callback/<id>
- Create an application for the authentication service in Authentik and link it to the provider.
- Note the slug of your application, Client ID and Client Secret.
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
Discord
- Create a new application in the Discord Developer Portal (see documentation)
- Add the following "Redirect URI" in the OAuth2 tab under settings:
https://<auth-service-domain>/upstream/callback/<id>
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
- You will need a Facebook developer account. You can register for one here.
- On the apps page of the developer console, "Create App", and choose "Allow people to log in with their Facebook account".
- Once the app is created, add "Facebook Login" and choose "Web". You don't need to go through the whole form here.
- In the left-hand menu, open "Use cases" > "Authentication and account creation" > "Customize" > "Settings"
- Add
https://<auth-service-domain>/upstream/callback/<id>as an OAuth Redirect URL.
- Add
- In the left-hand menu, open "App settings/Basic". Here you can copy the "App ID" and "App Secret" for use below.
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
GitHub
GitHub doesn't support OpenID Connect, but it does support OAuth 2.0.
It will use the fetch_userinfo option with a manual userinfo_endpoint to fetch the user's profile through the GitHub API.
- Create a new application.
- Fill in the form with an application name and homepage URL.
- Use the following Authorization callback URL:
https://<auth-service-domain>/upstream/callback/<id> - Retrieve the Client ID
- Generate a Client Secret and copy it
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
GitLab
- Create a new application.
- Add the
openidscope. Optionally add theprofileandemailscope if you want to import the user's name and email. - Add this Callback URL:
https://<auth-service-domain>/upstream/callback/<id>
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
- Set up a project in the Google API Console (see documentation)
- Add an "OAuth Client ID" for a Web Application under "Credentials"
- Add the following "Authorized redirect URI":
https://<auth-service-domain>/upstream/callback/<id>
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
Kanidm
Install and configure a Kanidm instance using the Official Docs
Create a OAuth2 Client following the OAuth2 Setup guide
⚠️ Important Ensure you configure the client to prefer short usernames. This means instead of
user@domain.tldit will return justuseras the preferred username You can configure this by runningkanidm system oauth2 prefer-short-username <client_id>.
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
Keycloak
Follow the Getting Started Guide to install Keycloak and set up a realm.
- Click
Clientsin the sidebar and clickCreate -
Fill in the fields as below:
Field Value Client ID matrix-authentication-serviceClient Protocol openid-connect -
Click
Save -
Fill in the fields as below:
Field Value Client ID matrix-authentication-serviceEnabled OnClient Protocol openid-connectAccess Type confidentialValid Redirect URIs https://<auth-service-domain>/upstream/callback/<id>Front channel logout OffBackchannel logout URL https://<auth-service-domain>/upstream/backchannel-logout/<id>Backchannel logout session required On -
Click
Save -
On the Credentials tab, update the fields:
Field Value Client Authenticator Client ID and Secret -
Click
Regenerate Secret - Copy Secret
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
Microsoft Azure Active Directory
Azure AD can act as an OpenID Connect Provider.
Register a new application under App registrations in the Azure AD management console.
The RedirectURI for your application should point to your authentication service instance:
https://<auth-service-domain>/upstream/callback/<id> where <id> is the same as in the config file.
Go to Certificates & secrets and register a new client secret. Make note of your Directory (tenant) ID as it will be used in the Azure links.
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
ProConnect
Follow the instructions to create an application for ProConnect.
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
Rauthy
- Click
Clientsin the Rauthy Admin sidebar and clickAdd new Client -
Fill in the fields as below:
Field Value Client ID matrix-authentication-serviceClient Name matrix-authentication-serviceRedirect URI https://<auth-service-domain>/upstream/callback/<id> -
Set the client to be
Confidential. -
Click
Save -
Select the client you just created from the clients list.
- Enable the
authorization_code, andrefresh_tokengrant types. - Set the allowed scopes to
openid,profile, andemail. - Set both Access Algorithm and ID Algorithm to
RS256. - Set PKCE challenge method to
S256. - Click
Save - Copy the
Client IDfrom theConfigtab and theClient Secretfrom theSecrettab.
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false
To use a Rauthy-supported Ephemeral Client, use this JSON document:
{
"client_id": "https://path.to.this.json",
"redirect_uris": [
"https://your-app.com/callback"
],
"grant_types": [
"authorization_code",
"refresh_token"
],
"access_token_signed_response_alg": "RS256",
"id_token_signed_response_alg": "RS256"
}
Shibboleth
Shibboleth is an open-source identity management system commonly used by universities and research institutions. It is primarily based on SAML but also supports OIDC via the OIDC OP Plugin.
These instructions assume you have a running Shibboleth instance with the OIDC plugin configured.
Register MAS as a relying party in Shibboleth:
- Add a metadata file (e.g.
mas-metadata.xml) to%{idp.home}/metadata/with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
xmlns:oidcmd="urn:mace:shibboleth:metadata:oidc:1.0"
entityID="<client-id>">
<Extensions>
<oidcmd:ClientInformation>
<oidcmd:ClientSecret><client-secret></oidcmd:ClientSecret>
</oidcmd:ClientInformation>
</Extensions>
<SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<Extensions>
<oidcmd:OIDCClientInformation scopes="openid profile email"
token_endpoint_auth_method="client_secret_basic">
<oidcmd:GrantType>authorization_code</oidcmd:GrantType>
<oidcmd:ResponseType>code</oidcmd:ResponseType>
</oidcmd:OIDCClientInformation>
</Extensions>
<AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Location="https://<auth-service-domain>/upstream/callback/<id>"
index="1"/>
</SPSSODescriptor>
</EntityDescriptor>
Replace `<client-id>`, `<client-secret>`, `<auth-service-domain>`, and `<id>` with your values.
- Reference the metadata file in
%{idp.home}/conf/metadata-providers.xmland reload services.
Authentication service configuration:
authentication:
oidc:
- idpId: 0000000000000000000001DCS0
idpName: OIDC Provider 0
issuer: <issuer>
clientId: <clientid>
clientAuthMethod: client_secret_basic
clientSecret:
value: <clientsecret>
scopes:
- openid
- profile
- email
forwardLoginHint: false
fetchUserInfo: false
responseMode: query
backchannelLogout: do_nothing
endpointsDiscovery:
skipVerification: false
usePKCE: false