Skip to content

OIDC / SSO Provider Settings

spec.oidc configures the user_oidc app: the operator installs and enables the app and creates the provider with occ user_oidc:provider. Credentials and the secret handling are described in Secret Management. This page covers the user-mapping and behaviour settings of that provider.

spec:
  oidc:
    enabled: true
    providerName: keycloak
    clientId: nextcloud
    clientSecretRef: {name: oidc-secret}
    discoveryUri: https://iam.example.com/realms/office/.well-known/openid-configuration
    # optional user-mapping settings
    mappingUid: preferred_username
    uniqueUid: false
    groupProvisioning: true

Fields

Every field is optional and has no default in the CRD. The operator maps each one to one --option=value argument of occ user_oidc:provider. Booleans are passed as 1/0; false is sent, not dropped. Reference: lib/Command/UpsertProvider.php of user_oidc v8.10.x/v8.11.0 (Nextcloud 29 to 35).

Field Type occ option Meaning
mappingUid string --mapping-uid Claim used as the Nextcloud user id.
uniqueUid bool --unique-uid false: the user id is the mapped claim itself. true: a provider-prefixed hash (user_oidc's default for new providers).
mappingDisplayName string --mapping-display-name Claim for the display name.
mappingEmail string --mapping-email Claim for the email address.
mappingQuota string --mapping-quota Claim for the storage quota.
groupProvisioning bool --group-provisioning Create and sync groups from the groups claim.
mappingGroups string --mapping-groups Claim holding the groups.
groupWhitelistRegex string --group-whitelist-regex Only provision groups matching this regex.
groupRestrictLoginToWhitelist bool --group-restrict-login-to-whitelist Refuse login for users in no whitelisted group.
scope string --scope Requested scopes, space separated.
extraClaims string --extra-claims Extra claims to request.
checkBearer bool --check-bearer Validate Bearer tokens of API/WebDAV calls against this provider.
bearerProvisioning bool --bearer-provisioning Auto-provision users that send a Bearer token.
sendIdTokenHint bool --send-id-token-hint Send the ID token as hint on unified logout.
resolveNestedClaims bool --resolve-nested-claims Dot-separated and fallback claim mappings.

Not exposed: the remaining profile-attribute mappings (website, address family, phone, avatar, language and so on), entraid-group-names, the end-session and post-logout URIs. Use a NextcloudCommand for those.

Clearing a value

Because an absent field leaves the live value alone, the way to clear a mapping is to set it to the empty string: mappingGroups: "" passes --mapping-groups= and empties the setting. This works for mappingUid, mappingDisplayName, mappingEmail, mappingQuota, mappingGroups, groupWhitelistRegex and extraClaims. It does not work for scope: an empty scope would break login, so scope: "" is ignored (nothing is passed). Booleans are reset by setting them to the value you want (false is sent as 0).

Other string values must be non-empty and free of newlines; a value of the wrong type is ignored (and, on a structurally validated CRD, rejected by the API server).

Absent means unchanged

A field that is not set is not passed to occ. With no new field set, the operator's command is identical to releases before these fields existed. occ user_oidc:provider keeps every setting that is not passed, so:

  • on a new provider an unset setting has user_oidc's own default;
  • on an existing provider an unset setting keeps its current value;
  • removing a field from the spec does not revert the provider. To go back to a value, set it explicitly (for example uniqueUid: true).

Re-reconcile and changes

The provider call is an in-place upsert. The operator runs it on create, on spec updates, on a forced reconcile and when the instance becomes Ready. Running it with unchanged values rewrites the same values and keeps the provider id. Changing a field updates that setting on the existing provider. The new fields do not enter the Helm values, so changing one does not roll the pod.

The operator does not compare against the live provider; the upsert is cheap and idempotent. It does not delete a provider because a field changed.

How the user id depends on the provider id

With uniqueUid: true (user_oidc's default) the Nextcloud user id is a SHA-256 hash of the provider's numeric database id and the claim (LocalIdService, user_oidc v8.10.1). A provider that is deleted and recreated gets a new numeric id, so every user gets a new hashed id: new, empty accounts, with the old accounts left behind.

With uniqueUid: false the user id is the mapped claim itself and does not depend on the provider id at all, so a recreated provider with the same settings maps users to the same accounts.

The before-starting hook deletes the providers that occ user_oidc:providers lists at pod start. While spec.oidc.enabled is true it keeps the provider named providerName (exact match; default oidc) and deletes every other one, so the operator's provider keeps its numeric id across pod starts and the operator's upsert updates it in place. With enabled: false the hook still deletes all providers and disables the app.

providerName must not start with - (occ would read it as an option). The CRD rejects such a name; if one gets past the API server (for example through a pool template), the operator sets OIDCReady=False with reason InvalidProviderName and does not configure the provider.

Requirements of the hook's provider cleanup

The cleanup lists providers with occ user_oidc:providers --output=json, which needs user_oidc 8.2.0 or newer (the app store currently serves 8.11.0 for Nextcloud 31 to 33). On older versions, and while the instance is in maintenance mode (occ does not load app-provided commands then), the command fails, the hook deletes nothing and carries on. The cleanup is therefore skipped during maintenance, for example while an upgrade is held.

Warning: uniqueUid and account orphaning

uniqueUid decides how a login is turned into a Nextcloud user id. Users that logged in under one setting are not found under the other: they get a new, empty account, and the old account with its files stays behind unused. So:

  • Set uniqueUid (and mappingUid) before the first user logs in, and never flip it on a provider that already has users.
  • The same applies to mappingUid alone.
  • Renaming providerName is a delete and recreate. The old provider is removed by the before-starting hook (it is no longer the configured one) and the operator creates a new one under the new name, which gets a new numeric id. With uniqueUid: true that means new, empty accounts for every user. With uniqueUid: false users are unaffected, because their id does not depend on the provider id. The rename also rolls the pod once, because providerName is part of the hook text.

Migrating a hand-made provider

If the provider was created by hand, for example

php occ user_oidc:provider "corp-sso" --clientid=... --clientsecret=... --discoveryuri=... \
  --mapping-uid=preferred_username --unique-uid=0 --group-provisioning=1

then, before letting the operator manage it:

  1. Read the live settings: php occ user_oidc:provider "<name>" --output=json (prints the provider with its settings; no secret).
  2. Set providerName to the same identifier and copy the settings into spec.oidc (mappingUid, uniqueUid: false, groupProvisioning: true, ...). Do this in the same change that enables spec.oidc.
  3. After the first reconcile, check user_oidc:provider "<name>" --output=json again and log in with an existing user: the user id must be unchanged.

An operator-created provider with a different providerName is a second provider next to the hand-made one, not an update of it.