# SAML and SCIM: not here, and why

Mote signs people in with any OpenID Connect provider by its issuer, and
gives each customer of a B2B product a connection of their own
([oauth.md](oauth.md#single-sign-on-for-each-customer)). It has no SAML and
no SCIM. This page is the design they would have and the reasons they are
not built, so that a product knows what it gives up. Back to the
[map](README.md).

## What a B2B product loses

- **The enterprises that only speak SAML.** Okta, Entra ID, Google
  Workspace, OneLogin, Ping, JumpCloud, Keycloak and Auth0 all speak OpenID
  Connect, and a customer on any of them is a connection by issuer. Some do
  not: ADFS set up long ago, Shibboleth at universities, a government's
  own, a vendor's IdP that never added OIDC. A procurement form that says
  "SAML 2.0 SSO" is answered "OIDC" and sometimes that is a no.
- **Provisioning and deprovisioning (SCIM 2.0).** Without it, a person who
  leaves the customer stops being able to sign in (their IdP refuses them)
  but their account here stays, with its sessions until they end, and its
  API keys. A product sells "when someone leaves, they lose access at once"
  with SCIM. Without it: sessions are 30 days, keys live until taken back.
  The program can narrow this (shorter sessions for SSO people, a nightly
  job that asks the IdP's own API, keys that end), but it is not the same.
- **IdP-initiated sign-in** (a tile in the customer's Okta dashboard). OIDC
  can do it with a third-party initiated login (`/auth/sso/<name>/start` is
  the address to give the tile), which most IdPs support; SAML's unsolicited
  responses are what some customers expect.

What OIDC by issuer covers: sign-in from every major IdP, the customer's
domains held to (an IdP vouches only for its own), the customer turning a
person off at their end (the next sign-in is refused), MFA as the IdP
enforces it, and none of SAML's XML.

## Why not SAML

The owner said earlier that SAML was not wanted, and the reasons stand:

- **It is XML signatures.** A SAML response is checked by XML-DSig over a
  canonicalized document (Exclusive C14N), which has been the source of
  more sign-in bypasses than anything else in this field: signature
  wrapping (the signed element and the element read are different ones),
  comments inside a NameID changing what is read, entity expansion,
  multiple assertions. Each SAML library has had several. Doing it right
  in Mote means an XML parser with no DTDs and no entities (the `cloud`
  work is adding one), C14N written out, and every one of those attacks as
  a test. It can be done; it is the largest and most dangerous piece of the
  whole identity surface, for the fewest customers.
- **Certificates and their rotation by hand.** Each customer's IdP signs
  with a certificate pasted in at setup, rotated by email.

## The design, if it is built

- `extensions/saml`, beside `sso.mote`: a connection is the IdP's metadata
  (its entity ID, its SSO address, its signing certificates:
  [`crypto.cert`](data.md#crypto) reads them), kept in a model as
  `OauthIssuer` is, its domains held to the same way.
- SP-initiated only at first: `GET /auth/saml/<name>/start` sends an
  `AuthnRequest` by redirect (deflated, signed when the IdP asks), with an
  ID kept as `OidcPending` keeps a state (ten minutes, once, the browser's
  cookie); `POST /auth/saml/<name>/acs` takes the response.
- The response is taken only when: exactly one assertion; it, or the whole
  response, is signed with one of the connection's certificates, by RSA-SHA256
  or ECDSA-SHA256 (no SHA-1); the signed element is the one read (by ID, and
  no other element of that ID anywhere); `InResponseTo` is the request kept;
  `Destination`, `Recipient` and `Audience` are this connection's;
  `NotBefore` and `NotOnOrAfter` hold with a minute's leeway; the NameID
  (an address, or the IdP's persistent ID as `sub`) is taken from the signed
  assertion only. No DTD, no entity, no comment read into a value; a cap on
  size and depth.
- Then whose account it is, by the same rules as every provider
  ([google.md](google.md#whose-account-it-is)): the persistent ID is the
  `sub`; an address is joined only within the connection's domains.

## SCIM, if it is built

- `extensions/scim`: `/scim/v2/Users` and `/scim/v2/Groups` for a
  connection, the IdP authenticating with a bearer token that is an
  [API key](jwt.md#api-keys) with the scope `scim`, one a connection.
- `POST /Users` makes an account (`auth.create`) linked to the connection;
  `PATCH active: false` and `DELETE` end its sessions everywhere
  (`auth.signOutAll`), take back its API keys and its grants, and mark it
  off so that sign-in refuses it; `GET` with SCIM's `filter=userName eq …`
  for the IdP to find whom it made. Groups as the program's own model, a
  `wants fn` for what membership means.
- What makes it worth doing is the one guarantee it gives: someone the
  customer turned off is out within a minute, sessions and keys too.
