Integrations

Keycloak

Sign in to Neurouter with Keycloak over OpenID Connect and send Keycloak group membership as a groups claim for roles and MCP access control.

Last updated: 2026-11-24 · Markdown

Neurouter works with Keycloak as a standard OpenID Connect provider, and Keycloak can send group membership in the ID token.

1. Create a client in Keycloak

In your realm, create a client:

  • Client type: OpenID Connect; Client authentication: on (confidential client); Standard flow: on.
  • Valid redirect URIs: https://mcp.example.com/api/auth/callback (your PUBLIC_URL followed by /api/auth/callback).
  • Copy the client secret from the client's credentials.
  • Add a Group Membership mapper to the client's dedicated scope, with token claim name groups and Add to ID token on. Turn Full group path off if you want plain names such as neurouter-admins rather than paths such as /neurouter-admins.

See the Keycloak server administration guide for details.

2. Configure Neurouter

OIDC_ISSUER=https://keycloak.example.com/realms/<realm>
OIDC_CLIENT_ID=neurouter
OIDC_CLIENT_SECRET=<client-secret>
OIDC_DISPLAY_NAME="Sign in with Keycloak"
OIDC_SCOPES="openid email profile"
OIDC_GROUPS_CLAIM=groups
OIDC_ADMIN_GROUPS=neurouter-admins
OIDC_AUDITOR_GROUPS=security-auditors

Match the group values exactly as Keycloak sends them: with Full group path on, use /neurouter-admins.

Trying it locally

The repository's Docker Compose file includes a Dex identity provider (docker compose --profile oidc up) for testing OIDC sign-in without Keycloak. For Keycloak, the issuer URL must be reachable both from your browser and from the Neurouter container.

How Neurouter uses the claims

  • Claims come from the ID token, merged with userinfo where the token doesn't contain them.
  • Users must have an email; if Keycloak reports it as unverified, sign-in is refused.
  • Group values are matched against OIDC_ADMIN_GROUPS, OIDC_AUDITOR_GROUPS and the group mappings in the console at every sign-in.