Single sign-on and SAML
masks works with other sign-in services in three ways. Single sign-on (SSO) means an actor signs in once and uses that sign-in for many apps.
| Direction | masks is | See |
|---|---|---|
| Sign in to masks with Google, Okta, Entra, or a SAML identity provider | the service provider, the side that accepts the sign-in | Providers |
| Sign in to a SAML-only app, such as a wiki, with masks | the identity provider, the side that signs actors in | SAML applications |
| Keep masks’ actors in sync with a directory | the SCIM service, the side a directory sends changes to | Provisioning |
Providers
Section titled “Providers”A provider is another service that actors sign in with, over OpenID Connect, OAuth 2.0, or SAML 2.0. masks links the account there to an actor in masks. That link is a connected account.
A provider takes the place of the password. The actor’s sign-in policy still asks for a second factor when it requires one.
To add a provider, open Settings, then Providers, in /manage, and choose Add provider.
A provider’s page lists what each tab holds.
Known providers
Section titled “Known providers”A known provider fills in every setting except the credentials.
| Known provider | Protocol | Asks for |
|---|---|---|
| OpenID Connect | ||
| Microsoft | OpenID Connect | directory (tenant) ID |
| Apple | OpenID Connect | team ID, key ID, private key |
| GitHub | OAuth 2.0 | |
| GitLab | OpenID Connect | domain, gitlab.com by default |
| Slack | OpenID Connect | |
| OpenID Connect | ||
| Discord | OAuth 2.0 | |
| OAuth 2.0 | ||
| X | OAuth 2.0 | |
| Okta, Auth0 | OpenID Connect | domain |
| Keycloak | OpenID Connect | domain, realm |
| Microsoft Entra (SAML), Okta (SAML), Google Workspace (SAML) | SAML 2.0 | metadata |
| Notion (MCP) | MCP | Nothing. masks registers itself. |
Under Anything else, a blank OpenID Connect, OAuth 2.0, SAML 2.0, or MCP server provider asks for everything.
Google, Apple, GitHub, GitLab, Slack, LinkedIn, and Discord turn on Trust the addresses it confirms.
An MCP server signs nobody in. Apps use it through a delegation.
Provider roles
Section titled “Provider roles”Add the actors it signs in, on the provider’s Sign-in tab, sets its role. The manage API
names the two roles delegate (on) and credential (off).
Off (credential) |
On (delegate) |
|
|---|---|---|
| Someone with no account | Refused. | Becomes an actor, with Scopes a new actor holds. |
| Name, photo, and email address | Left alone. | Updated from the provider on every sign-in. |
Turn it on when the company directory decides who works there.
Under either role:
- An actor who already has the same email address is connected only when both masks and the provider confirm that address, and only after the actor signs in another way once.
- An invited actor who has not accepted yet is connected at once, but only when masks trusts the address.
Trusted email addresses
Section titled “Trusted email addresses”masks tells apps email_verified: true for a confirmed address. So masks trusts an address from a
provider only when one of these is true:
- The address is in the provider’s Email domains, and the tenant has proven that domain.
- Trust the addresses it confirms is on, and the provider reports the address as confirmed.
Turn on Trust the addresses it confirms only for a provider that checks the person holds the mailbox. SAML has no field for confirmation, so a SAML provider is trusted only for proven domains in Email domains it answers for.
A trusted address lets a provider add an actor with an email address, take up an invitation, or change an actor’s address.
Email domains also limit who signs in. When the provider’s Email domains or the policy’s
email_domains is set:
- The provider signs in only addresses in both lists. An unset list allows any domain.
- The provider must report the address as confirmed. An address it says nothing about counts as confirmed only in a proven domain on the provider’s list.
- Someone with no email address is refused.
With neither list set, a provider that adds actors can add someone who has no email address.
Where a provider is offered
Section titled “Where a provider is offered”The sign-in policy decides where a provider is offered:
first_factorsmust includeprovider.providerslists which providers. All providers offers every one.- A provider that belongs to an organization is offered on the sign-in page only to a request that names the organization.
A signed-in actor can connect any provider their policy offers under Connected accounts on their account page. They must have signed in within the last 15 minutes. masks refuses an account at the provider that is already connected to someone else.
Sending a domain to its provider
Section titled “Sending a domain to its provider”An actor who types an email address at a company’s domain can go straight to that company’s provider, with no password prompt. masks does this only for a domain the tenant has proven it controls.
- In
/manage, open Settings, then General. - Under Domains, enter the domain and choose Claim.
- Publish the TXT record masks shows. A TXT record is a text entry in the domain’s DNS settings,
such as
_masks-challenge.acme.examplewith the valuemasks-verification=…. - Choose Check, or wait for the hourly check.
- Once the domain is proven, choose Send to the provider in the list beside it. Sign in here turns this off.
After that, an email address at the domain starts the provider’s sign-in. This happens even when the provider belongs to an organization the app did not name. Any other address, and a nickname, sign in the usual way.
- Claiming a domain needs
masks:manage:securityormasks:manage. - Only one tenant can prove a domain. Another tenant’s check for it is refused.
- When the record stops answering, the domain shows Stopped answering. Seven days later it is no longer proven, and actors sign in the usual way again.
- A sign-in policy without the
providerfactor sends nobody to a provider.
Provider protocols
Section titled “Provider protocols”OpenID Connect
Section titled “OpenID Connect”masks checks the id_token from the provider:
- Its signature, against the issuer’s keys.
- Its issuer, against the provider’s issuer.
- Its audience and nonce, against the client and the request.
The request uses PKCE, a one-time secret that stops someone else from using the sign-in code.
The subject, the ID for the account at the provider, is sub by default. For a Microsoft directory,
Subject (sub or oid) on the provider’s Sign-in tab can name oid instead.
Apple sends the actor’s name only on their first sign-in. masks keeps it.
OAuth 2.0
Section titled “OAuth 2.0”With no id_token, masks reads the provider’s userinfo endpoint. The request uses PKCE.
- Where each claim comes from maps each claim to a path in the response, such as
data.idfor X oridfor GitHub. - An Emails URL lists confirmed email addresses apart from the profile, as GitHub does. masks uses the primary confirmed address, or else another confirmed one. It ignores an address that appears only in the public profile.
SAML 2.0
Section titled “SAML 2.0”-
In
/manage, choose Add provider, then a SAML known provider or SAML 2.0. -
Give the identity provider the two values under Give … these:
Assertion consumer service URL https://demo.masks.example/login/provider/<key>/callbackService provider entity ID https://demo.masks.example/login/provider/<key>/metadata, which also serves masks’ metadata -
Under Identity provider, enter the Metadata URL and choose Read. Or paste the metadata under Or paste the metadata.
-
Choose Add.
Set Name ID format to Persistent, or ask the identity provider for a persistent name ID. A transient name ID changes on every sign-in, so each sign-in looks like a new actor.
masks reads a metadata URL again every night, so it picks up a rotated certificate.
An assertion is the signed message in which the identity provider says who signed in. masks trusts an assertion only when it:
- is signed by a certificate in the identity provider’s metadata
- answers a request this browser sent, and only once
- names this service provider as audience and recipient, and the identity provider as issuer
- is within its validity window, with one minute allowed for clock drift
masks refuses a response it did not ask for, such as one the identity provider starts.
SAML applications
Section titled “SAML applications”masks is the identity provider for apps that sign actors in only over SAML 2.0.
- The app sends an
AuthnRequest. - masks signs the actor in under their sign-in policy.
- masks posts a signed assertion back to the app.
What to give the application
Section titled “What to give the application”| Metadata | https://demo.masks.example/saml/metadata |
| Entity ID | The same URL. |
| Single sign-on | https://demo.masks.example/saml/sso, HTTP-Redirect or HTTP-POST. |
| Single logout | https://demo.masks.example/saml/slo, HTTP-Redirect or HTTP-POST. |
| Certificate | In the metadata. One for each published signing key. |
Most apps need only the metadata URL, which the client’s page shows as masks metadata. After a key rotation, the app must read the metadata again. The retiring key’s certificate stays in the metadata until that key is retired.
Registering one
Section titled “Registering one”- In
/manage, open Clients, and choose Add client. - Choose Signs actors in over SAML.
- Paste the app’s metadata under Its metadata, and choose Read it. masks fills in the app’s entity ID, assertion consumer services, signing certificate, single logout URL, and whether it signs its requests.
- Choose Add the client.
A SAML app is an approved client with no grants and no secret. It cannot use /authorize or
/token.
The SAML section of the client’s General tab holds its settings:
| Setting | |
|---|---|
| Entity ID | The Issuer its AuthnRequest names. |
| Names actors by | A persistent identifier (pairwise if the client is), or Their email. |
| Its signing certificate | What masks checks the app’s signed requests against. |
| Attributes it is sent | One attribute = claim a line. Left empty, the app gets the default attributes below. |
| Refuse requests it did not sign | Check every request against the certificate. |
| Let actors start from masks | Answer /saml/initiate/<client_id> without a request. The page shows the path as Start from masks. |
| Single logout URL | Where masks posts its logout messages. Without one, the app takes no part in single logout. |
The client’s Endpoints tab holds its Assertion consumer services, the only URLs masks posts to.
What is checked
Section titled “What is checked”masks shows an error and posts nothing when a request:
- names an
Issuerwith no registered app - names an assertion consumer service that is not registered, picks one by index, or asks for a binding other than HTTP-POST
- asks for a NameID format masks does not issue
- is more than eight minutes old, is more than three minutes in the future, or names another
Destination - was already received
- fails a required signature check, which needs SHA-256 or stronger
- is larger than 64 kilobytes, or declares a document type
ForceAuthn makes the actor sign in again. IsPassive gets NoPassive, with no page shown. An
actor who is suspended, declines, or is stopped by the policy gets RequestDenied.
What is asserted
Section titled “What is asserted”The response and the assertion are both signed with RSA-SHA256. The assertion is valid for five
minutes, names the session in SessionIndex, and names https://refeds.org/profile/mfa when a
second factor was used.
- By default, the attributes are
email,name,given_name,family_name, andpreferred_username, named after the claims they hold. - masks releases only what the actor’s
openid profile emailconsent covers. - masks releases an email address only once it is confirmed, as an attribute or as the NameID.
masks does not support encrypted assertions, the artifact and SOAP bindings, or choosing an assertion consumer service by index.
Single logout
Section titled “Single logout”Single logout means that signing out in one place signs the actor out of every app the session used. An app takes part when it has a Single logout URL. masks posts every logout message to that URL over HTTP-POST, signed with RSA-SHA256.
When the app signs a person out
Section titled “When the app signs a person out”The app sends a signed LogoutRequest to /saml/slo, over HTTP-Redirect or HTTP-POST. masks
refuses it, and ends nothing, when:
- the app has no single logout URL or no certificate
- the signature is missing or does not verify against the app’s certificate
- the request fails the checks an
AuthnRequestgets, or has expired - the request names no
NameID
Otherwise, masks ends every session in which the app was given that NameID. A request that carries a
SessionIndex ends only the sessions it names. masks answers with a signed LogoutResponse:
Success, or Requester with UnknownPrincipal when nothing matched.
An ended session ends as it does at /logout. OpenID Connect clients get their
back-channel logout tokens, and the session’s other SAML
apps are signed out as the next section describes.
When a person signs out of masks
Section titled “When a person signs out of masks”Each app with a single logout URL that the session signed in to gets one LogoutRequest. It names
the NameID and SessionIndex from that app’s assertion.
| How the session ends | How the apps hear |
|---|---|
Sign out, or an app’s LogoutRequest from the browser holding the session |
The browser visits each app in turn. Then it goes where the logout was going, or back to the app that asked. |
| Any other way, such as a manager signing the actor out, the actor being suspended, or the session timing out | masks posts the LogoutRequest to each app from the server. A 2xx or 3xx answer counts as delivered. masks tries up to five times, then records a failed delivery as an event. |
A delivery from the server reaches an app without the actor’s browser. So it ends only sessions the
app can find by NameID or SessionIndex.
Provisioning
Section titled “Provisioning”Provisioning means a directory adds, changes, and removes actors in masks for you. A directory such as Entra ID, Okta, Google Workspace, or JumpCloud does this over SCIM 2.0 (RFC 7643, RFC 7644).
Each tenant’s base URL is its issuer followed by /scim/v2:
https://demo.masks.example/scim/v2Connecting a directory
Section titled “Connecting a directory”- In
/manage, open Settings, then Directory. - Under Provisioning, enter a label, such as the directory’s name.
- If the tenant has organizations, choose Every actor, or Only members of one organization.
- Choose how long the token lives: 30 days, 90 days, or A year. The default is 90 days.
- Choose Issue a token, and copy it. masks shows it once.
- In the directory, enter the SCIM base URL, and enter the token as a bearer token. A bearer token is a secret that grants access to whoever sends it.
Issuing a token needs masks:manage:security or masks:manage. Only masks:manage can issue one
for every actor, because that token reaches managers too. See
limits on the narrower roles.
Each token shows who issued it, when it was last used, and when it expires. Revoke refuses it from then on.
A client can also provision. The client must:
- be allowed
masks:scim - request its own token with
client_credentials - name the base URL as its
resource
What is provisioned
Section titled “What is provisioned”/Users supports reads, filters, creation, PUT, PATCH, and deletion.
| SCIM | masks |
|---|---|
id |
The actor’s uuid. |
userName |
The nickname, or the email address when it is an email address. |
externalId |
Stored and filterable. It is unique in the tenant, or in the organization for a directory for one organization. |
name, displayName |
The name claims. |
emails |
The primary email address, treated as confirmed. |
phoneNumbers, photos, profileUrl, locale, timezone |
The matching claims. |
active |
Whether the actor is suspended. |
password |
Set, if the directory sends one. |
A provisioned actor holds the standard scopes. They have no password unless the directory sent one. They sign in through a provider that trusts the same email address, or by accepting an invitation.
- Filters join up to four comparisons with
and.externalIdcompares exactly. - A user’s
meta.versionis a weakETag. APUTorPATCHwhoseIf-Matchnames an older version is refused with412. /ServiceProviderConfig,/ResourceTypes, and/Schemasdescribe the rest./Groupsanswers only a directory for one organization.- Bulk operations and sorting are not supported.
active: false suspends an actor, the same as suspending them in /manage. See
suspending and deleting. active: true restores the
actor. DELETE removes them.
A provisioning token changes many accounts. So it cannot:
- set the password or email address of anyone holding a
masks:scope - suspend or delete the last active holder of
masks:manage - change anyone’s scopes
Every change is recorded in the actor’s activity, marked as SCIM.
A directory for one organization
Section titled “A directory for one organization”A provisioning token can belong to one organization. Then a customer’s directory manages that customer’s actors and nobody else.
| Request | What happens |
|---|---|
| List or read users | Only the organization’s members. Anyone else is not found. |
| Create a user | A new actor that joins as member. Its email address must be at a proven domain that sends actors to one of the organization’s providers, and is then treated as confirmed. Any other email address is refused with 400. A user without an email address is allowed. |
| Replace or patch a user | Allowed only for an actor this directory created who belongs to no other organization and manages nothing. Anyone else is refused with 403. |
| Delete a user | Removes them from the organization and revokes its tokens. The actor stays. |
Each organization’s directory keeps its own externalId for each member, so two organizations’
directories can use the same value. An actor’s Access tab in /manage shows them under
Provisioned.
A userName, email address, or externalId that is already taken is refused with 409. The answer
is the same every time, so it does not say who holds the value or where.
Roles as groups
Section titled “Roles as groups”A directory for one organization manages roles through /Groups. Each of the organization’s roles
is one group.
- Its
displayNameis the role. - Its
idis the organization’s uuid and the role, joined by a dot. - Its members are the actors who have accepted that role.
| Request | What happens |
|---|---|
| List or read groups | Every role, owner and member included. Filter with displayName eq or id eq. |
| Add a member | Gives them that role in place of the one they held. |
| Remove a member | Moves them back to member. They stay in the organization. |
| Replace members | Adds everyone named and moves everyone else back to member. Actors this directory did not create keep their role. |
| Create a group | Adds a role with that name. An existing role is a conflict. |
| Delete a group | Removes the role once nobody holds it. owner and member cannot be deleted. |
| Rename a group | Refused. |
A group takes only actors this directory created who belong to no other organization and manage nothing.
- Adding anyone else is refused with
400, and removing them with403. The answer is the same whether or not the account exists. - Removing the last owner is refused with
409. - A role change revokes the actor’s access tokens for the organization. It is recorded in the organization’s activity, marked as SCIM.
A token for every actor lists no groups and cannot change them.