Removed the direct access grant on the rest-api client in the dev realm.json Repair make test-keycloak, which could not run against a freshly imported realm. The fixtures need more rights than the rest-api service account holds, so they now use the bootstrap admin service account. The bootstrap admin user cannot serve here, because it has an empty profile and Keycloak refuses the password grant. Grant view-realm to the service account. set_realm_role reads a realm role by id, which fails with 403 without that role. Add a setup guide for the authentication provider and one for the identity provider. Document the required client shape in env.md.
5.1 KiB
Authentication Provider Setup Guide
Messages uses OpenID Connect in two distinct parts. Do not confuse them.
- Authentication. Messages delegates each user login to an OIDC
provider. The provider can be ProConnect, Keycloak, or any
other OIDC provider. Every Messages instance needs one, this is
managed by the
OIDC_**environment vars. - Mailbox identities and Maildomains. A mail domain decides how a user gets a
mailbox. This part is independent of the authentication provider.
This is managed by the
IDENTITY_PROVIDERenvironment variable, for now Messages only supports Keycloak.
This guide covers the first part only. If you are looking for the mailbox and maildomain provisioning, see identity-provider.md.
What Messages Expects from the Provider
Messages acts as a standard OIDC relying party. Any compliant provider works. Messages needs:
- the authorization code flow, with a confidential client;
- an
emailclaim in the userinfo response. Messages matches a user to a mailbox by this address; - the five endpoints listed below. Most providers publish them at
/.well-known/openid-configuration.
Setup Steps
-
Create a client at your provider.
Set the redirect URI, for example
https://messages.example.fr/api/v1.0/callback/.Set the Logout redirect URI, for example
https://messages.example.fr/api/v1.0/logout-callback/. -
Set the client variables. Set
OIDC_RP_CLIENT_IDandOIDC_RP_CLIENT_SECRETto the credentials of that client. -
Set the endpoint variables. Read them from the provider's
/.well-known/openid-configurationdocument:Variable Discovery document key OIDC_OP_AUTHORIZATION_ENDPOINTauthorization_endpointOIDC_OP_TOKEN_ENDPOINTtoken_endpointOIDC_OP_USER_ENDPOINTuserinfo_endpointOIDC_OP_JWKS_ENDPOINTjwks_uriOIDC_OP_LOGOUT_ENDPOINTend_session_endpointThe browser reaches the authorization endpoint and the logout endpoint. Give them a public URL. The backend reaches the other three. A private URL is enough for those.
-
Set the redirect hosts. Add each host that serves Messages to
OIDC_REDIRECT_ALLOWED_HOSTS. SetOIDC_REDIRECT_REQUIRE_HTTPStoTruein production. -
Check the scopes.
OIDC_RP_SCOPESmust request the claims Messages needs. The default isopenid email.
See the OIDC Configuration and
OIDC Advanced Settings sections of
env.md for the full variable tables.
ProConnect as the Authentication Provider
For ProConnect Integration you can create your application at https://partenaires.proconnect.gouv.fr and can use the following variables :
OIDC_RP_CLIENT_ID=XX
OIDC_RP_CLIENT_SECRET=XX
OIDC_OP_AUTHORIZATION_ENDPOINT=https://fca.integ01.dev-agentconnect.fr/api/v2/authorize
OIDC_OP_JWKS_ENDPOINT=https://fca.integ01.dev-agentconnect.fr/api/v2/jwks
OIDC_OP_LOGOUT_ENDPOINT=https://fca.integ01.dev-agentconnect.fr/api/v2/session/end
OIDC_OP_TOKEN_ENDPOINT=https://fca.integ01.dev-agentconnect.fr/api/v2/token
OIDC_OP_USER_ENDPOINT=https://fca.integ01.dev-agentconnect.fr/api/v2/userinfo
OIDC_AUTH_REQUEST_EXTRA_PARAMS={"acr_values": "eidas1"}
ProConnect requires a Level of Assurance in the authorization request.
OIDC_AUTH_REQUEST_EXTRA_PARAMS carries it, for example
{"acr_values": "eidas1"}. The mobile application depends on this value
too. See mobile.md.
For ProConnect Production, contact the ProConnect team.
Keycloak as the Authentication Provider
You can use Keycloak for this part too. Create a second client, next to the service-account client of identity-provider.md.
-
Create the
messagesclient. Configure it as a confidential client. Turn the standard flow on. Turn the direct access grants off. Turn the service accounts off.Set the redirect URIs to your own host names.
The dev realm (
src/keycloak/realm.json) shows example values. Adapt the values to your own host names. Do not reuse the example values. -
Set the login variables. Set
OIDC_RP_CLIENT_IDandOIDC_RP_CLIENT_SECRETfrom themessagesclient. Set the five endpoint variables from the realm, athttps://<KEYCLOAK_URL>/realms/<realm>/.well-known/openid-configuration.
How a User Gets a Mailbox After the Login
The login alone does not give a user a mailbox. The mail domain decides that, and it is a separate mechanism.
In short:
- a mail domain with
oidc_autojoingives each user connected through the authentication provider a mailbox at login, you don't need to setup anything else; - a mail domain with
identity_synclets you create the mailboxes as you need, but you'll then need anIDENTITY_PROVIDER, see identity-provider.md.; - a mail domain with neither field can manage shared mailboxes only, the admin must configure the access on every mailbox to an authenticated user manually.