# Single sign-on (SSO) for organizations

Source: https://docs.formance.com/manage/identity/sso

Stack: v3.2

You can enable SSO on a per-organization basis using your existing identity provider. Supported providers are OIDC, Microsoft Entra ID (formerly Azure AD), Google, and GitHub.

## Prerequisites

- A Formance Cloud organization and access to `fctl`
- A client application created in your identity provider (Client ID and Client Secret)

When creating the app in your IdP, set the redirect URI to your membership endpoint callback: `<membership_uri>/api/authorize/callback`. See step 1 to determine your membership URI.

## Determine your membership URI

Use the same membership URI you pass to `fctl login`.

```bash
fctl login --membership-uri https://membership.BASE_URL/api
```

The SSO redirect URI to register in your IdP is therefore:

```text
https://membership.BASE_URL/api/authorize/callback
```

After you create the SSO configuration, the exact redirect URI is also displayed in the UI.

## Configure the authentication provider

The command format is:

```text
fctl cloud organizations authentication-provider configure <type> <name> <client-id> <client-secret> \
  [--oidc-issuer <issuer-url>] [--microsoft-tenant <tenant-id-or-domain>]
```

- **type**: one of `oidc`, `microsoft`, `github`, `google`
- **name**: human-friendly provider name shown to users
- **client-id / client-secret**: values from your IdP app
- **--oidc-issuer**: required for `oidc` (e.g., `https://accounts.example.com`)
- **--microsoft-tenant**: required for `microsoft` (tenant ID or verified domain)

OIDC

```bash
fctl cloud organizations authentication-provider configure \
  oidc "My OIDC" "<client-id>" "<client-secret>" \
  --oidc-issuer https://accounts.example.com
```

Microsoft

```bash
fctl cloud organizations authentication-provider configure \
  microsoft "My Entra" "<client-id>" "<client-secret>" \
  --microsoft-tenant "<tenant-id-or-domain>"
```

Google

```bash
fctl cloud organizations authentication-provider configure \
  google "Google" "<client-id>" "<client-secret>"
```

GitHub

```bash
fctl cloud organizations authentication-provider configure \
  github "GitHub" "<client-id>" "<client-secret>"
```

### Microsoft Entra ID

To configure Microsoft Entra ID as your identity provider, use the `oidc` type with the Microsoft issuer URL.

The `--oidc-issuer` must follow this format:

```text
https://login.microsoftonline.com/<tenant-id>/v2.0
```

Replace `<tenant-id>` with your Entra tenant ID.

```bash
fctl cloud organizations authentication-provider configure \
  oidc "msentra" "<client-id>" "<client-secret>" \
  --oidc-issuer "https://login.microsoftonline.com/<tenant-id>/v2.0"
```

Users must have an email address configured on their Entra identity to sign in via SSO.

Ensure the redirect URI in your IdP exactly matches `<membership_uri>/api/authorize/callback`. Mismatches (scheme, host, path, or trailing slash) will cause sign-in failures.

## Verify SSO

Sign in via SSO

From the Formance Cloud portal, choose the newly configured provider and complete the sign-in flow.

You should land back in the portal authenticated to your organization. If not, confirm the redirect URI and client credentials in your IdP. Do not change the issuer, client ID or provider type to troubleshoot: see [Change the identity provider](#change-the-identity-provider).

Check the new member

The first SSO sign-in of a user creates an account in your organization. The user receives your organization's default role. Update the role if necessary. See [Access Control](https://docs.formance.com/v3.2/manage/identity/rbac).

## How SSO accounts work

An SSO provider authenticates users for its own organization only. The table shows the rules that apply.

| Situation                                                                  | Result                                                                                                                      |
| -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| A user signs in through your SSO for the first time                        | Formance creates an account that belongs to your organization and adds it as a member. No personal organization is created. |
| Your IdP sends an email address that a Formance Cloud account already uses | Formance creates a separate SSO account. The existing account is not linked, merged or changed.                             |
| Two SSO users have the same email address                                  | Formance keeps two separate accounts. Accounts are identified by their IdP subject, not by email.                           |
| A user's email changes in your IdP                                         | The user keeps the same account and memberships.                                                                            |
| Your IdP sends groups                                                      | Group mappings apply in your organization only.                                                                             |
| A user signs in with a Formance Cloud account                              | Platform sign-in still works. SSO is an additional sign-in method for your organization, not a replacement.                 |

Use the user ID, not the email address, to identify a user in API calls and integrations. An SSO account and a Formance Cloud account can show the same email address but have different IDs.

### Access to other organizations

An SSO session gives access to the organization that owns the SSO provider. It does not give access to other organizations, even when the user is a member of them. To use one SSO provider for several organizations, contact Formance support. The owner of each destination organization must approve the provider, and the user still needs a membership in that organization.

### Invitations

Your SSO provider does not accept invitations for its users. An invitation is accepted only when the invited user confirms it. See [Invite users](https://docs.formance.com/v3.2/manage/identity/inviting-team).

## Change the identity provider

These changes create a new provider identity:

- the provider type
- the client ID
- the OIDC issuer
- the Microsoft tenant

If users already signed in with the previous configuration, SSO sign-in stops for your organization. Formance must migrate the existing accounts before SSO works again. Formance does not create replacement accounts automatically.

Contact Formance support before you make one of these changes. Changing the provider name, the client secret or the group mappings does not need a migration.

## Sessions after the SSO update

After the update that introduced organization-scoped SSO accounts, some users must sign in again. API clients keep their credentials, but some access tokens obtained by token exchange before the update must be requested again.

## Reference

```bash
fctl cloud organizations authentication-provider configure -h
```

Command help

```text
Configure the authorization provider for the organization

Usage:
  fctl cloud organizations authentication-provider configure <type> <name> <client-id> <client-secret> [flags]

Flags:
  -h, --help                      help for configure
      --microsoft-tenant string   Microsoft tenant ID (used when type is 'microsoft') (default "tenant")
      --oidc-issuer string        OIDC issuer URL (used when type is 'oidc')

Global Flags:
  -c, --config string         Path to configuration file
  -d, --debug                 Enable debug mode
      --insecure-tls          Allow insecure TLS connections
      --organization string   Selected organization (not required if only one organization is present)
  -o, --output string         Output format (plain, json)
  -p, --profile string        Configuration profile to use
      --stack string          Specific stack (not required if only one stack is present)
      --telemetry             Enable telemetry
```
