Skip to Content
FeaturesSingle sign-on and SCIM

Single sign-on and SCIM

A company that uses your app can sign its people in through its own identity provider, such as Okta or Microsoft Entra ID, over SAML 2.0. The same connection can provision those people with SCIM 2.0, so someone the identity provider adds is added to the company’s organization and someone it removes stands there no longer. The company’s IT manager sets all of it up from inside your app, through the API or the SDK, using a role that lets them manage sign-in providers at their own organization.

SAML and SCIM are on every plan. Each SAML connection is one of your plan’s sign-in providers, wherever it sits: on the project, on an organization, or the workspace’s own connection for the console. SCIM rides on its connection and isn’t counted on its own.

Where a connection sits

A SAML connection is a sign-in provider of type SAML, and it belongs to one level as every provider does. On the project it is offered to everyone the project signs in. On an organization it is offered when that organization’s people sign in at its login domain, and the organizations beneath it take it unless they configure their own. A sibling organization keeps the project’s providers.

Managing the providers at a level takes signinproviders:write there, and reading them takes signinproviders:read. A role in your project’s user pool can give both, so you can make an “IT team” role and give it to one person at their organization: they manage that organization’s connection and reach no other. The key your app signs people in through has to hold the two permissions as well, because a key holds the most a person signed in through it can reach. Role permissions and key permissions list what each can give.

A request names its organization with X-Org-Id, which the SDK sends when the client is made with orgId. A person whose role does not give the permission there is refused, and the refusal names signinproviders:write.

Setting up a connection

The manager creates the connection with what their identity provider tells them about itself:

mutation { createSignInProvider(input: { key: "acme-okta" name: "Acme Okta" type: SAML config: { issuer: "http://www.okta.com/exk1abcd" sso_url: "https://acme.okta.com/app/acme_foir/exk1abcd/sso/saml" certificate: "-----BEGIN CERTIFICATE-----\nMIIDpDCC...\n-----END CERTIFICATE-----" } }) { id metadataUrl acsUrl } }
const foir = createFoirClient({ apiKey, orgId: 'org_acme' }); const connection = await foir.ns.project.createSignInProvider({ input: { key: 'acme-okta', name: 'Acme Okta', type: 'SAML', config: { issuer, sso_url: ssoUrl, certificate }, }, });
Config fieldWhat it is
issuerThe identity provider’s entity ID. Every subject it signs in is kept under it.
sso_urlIts single sign-on address, over https. Foir sends the sign-in request there by the redirect binding.
certificateIts signing certificate, in PEM or base64 DER. A response it did not sign is refused.
email_attributeOptional. The attribute that carries the person’s address. Without it Foir reads email, mail, emailaddress and the two standard claim names, then a NameID in email format.
domainsOptional. The email domains the connection serves, such as ["acme.com"]. See Sending people to their connection.
scim_group_rolesOptional. SCIM group names mapped to role keys. See Provisioning with SCIM.

The answer carries Foir’s side of the connection for the identity provider’s own setup. metadataUrl is the connection’s metadata, and it is also its entity ID (the audience), so most identity providers take it in one field. acsUrl is where the identity provider posts its response, by the HTTP-POST binding. The artifact binding is not supported.

The connection is a draft until it is released. Releasing it moves this one provider and nothing else at the organization:

mutation { publishSignInProvider(id: "ap_123") { released releaseId } }
const { released } = await foir.ns.project.publishSignInProvider({ id: connection.id });

signInProviders lists the providers at the request’s level: the organization’s own and those it takes from above. updateSignInProvider changes one of its own and deleteSignInProvider removes one. A provider that belongs to the project or to an organization above can only be changed there. To offer something else for the same key, create a provider with that key at the organization, which replaces the inherited one for it and everything beneath it.

query { signInProviders { id key type orgId published } }
const providers = await foir.ns.project.signInProviders();

A project’s connection in config and the CLI

A connection the project itself owns can be declared in your config like any other provider, and foir push writes it as a draft for the next release:

export default defineConfig({ authProviders: [ { key: 'staff-okta', name: 'Okta', type: 'SAML', config: { issuer, sso_url: ssoUrl, certificate }, }, ], });

From the terminal, foir auth-providers create --key staff-okta --name Okta --type SAML --file saml.json does the same with the config in a file. A push is the project’s, so an organization’s own connection is set up from inside your app as above.

Sending people to their connection

A connection can name the email domains it serves in domains. When somebody types an address at one of them on the hosted sign-in page, where the connection is offered, the page starts the connection’s sign-in instead of asking for a password or a code. Somebody new who would join with a code is sent to it the same way. The page asks Foir when the address is typed and again when the form is sent, and Foir decides from the sign-in’s own place. It reads nobody’s account, so the answer is the same whether or not the address belongs to anyone.

config: { issuer, sso_url: ssoUrl, certificate, domains: ['acme.com', 'acme.co.uk'] },

Write each domain in lower case, with an international name in its xn-- form. It has to be a domain an organization can hold: a public suffix such as com, co.uk or github.io is refused. The connection serves exactly the domains it names, so an address at eu.acme.com needs eu.acme.com in the list.

A domain is served by one connection at a place. A second connection of the project’s own, or of the same organization’s own, that names it is refused, and the refusal names the connection that serves it. An organization’s own connection may serve a domain the project’s connection also serves: at that organization’s sign-ins, and those beneath it, its own is used. A domain one organization names never sends anybody signing in at a sibling organization, and a domain one project names never reaches another project. An app that turns a connection off on its own login page is never sent to it.

Naming a domain proves nothing about who holds it, and does not need to: it only decides where your own login page sends people. Who a sign-in through the connection is stays as the next section describes, and an address is trusted only at a domain the organization has verified.

Who a sign-in is

A SAML sign-in names a subject at the identity provider, and Foir keeps that subject as one of the person’s sign-in methods. The same subject signs the same person in every time.

The first time a subject arrives, its address decides who it is. If the organization has verified the address’s domain, the connection may vouch for it, and the sign-in connects to the person who holds that address. At any other domain the person proves the address with a one-time code before the subject is connected to them. An address nobody holds makes a new person under the project’s sign-up policy.

Provisioning with SCIM

Every connection serves SCIM 2.0, for identity providers that push people rather than wait for them to sign in. An organization’s connection provisions the organization’s members, the project’s provisions the project’s users, and a workspace’s provisions its staff. The manager makes the bearer the identity provider’s SCIM client presents:

mutation { makeSCIMToken(providerId: "ap_123") { token baseUrl } }
const { token, baseUrl } = await foir.ns.project.makeSCIMToken({ providerId: connection.id });

The token is shown once, and making a new one replaces the old. Paste baseUrl and token into the identity provider’s SCIM settings.

What a user the identity provider creates becomes depends on whether their address is new to the place’s sign-in, as with WorkOS’s directory provisioning:

  • An address nobody signs in with yet is a new user, made at the connection’s place. The identity provider keeps their name.
  • An address at a domain the place has verified itself (the organization’s own, or the project’s own for the project’s connection) belongs to somebody who is the place’s own. They stand there at once, and the identity provider keeps their name.
  • Anybody else who already signs in there is somebody else’s too, so they are invited, and stand at the place only once they accept. Their name stays their own. A group’s role given while they are still invited is kept on the invitation, and is theirs when they accept. A workspace verifies no domains, so a workspace’s connection invites everybody who already has a console account.

One the identity provider deactivates or deletes stands there no longer, or is invited no longer. Reactivated, they are somebody who already signs in, so they are invited back unless their address is at the place’s own domain. Users can be filtered by userName or by their address, as identity providers do before they create anyone, and somebody invited is listed as provisioned.

Groups give roles. Map each group name to a role key in the connection’s scim_group_roles:

{ "scim_group_roles": { "Engineers": "engineer", "Finance": "finance" } }

A member of a mapped group holds that role at the place, and removing them from the group takes it away. A group with no mapping gives nothing. A person holds one role at a place, so someone in two mapped groups holds the one given last.

Mapping a group is giving its role, so whoever sets scim_group_roles has to hold everything each mapped role gives. At an organization the role must also be one the project has made assignable inside an organization, unless the person mapping it is one of your team in the console. A mapping that breaks either rule is refused when the connection is saved, and the refusal names what is missing.

Your workspace’s staff

A workspace can sign its own staff into the console the same way. In the account console, open the workspace and go to Sign-in, on its Single sign-on tab, then add a connection with your identity provider’s entity ID, single sign-on URL and signing certificate. The connection’s screen gives Foir’s metadata and response addresses for your identity provider, and the sign-in link staff open:

https://auth.foir.io/login?provider=sso:<connection id>

Add the link to your identity provider as the app’s start URL. A workspace’s connection is a sign-in provider like a project’s: the same calls read and write it, made standing at the workspace with no project named, and managing it takes signinproviders:write given at the workspace. A workspace manager holds that, and so does an admin key made at the workspace. A role given in one project manages that project’s providers and not the workspace’s. Unlike a project’s, a workspace’s connection is live when it is saved: a workspace has no release. A person who already has a console account is connected after a one-time code the first time they sign in through the connection, and their subject signs them in from then on.

A workspace’s connection can name the email domains it serves as well, on the same screen. Somebody who opens one of the workspace’s sign-in links and types an address another of its connections serves is sent to that connection. A domain is served by one of the workspace’s connections.

The same screen makes the connection’s SCIM token, and its groups map to the workspace’s own roles. A role given this way takes a seat on your plan, as giving one in the console does. SCIM never takes away the last person who manages the workspace: removing them, or their role, is refused until somebody else holds one that does.

Last updated on