Sovrain
  1. Documentation
  2. Identity provider

Explanation

OpenID Connect and SAML

How the two sign-in protocols differ in Sovrain - where sign-in starts, keys, what the application learns, sessions and sign-out - and which one to choose when an application offers both.

Sovrain signs people in to applications with two protocols, OpenID Connect and SAML 2.0. Both end in the same place: the application learns who the person is from a statement Sovrain signed. The same groups decide who may sign in, the same two-step rules apply, and delegation works with both. What differs is how the two protocols carry that statement, and the differences show up later: when keys change, when someone signs out, when an admin suspends an account. Many applications offer both, and the choice is made once, because an OpenID Connect application in Sovrain cannot be switched to another type.

Two generations of the same idea

SAML is the older protocol. It is built on signed XML documents that travel through the person’s browser: the application sends a request, Sovrain answers with an assertion that the browser posts back to the application. It assumes a browser at every step, and enterprise software has supported it for a long time.

OpenID Connect is built on OAuth 2.0 and JSON tokens. The browser carries only a short-lived code; the application exchanges it for tokens directly with Sovrain. Because part of the conversation happens server to server, OpenID Connect can do things SAML cannot, such as renewing tokens without the browser or being told about a sign-out when no browser is involved. It also suits applications that run in the browser or on a phone, which cannot keep a secret: they prove themselves with PKCE instead.

Where sign-in starts

An OpenID Connect sign-in always starts at the application. The application sends the person to Sovrain and gets them back at an address registered in advance. That is why an OpenID Connect application has no tile on the Sovrain home page until an admin gives it a launcher address: the tile only opens the application, which then asks Sovrain.

SAML allows a second way. Besides sign-ins that start at the application, Sovrain can sign people in straight from their home page and post an assertion the application never asked for. This is convenient, but an unsolicited assertion cannot be matched to a request the application made, so the application has less to check. In Sovrain it is off for every new SAML application until an admin turns on Allow IdP-initiated SSO.

Keys and trust

All OpenID Connect applications of an organization share one set of signing keys, and Sovrain publishes the public keys at a fixed address. Applications fetch them from there, so when an admin stages a new key and later promotes it, most applications follow on their own.

Each SAML application has its own keys, with a certificate the application was given when it was connected. A SAML application usually trusts exactly that certificate, so a key change needs the application’s side too: it must learn the new certificate, from Sovrain’s metadata or by hand, before Sovrain signs with the new key. In return, a problem with one SAML application’s key touches only that application, and each one can use the algorithm it supports, RSA or ECDSA. OpenID Connect tokens are always signed with RS256.

Trust runs the other way as well. An OpenID Connect application proves itself with a client secret or PKCE. A SAML application proves itself by signing its requests, which Sovrain requires by default, so a SAML application is not ready until Sovrain has its certificate.

What the application learns

In OpenID Connect, the application identifies the person by sub, an id that never changes and is the same in every application of the organization. Other claims come in groups called scopes: a name with profile, a verified email with email, and with groups both the person’s groups that give access to this application and the roles those groups carry.

In SAML, the application identifies the person by the NameID, whose value an admin picks: by default the verified email address, which changes if the person’s address changes. Everything else is sent only when an admin maps it, except role, and actor on delegated sign-ins. There is no list of groups in SAML assertions, so a SAML application that needs to tell groups apart gets a role per group instead.

SAML can also encrypt the assertion for the application. OpenID Connect tokens in Sovrain are signed but never encrypted.

Sessions and sign-out

A SAML assertion is a one-time statement. Once the application has accepted it, the application decides how long its own session lasts, and Sovrain says nothing about it.

OpenID Connect can keep a connection open. An application allowed to receive refresh tokens can renew its tokens without sending the person back, and each renewal checks again whether the person may still use it. The refresh token ends with the person’s Sovrain session.

The biggest practical difference is sign-out. An OpenID Connect application with back-channel logout is told server to server when a Sovrain session ends, including when an admin suspends someone or a delegation ends. SAML Single Logout travels through the browser, so it works only when the person signs out through Sovrain, and a sign-out started by one SAML application does not reach the other SAML applications. Sessions and sign-out explains where each channel stops.

Two-step sign-in and delegation

Both protocols tell the application whether a second step happened, and both let the application ask for one. In OpenID Connect the ID token lists the methods in amr. In SAML the signal is a single class in the assertion, and since service providers expect different values, an admin chooses per application which class Sovrain sends.

A delegated sign-in looks like the owner’s own in both. When the delegation policy says so, an OpenID Connect application also receives act with the id of the person acting, and a SAML application receives actor with their login name.

Provisioning

SCIM provisioning can be added only to SAML applications. An application that signs in with OpenID Connect and also needs accounts created ahead of time gets its provisioning from a separate application of the type Standalone SCIM (provisioning only).

Which one to choose

When an application offers both, OpenID Connect is usually the better default in Sovrain:

  • sign-out reaches it even when an admin acts, through back-channel logout;
  • key changes usually need nothing on the application’s side;
  • it gets a stable sub and, with the groups scope, its groups without extra setup;
  • it can stay signed in with refresh tokens and still lose access within the hour;
  • it works for single-page and mobile applications.

SAML is the better choice when the application’s SAML support is the more complete one, when you want accounts provisioned over SCIM on the same application, when the application wants encrypted assertions, or when people should be able to start from the Sovrain home page and land signed in.