Skip to main content

User Portal SSO

User Portal SSO

This page owns IdP setup, entitled-team mapping, directory provisioning, and browser SSO troubleshooting. Portals And API Keys owns credential administration and portal procedures; Request Lifecycle And Security owns authentication policy.

Browser Login Flow

%%{init: {"sequence": {"rightAngles": true}}}%%
sequenceDiagram
  actor Browser
  participant DM as Dense-Mem
  participant IdP as OIDC provider
  participant PG as PostgreSQL
  Browser->>DM: Start enabled provider login
  DM->>IdP: Authorization request with state and PKCE
  IdP-->>DM: Authorization-code callback
  DM->>IdP: Validate tokens and load configured claims/groups
  DM->>PG: Resolve identity and entitled memberships
  PG-->>DM: Selected team, membership, role and grants
  DM-->>Browser: Browser session and CSRF cookies
  opt Select another entitled team
    Browser->>DM: POST /ui/api/sso/team
    DM->>PG: Revalidate entitlement and select membership
    DM-->>Browser: Refreshed session and connection details
  end

Register https://<dense-mem-host>/ui/api/sso/callback with the OIDC provider. It is derived from the configured SSO_PUBLIC_BASE_URL. Use GET /ui/api/sso/providers to inspect login availability, and GET /ui/api/sso/start/{providerId} to start login.

One SSO identity can have memberships in several teams. Each membership has its own permanent owner alias and private space. Team selection never creates API-key material. Owned API credentials have separate private spaces; their administration is in Portals And API Keys.

POST /ui/api/sso/logout clears the local SSO session. It is not an OIDC post-logout landing page. If an IdP requires a post-logout URL, use /ui; Dense-Mem does not implement RP-initiated logout as part of this flow.

Provider setup is version-sensitive: match the deployed release and the provider's current configuration.

SSO Login Visibility

The user portal shows SSO login only when public SSO is ready:

  • SSO_PUBLIC_BASE_URL is an absolute http or https URL.
  • At least one SSO provider is enabled.
  • The provider has a valid issuer URL and client ID.
  • If the provider uses Client secret env, that environment variable exists and is not empty.

When these conditions are not met, /ui should only show API-key login and GET /ui/api/sso/providers should return no public providers. This is intentional for deployments such as the hosted demo.

Provider Fields

Configure providers under Identity & access → Providers in the control portal.

FieldMeaning
NameDisplay name shown on the user portal login screen.
KindUse OIDC for standards-based OIDC providers. Use provider-specific kinds only when Dense-Mem has a provider-specific integration.
Issuer URLProvider issuer base URL, without /.well-known/openid-configuration.
Client IDOIDC application client ID.
Client secret envEnvironment variable name that contains the client secret. Leave empty for public PKCE clients.
ScopesLogin scopes requested during the browser flow. Use at least openid, profile, and email.
Group claimsClaim names that contain group, role, or entitlement values.
Groups endpointOptional endpoint used when group claims are not present or when SSO entitlement refresh needs a provider lookup.
Groups scopesScopes for the groups endpoint. If a groups endpoint is configured, these are also requested during browser login.
EnabledEnables the provider for login after the rest of the setup is correct.

The same provider can separately validate OAuth access tokens for MCP. This is not the browser login flow and remains disabled until its protected-resource settings are complete:

Protected-resource fieldMeaning
Accept OAuth JWTs on MCPUnder MCP access tokens. Enables access-token validation and RFC 9728 discovery for this issuer.
Allowed audiencesExact accepted aud values; at least one is required.
JWKS sourcediscovery reads the issuer's OIDC document; static uses the configured JWKS URL.
JWKS URLAbsolute HTTPS public-key endpoint, required only for static.
Signature algorithmsExplicit asymmetric allowlist; RS256 is the initial default.
Scope claimToken claim containing a space-delimited string or string array, commonly scope or scp.
Team claimOptional claim containing a Dense-Mem team UUID. A team-scoped MCP URL is preferred for multi-team users.
Scope mappingsMaps each external OAuth scope to bounded Dense-Mem grants. Effective access is the intersection with the selected membership.

Dense-Mem matches the token subject through the provider's configured identity claim and requires an existing active SSO identity and team membership. It does not auto-provision from an MCP token and never stores the token.

Enabling Accept OAuth JWTs on MCP on any enabled provider makes that customer IdP the MCP OAuth authority and turns off built-in MCP sign-in. An invalid protected-resource provider makes discovery fail closed. See MCP OAuth authority. In built-in mode, the consent page offers the enabled login providers for SSO sign-in.

Group mappings connect provider group values to Dense-Mem teams:

Mapping fieldMeaning
TeamDense-Mem team to grant access to.
Group IDExact group or role value from the provider claim.
PermissionDense-Mem API scopes for member mappings, such as read-only or read/write. Manager mappings always grant read/write.
RoleDense-Mem membership role, either member or manager. Manager role grants the /ui Team tab for that team.
EnabledTurn off to disable a mapping without deleting it.

Microsoft Entra ID / Azure AD SCIM Directory Automation

One Dense-Mem deployment is one organization boundary. An Entra provider can have one SCIM connector. The connector provisions durable users, groups, and group memberships; it does not create a second organization or a second authorization store.

Set up the provider first, using the tenant's discovered OIDC issuer, the application client ID, the Entra tenant ID, and oid as the stable identity claim. Register the normal user callback:

https://<dense-mem-user-host>/ui/api/sso/callback

Then configure a directory connector from that provider's SSO panel. Dense-Mem shows the connector ID and its bearer token plus OAuth client credentials once. Store those values in the Entra provisioning application or a secret manager; they cannot be read back from Dense-Mem. Rotate them from the control portal if they are lost or suspected exposed.

Set SCIM_PUBLIC_BASE_URL to the dedicated HTTPS base URL that fronts the main listener. The connector's SCIM base is:

https://<scim-host>/scim/v2/<connector-id>

The OAuth client-credentials token endpoint is:

https://<scim-host>/scim/oauth/token

The SCIM service accepts either the connector bearer token or an OAuth access token issued for that connector. It supports SCIM 2.0 Users and Groups, including PATCH and exact equality filters used by ordinary Entra provisioning. Bulk provisioning, a gallery-specific shortcut, workload identity federation, and multiple connectors for one provider are not part of this version.

Configure a full-match RE2 pattern with named team and role captures, then map each allowed role capture to a Dense-Mem member or manager entitlement. For example:

^ActiveDirectoryGroup(?P<team>.+?)(?P<role>Readonly|Member|Manager)Permission$

With the matching entitlement map, a group named ActiveDirectoryGroupResearchManagerPermission can create or bind the Research team and grant its current members manager access. The connector previews its plan before activation and enforces the configured auto-team cap.

The lifecycle is deliberate:

  1. disabled has no directory authority.
  2. observe accepts provisioning state and shows the proposed bindings, candidates, and durable issues without changing authorization.
  3. active requires the current preview version and applies that initial reconciliation atomically. SCIM becomes the authority for that provider's user/team entitlements.

While a connector is active, the OIDC login proves the user identity only. Dense-Mem does not grant user-portal teams from OIDC group claims, UserInfo, or a configured Graph/groups endpoint. It requires an active SCIM user and a current durable SCIM membership that matches the selected team membership. Existing user sessions and SSO-owned API keys perform that same durable check, so removing a membership or deactivating a SCIM user denies access on the next request.

The connector treats the external group ID as durable. A later display-name rename never rebinds a group, moves a team, renames a team, or changes a role. An exact manual group-to-team mapping wins over automation. Otherwise, an unambiguous normalized active team name can be previewed as an exact-name binding; a newly created directory team stays marked directory-managed. Removing a group archives only a directory-created team. Exact-name, manual, and adopted teams remain active but lose the removed directory access. An operator may adopt a directory-created team to make it manual before that removal.

Control Portal SSO

The control portal keeps the break-glass CONTROL_PORTAL_TOKEN, and can also use an enabled OIDC provider plus explicitly configured control-admin group IDs. Set CONTROL_PUBLIC_BASE_URL to the dedicated HTTPS administrative ingress and register this separate callback with the selected provider:

https://<control-host>/control/auth/callback

Control-group membership is not a user-team mapping. It grants only control portal access. A control SSO session is checked against the active configured admin group on every use; when its provider has an active SCIM connector, the identity must also remain an active SCIM user. Keep the control listener private or behind dedicated administrative ingress, and retain the break-glass token outside browser-accessible configuration.

Generic OIDC Group And Role Mapping

Dense-Mem is not tied to a specific SSO vendor. A provider without an active SCIM connector can use stable group, role, or entitlement values through one of these paths:

  • ID-token claims
  • UserInfo claims
  • a configured groups endpoint

Set Group claims to the claim names that contain the values you want to map. Dense-Mem accepts common claim shapes:

Claim shapeDense-Mem group values
["admin", "writer"]admin, writer
"admin"admin
{ "admin": {...}, "writer": {...} }admin, writer

The group mapping Group field must exactly match one emitted value. This can be an IdP group name, a role key, an application role, or any stable entitlement string your provider emits.

For claim-only providers, leave Groups endpoint and Groups scopes empty. Claim-derived entitlements are cached for the browser SSO session lifetime. For providers that do not emit usable group or role claims, configure Groups endpoint and the delegated or client-credential scopes it needs.

Examples:

Provider styleTypical Group claims
Generic OIDC group claimsgroups
Entra ID or Azure AD groupsgroups or provider-specific group endpoint
Application rolesroles
ZITADEL project rolesurn:zitadel:iam:org:project:<project_id>:roles, urn:zitadel:iam:org:project:roles

Use LOG_LEVEL=debug during setup and read id_token_claim_names, userinfo_claim_names, and groups in the SSO callback logs to confirm the right claim names and emitted values.

Example: ZITADEL Cloud With Project Roles

For hosted ZITADEL, use the ZITADEL instance that owns the application as the issuer URL:

https://<instance>.us1.zitadel.cloud

If you have multiple ZITADEL URLs, use the one whose /.well-known/openid-configuration issuer matches the application client ID.

In ZITADEL:

  1. Create or open the project used for Dense-Mem.

  2. Create a web application that uses Authorization Code with PKCE.

  3. Add the Dense-Mem redirect URI:

    https://<dense-mem-host>/ui/api/sso/callback
  4. Copy the application client ID.

  5. Create project roles for Dense-Mem access.

Example project role:

ZITADEL role fieldExample
Keydense-mem-admin
Display nameDense-Mem Admin
Groupdense-mem

Dense-Mem matches the role key from the token claim. The ZITADEL role group is only a ZITADEL-side organizer unless your emitted claim contains that value.

Assign the role to each user that should access Dense-Mem. For example, assign your own user the dense-mem-admin role before testing login.

In Dense-Mem, configure the provider:

Dense-Mem fieldValue
NameZITADEL
KindOIDC
Issuer URLhttps://<instance>.us1.zitadel.cloud
Client IDZITADEL application client ID
Client secret envEmpty for a public PKCE app, or an environment variable name for a confidential app secret.
Scopesopenid, profile, email
Group claimsurn:zitadel:iam:org:project:<project_id>:roles, urn:zitadel:iam:org:project:roles
Groups endpointEmpty when using ZITADEL role claims.
Groups scopesEmpty when using ZITADEL role claims.
EnabledChecked after the provider, roles, and mappings are ready.

If ZITADEL does not emit role claims, enable Assert Roles on Authentication on the project for UserInfo role claims, or User Roles Inside ID Token on the application for ID-token role claims. When required by your ZITADEL setup, add the project audience scope to Scopes:

urn:zitadel:iam:org:project:id:<project_id>:aud

Create a Dense-Mem group mapping whose Group value is the ZITADEL role key:

Dense-Mem mapping fieldExample
TeamMark
Group IDdense-mem-admin
PermissionNot shown for Manager; manager implies read/write.
RoleManager
EnabledOn

With debug logging enabled, a successful claim read should show the ZITADEL role claim names and a group value matching the role key:

json
{
  "configured_group_claims": [
    "urn:zitadel:iam:org:project:<project_id>:roles",
    "urn:zitadel:iam:org:project:roles"
  ],
  "groups": ["dense-mem-admin"],
  "groups_from_userinfo": true
}

SSO Troubleshooting

Set LOG_LEVEL=debug while setting up SSO. The callback response now returns a safe setup hint, and the server log has provider and claim details.

Browser messageWhat to check
sso setup failed: no groups found in configured claimsGroup claims does not match the token or UserInfo claim names, or the provider is not emitting the expected group or role claims.
sso setup failed: group lookup failedThe groups endpoint, delegated scopes, or client credentials are wrong.
sso setup failed: no mapping matched the user groupsThe Dense-Mem mapping Group value does not exactly match the emitted role or group value.
sso setup failed: no enabled team entitlement matchedA mapping exists, but it is disabled or does not grant an enabled team entitlement.
sso access deniedThe provider is disabled, the session is invalid, or entitlement validation failed after setup.

For claim-based setups, the usual fix is:

  1. Read id_token_claim_names and userinfo_claim_names in the debug log.
  2. Put the provider's group or role claim names in Group claims.
  3. Set the Dense-Mem mapping Group to the emitted group or role value.
  4. Confirm the user is assigned that group, role, or entitlement in the IdP.

ZITADEL example references:

The canonical setting names and defaults remain in Configuration. This page owns the setup process and behavior; the configuration page owns the setting reference.