Skip to content

IdP domain mappings need an explicit scope

Accepted.

2026-09-15.

An identity provider (IdP) is linked to email domains. Each domain has a mapping that decides what scope a user from that domain receives on first sign-in: ANCHOR (platform-wide), CLIENT (one tenant) or PARTNER (granted access to specific clients). Creating a provider with allowedEmailDomains also creates mappings for any domain that has none.

The original behaviour created new mappings as ANCHOR whenever no client was given. That meant forgetting a field silently produced the most privileged scope: every user signing in from that domain became an anchor user.

When a provider is created or updated with domains that need a new mapping, the scope is an explicit choice. The request carries mappingScope: "ANCHOR" | "CLIENT", and there is no fall-through.

Code (400) When
MAPPING_SCOPE_REQUIRED a new mapping would be created and mappingScope is absent, or primaryClientId is set without a scope
INVALID_MAPPING_SCOPE any other value (PARTNER is managed on the email-domain page)
PRIMARY_CLIENT_REQUIRED CLIENT without a non-blank primaryClientId
PRIMARY_CLIENT_NOT_ALLOWED ANCHOR with a primaryClientId

Behaviour for existing mappings is conservative:

  • A mapping routed elsewhere that the provider claims keeps its scope; with CLIENT, the client is linked only if the mapping has none.
  • A mapping already routed to this provider keeps its scope; with CLIENT, a client is linked if none exists. This is the “edit later” path for a provider created with ANCHOR domains.
  • An existing primary client is never overwritten.
  • The check runs before any row is written, so a failed request leaves nothing behind.
  • Removal-only updates need no scope.

The console shows a “Domain scope” choice with nothing preselected whenever at least one domain is listed.

Good:

  • Privilege is never granted by omission.
  • Existing mappings are not rewritten by a later edit.
  • The error codes are specific, so clients can render them inline.

Bad:

  • Callers (scripts, infrastructure code, test fixtures) that created providers without a scope broke and had to be updated.
  • Two sources of truth for mapping scope remain: the provider form and the email-domain page. PARTNER can only be set on the latter.
Alternative Why not
Default to CLIENT when a client is supplied and ANCHOR otherwise Keeps the silent privilege path.
Default to least privilege (CLIENT with no client) Creates unusable mappings.
Require scope on every update Needless friction for edits that add no domain.