Setting up OpenID Connect
eventcatalog@5.20.0This guide takes you through setting up a protected sign-in screen for your docs. Before going through this guide, make sure you've first gone through Enabling authentication.
If your identity provider does not have its own entry in EventCatalog, you can connect it with the generic oidc provider. It works with any provider that supports OpenID Connect.
To set up your EventCatalog site with an OpenID Connect provider, the process looks as follows:
- Create an OIDC app in your identity provider
- Configure the provider in EventCatalog
- Test the authentication
Create an OIDC app
eventcatalog@5.20.0First, create a new OIDC application (sometimes called a client) in your identity provider's admin console. The exact steps depend on your provider, so check its documentation for creating a web application that uses the authorization code flow.
You will need the following:
- Application type: a web application using the Authorization Code flow
- Redirect URI (callback URL):
- Production:
{YOUR_EVENTCATALOG_SITE_URL}/api/auth/callback/oidc - Local development:
http://localhost:3000/api/auth/callback/oidc
- Production:
- Scopes:
openid,emailandprofile - Assignments: the users or groups who can access the application
The redirect URI always ends in /api/auth/callback/oidc. The provider id is fixed to oidc and cannot be changed.
Once the app is created, copy the Client ID and Client Secret, and find the issuer URL of your provider.
The issuer must match the issuer value in your provider's /.well-known/openid-configuration document exactly, including any trailing slash. For example, https://auth.example.com/ and https://auth.example.com are different values.
Configure the provider in EventCatalog
eventcatalog@5.20.0Add your Client ID and Client Secret to your .env file.
AUTH_OIDC_ISSUER={YOUR_OIDC_ISSUER}
AUTH_OIDC_CLIENT_ID={YOUR_OIDC_CLIENT_ID}
AUTH_OIDC_CLIENT_SECRET={YOUR_OIDC_CLIENT_SECRET}
In your eventcatalog.auth.js file, add an oidc provider.
export default {
providers: {
oidc: {
name: 'Company SSO',
issuer: process.env.AUTH_OIDC_ISSUER,
clientId: process.env.AUTH_OIDC_CLIENT_ID,
clientSecret: process.env.AUTH_OIDC_CLIENT_SECRET,
},
},
};
Options
| Option | Required | Description |
|---|---|---|
name | No | Name shown on the login button ("Continue with name") and in the user menu. Defaults to SSO. |
issuer | Yes | Issuer URL of your provider. Must match its /.well-known/openid-configuration exactly. |
clientId | Yes | Client ID of the OIDC app. |
clientSecret | No | Client secret of the OIDC app. |
scope | No | Scopes to request. Defaults to openid email profile. |
groupsClaim | No | Token claim that holds the user's groups. Defaults to groups. |
rolesClaim | No | Token claim that holds the user's roles. Defaults to roles. |
Any other Auth.js OIDC option (for example checks, authorization or client) is passed through to Auth.js. If you set authorization.params, it is merged with scope, and a scope set there wins.
Read groups and roles
eventcatalog@5.20.0EventCatalog reads the user's groups and roles from claims in their tokens, and makes them available to your RBAC middleware. Use hasGroup() and hasRole(), or read locals.user.groups and locals.user.roles. For these users, locals.user.provider is oidc.
Claims are read as follows:
- The ID token's claims are read first. If it has none, the access token's claims are used.
- An exact claim name is tried first, so namespaced claims such as
https://example.com/groupswork. - Otherwise the name is read as a dotted path into nested claims, such as
realm_access.roles. - An array claim gives a list of values. A single string counts as one value and is not split.
export default {
providers: {
oidc: {
name: 'Company SSO',
issuer: process.env.AUTH_OIDC_ISSUER,
clientId: process.env.AUTH_OIDC_CLIENT_ID,
clientSecret: process.env.AUTH_OIDC_CLIENT_SECRET,
groupsClaim: 'https://example.com/groups',
rolesClaim: 'roles',
},
},
};
Your provider must include these claims in the tokens it issues. Check its documentation for how to add a groups or roles claim to an app.
Test the authentication
Restart your EventCatalog server and test the authentication.
npm run dev
All pages should now be protected and require an account from your identity provider.
- Navigate to your EventCatalog site
- You should be redirected to the sign-in page
- Click Continue with followed by the
nameyou configured - Sign in with your identity provider
- After successful authentication, you'll be redirected back to EventCatalog
Found an issue?
Remember to setup the prerequisites for this guide:
If you still have problems, please let us know.