# Authentication

Set up how users sign in to the Backend.

For an installation made with an installer, see [Install in cloud with installer](/install-cloud-installer/).

Users sign in (To show the Backend who you are, with a sign-in provider or a single-user token. The verb is "sign in"; the noun and the adjective are "sign-in".) with the accounts that they already have: you connect the Backend (The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs.) to the corporate identity provider or directory, and the Backend does not keep passwords of its own for them. You set one or more sign-in providers (A configured way for users to sign in to the Backend: single sign-on (SSO), LDAP or a static list of users. One Backend can have more than one.), and the Desktop App (The program that each user installs on their own computer to work with Platforma. It is a client of the Backend.) shows one sign-in button for each, in the order of the list. These are the sign-in providers, and the single-user token instead of them:

- [SSO](#sso): the corporate identity provider, with OpenID Connect.
- [LDAP](#ldap): the corporate LDAP (The directory of users of a company. The Backend can check logins and passwords in it.) directory.
- [Static list of users](#static-list-of-users): logins and passwords in a file.
- [Single-user token](#single-user-token): one user, for a test installation.

You can combine providers of all three kinds, for example SSO (Sign-in through the identity service of the company, with the same account as for other company systems.) for all users and a static list of users (A sign-in provider that is a file with the logins and the password hashes of the users, in the htpasswd format. The Backend reads it again when it changes.) with one emergency login. A provider that fails does not stop the other providers. For when the emergency login works, see [When a sign-in provider fails](/security-access-control/#when-a-sign-in-provider-fails). The single-user token cannot be combined with providers. Sign-in providers need a [master secret](/security-secrets/#master-secret).

For how each provider works, how long a session lasts and what each provider checks, see [Sign-in](/security-access-control/#sign-in).

## Sign-in providers

Each provider has:

- `name`: a unique ID, in lowercase letters, digits and `-`, at most 40 characters.
- `title`: the text on the sign-in button, and an optional `description` under it.
- exactly one group of settings: `sso`, `ldap` or `htpasswd`. It sets the kind of provider.
- the settings of all kinds: how the Backend identifies the user (`map`, `lookUpAttr`), whether it creates new users (`createUsers`), and the administrator rules (`adminUsers`, `roles`).

Sign-in providers need a master secret: at least 32 random bytes, base64-encoded. Without it, the Backend does not start. Keep a copy of it: see [Master secret](/security-secrets/#master-secret).

To change the master secret, put the new value where the Backend reads it (the Secret, or the file of `--master-secret-file`), then restart the Backend. All users sign in again. The Backend encrypts again the storage keys in its settings. A removed data library (A folder or bucket with input data of the company. Users select files from it in the Desktop App. Platforma only reads it.) with stored access keys gets the status “secret lost”: see [Master secret](/security-secrets/#master-secret).

#### Variant: Kubernetes cluster

Set the providers in `auth.providers` of the input `backend_service` of `platforma-tf-services`, or in `auth.providers` of the values of the chart `platforma-backend`. The two have the same fields: the Terraform input uses `snake_case` (`look_up_attr`), and the Helm values `camelCase` (`lookUpAttr`). For all fields, see [Chart values](/reference-chart-values/) and [Terraform modules](/reference-terraform-modules/).

Put the master secret in the Secret `platforma-master-secret` under the key `master-secret` before the install (Helm value `secrets.masterSecret`, Terraform input `backend_service.secrets.master_secret`):

```sh
kubectl create secret generic platforma-master-secret --namespace <namespace> \
  --from-literal=master-secret="$(openssl rand -base64 32)"
```

A secret of a provider (the SSO client secret, the LDAP bind password, the file of a static list of users) is a reference `{ name, key }` to a Kubernetes (A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster.) Secret in the namespace of the Backend. Create the Secret before the install: the modules and the chart do not create it. For the default keys, see [Secrets](/infrastructure-contract-names/#secrets). The chart refuses sign-in options in `extraArgs` and sign-in variables in `env`: use the `auth` settings.

#### Variant: Single Server

Give the master secret in a file named by `--master-secret-file` (`PL_MASTER_SECRET_FILE`) that only the system user of the Backend can read: MiLaboratories recommends this way. The environment variable `PL_MASTER_SECRET` also works.

Declare each provider with `--auth.provider-id=<id>` and `--auth.provider-type=<id>=<type>` (`sso`, `ldap` or `htpasswd`). All other options of the provider start with `--auth.` and take the ID of the provider first: `--auth.title=<id>=<text>`. Each option has an environment variable, for example `PL_AUTH_TITLE` for `--auth.title`. For the full list, see [Backend options](/reference-backend-options/).

Give secrets in environment variables of the Backend service or in files, not on the command line: other users of the server can see the command line in the list of processes.

## SSO

With SSO, users sign in at the corporate identity provider with OpenID Connect, so the company keeps one place to manage accounts, passwords and multi-factor checks. For the sign-in flow and its tokens, see [SSO](/security-access-control/#sso).

At the identity provider, register a client (an application) for Platforma: see [What to register at the identity provider](/configuration-authentication/#what-to-register-at-the-identity-provider).

The Backend reads the discovery document of the identity provider (`<issuer>/.well-known/openid-configuration`) at start. If it cannot read it, the Backend does not start, so the Backend needs HTTPS access to the identity provider.

| Setting         | What it does                                                                                                                                               | Default                               |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| `issuer`        | The issuer URL of the identity provider                                                                                                                    | Required                              |
| `clientID`      | The client ID                                                                                                                                              | Required                              |
| `clientSecret`  | The client secret that the identity provider gives to a public client, for example Google. Not for a confidential client: see the caution after this table | Not set                               |
| `scopes`        | The scopes, separated by spaces                                                                                                                            | `openid profile email offline_access` |
| `redirectPorts` | The local ports of the redirect URI                                                                                                                        | `8765`                                |
| `prompt`        | The `prompt` of the sign-in request: `none`, `login`, `consent` or `select_account`                                                                        | `login`                               |
| `accessType`    | `online` or `offline`. Google needs `offline`                                                                                                              | Not set                               |
| `resource`      | The audience of the access token (RFC 8707), for identity providers that need it                                                                           | Not set                               |
| `jwtAlgorithms` | The signing algorithms of tokens that the Backend accepts                                                                                                  | RS256, ES256, ES384                   |

Platforma supports only the public client flow: the authorization code flow with PKCE. It does not support a confidential client.

> **The client secret of a public client is not a secret:**
>
> Google requires a client secret from every client, also from a public client. For a public client, this value is not a secret and can be published: the public client flow works so. Thus the Backend gives the value of `clientSecret` to any client that starts an SSO sign-in, also to a client that has not signed in. Set `clientSecret` only to the value that the identity provider gives to a public client, and never to the secret of a confidential client.

For a data library with federated access, the token that the Backend gives to the cloud is a setting of the library, not of the provider: see [Federated user access](/configuration-data-libraries/#federated-user-access).

By default, the login of an SSO user is the value of the claim `sub`, which is an opaque ID. Other users see this login when they share projects. MiLaboratories recommends that you map the login to a readable claim that does not change, for example the email address (`map.login: email`). Choose it before users sign in for the first time: a change later gives users new accounts (see [How the Backend finds the account of a user](/configuration-authentication/#how-the-backend-finds-the-account-of-a-user)).

**Microsoft Entra ID:**

Microsoft Entra ID does not send the claim `email_verified`, so the example takes the login from `preferred_username`, usually the user principal name, and not from `email`.

#### Variant: Kubernetes cluster

*terraform.tfvars*

```hcl
backend_service = {
  auth = {
    providers = [
      {
        name  = "entra"
        title = "Company account"
        sso = {
          issuer        = "https://login.microsoftonline.com/<tenant-id>/v2.0"
          client_id     = "<client-id>"
        }
        map = { login = "preferred_username", email = "email" }
      },
    ]
  }
}
```

*values.yaml*

```yaml
auth:
  providers:
    - name: entra
      title: Company account
      sso:
        issuer: https://login.microsoftonline.com/<tenant-id>/v2.0
        clientID: <client-id>
      map: { login: preferred_username, email: email }
```

#### Variant: Single Server

*Options of the Backend*

```sh
--auth.provider-id=entra \
--auth.provider-type=entra=sso \
--auth.title=entra='Company account' \
--auth.sso.issuer=entra=https://login.microsoftonline.com/<tenant-id>/v2.0 \
--auth.sso.client-id=entra=<client-id> \
--auth.map.login=entra=preferred_username \
--auth.map.email=entra=email
```

**Google Workspace.** Google tokens do not have the groups of the user. To give roles by Google groups, turn on `google.groupFetch` for the provider. At each sign-in, the Backend then asks Google (the Cloud Identity (The identity that the cloud gives to the Platforma pod (IAM roles for service accounts on AWS, Workload Identity on Google Cloud). With it, Platforma needs no access keys.) Groups API) whether the user is a member of the groups that the role rules name, with the access token of the user. The Backend adds the scope `https://www.googleapis.com/auth/cloud-identity.groups.readonly` to the sign-in request for this. Each call waits up to `apiTimeout` (default 5 seconds) and is repeated up to `apiRetries` times (default 2). For the role rules, see [Users and roles](/configuration-users-and-roles/).

For a data library in the Google account mode, add a Cloud Storage scope to `scopes`, for example `https://www.googleapis.com/auth/devstorage.read_only` (the smallest one), and set `accessType: offline`. Without them, the Backend does not start. After you add the scope, all users of this provider sign in again. For the library, see [Google account of the user](/configuration-data-libraries/#google-account-of-the-user).

### What to register at the identity provider

Give this list to the team that manages the corporate identity provider. The Desktop App signs the user in through the browser with OpenID Connect: the authorization code flow with PKCE. Then the Backend checks the ID token and keeps the tokens of the user for the session.

Register one client (an application) with these settings:

| Setting                           | Value                                                                                                                                                                                                                                                                                                      |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Kind of client                    | A native (desktop) application: a public client with PKCE (method `S256`). Platforma supports only the public client flow, not a confidential client. Google gives a client secret also to a public client: then give it to the Backend in `clientSecret` (see [SSO](/configuration-authentication/#sso)). |
| Grant types                       | Authorization code and refresh token.                                                                                                                                                                                                                                                                      |
| Redirect URIs                     | `http://127.0.0.1:8765/callback`. Write the address `127.0.0.1`, not `localhost`. For each other port in `redirectPorts`, add the same URI with that port.                                                                                                                                                 |
| Scopes                            | `openid`, `profile`, `email` and `offline_access`, or the list in `scopes`, which must contain `openid`. When the identity provider puts the groups into the token only for a scope, add it: for example, `groups` for Okta.                                                                               |
| Refresh token                     | Necessary. When the answer of the identity provider does not have a refresh token, the sign-in fails. Google gives one only with `accessType: offline`.                                                                                                                                                    |
| Signing algorithm of the ID token | RS256, ES256 or ES384 (`jwtAlgorithms`).                                                                                                                                                                                                                                                                   |

The Backend reads these claims of the ID token:

| Claim                                                                 | What the Backend does with it                                                                                                                                                           |
| --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sub`                                                                 | The ID of the user at the identity provider. It is the login when `map.login` is not set.                                                                                               |
| `nonce`                                                               | Checks that the token answers a sign-in request of this Backend.                                                                                                                        |
| The claim of `map.login`, for example `email` or `preferred_username` | Makes it the login of the user.                                                                                                                                                         |
| The claims of `map.email`, `map.displayName` and `map.fullName`       | Fills the email address and the names of the account.                                                                                                                                   |
| `email_verified`                                                      | Only a verified email address finds an existing account: see [How the Backend finds the account of a user](/configuration-authentication/#how-the-backend-finds-the-account-of-a-user). |
| The claim of `map.groups`, for example `groups`                       | Gives the groups to the [role rules](/configuration-users-and-roles/#by-group). Without `map.groups`, the Backend does not read groups from the token.                                  |

The role rules compare the values of the groups claim exactly as the token has them. Microsoft Entra ID puts the object IDs of the groups into this claim, not their names: write these IDs in the rules. Google tokens do not have groups: see [SSO](/configuration-authentication/#sso).

The network must let these connections through:

- The computers of users reach the identity provider over HTTPS. The Desktop App reads the discovery document and gets the tokens from the token endpoint itself.
- The Backend reaches the identity provider over HTTPS: for the discovery document at start, for the keys that sign the tokens, and to renew the tokens.
- On the computers of users, the Desktop App gets the answer on `127.0.0.1`, on the first free port of `redirectPorts`. Endpoint security software must let it listen on this port.

From the identity team, you get the issuer URL, the client ID, the client secret when the identity provider gives one to a public client (Google), and the group values for the administrators.

## LDAP

With LDAP, users sign in with the login and the password of the corporate directory. The Backend checks them in one of two modes:

- **Direct bind.** The Backend puts the login into a DN template (`userDN`, `%u` is the login) and binds with the password of the user. It does not need a service account, but it cannot read the email address of the user. The Backend does not check the user at renewal.
- **Search mode.** The Backend binds with a service account (`bindDN`, `bindPassword`), finds the user with a filter (`baseDN`, `userFilter`), and then binds as the user. Use this mode when you can: it reads the email and other attributes, and it refuses to renew the session of a removed user.

For what each mode checks, see [LDAP](/security-access-control/#ldap).

| Setting                  | What it does                                                                                                         |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------- |
| `url`                    | `ldaps://host:636`, or `ldap://host:389` with `startTLS: true`                                                       |
| `userDN`                 | Direct bind: the DN template, for example `uid=%u,ou=people,dc=example,dc=com`                                       |
| `bindDN`, `bindPassword` | Search mode: the service account and its password                                                                    |
| `baseDN`, `userFilter`   | Search mode: where to search, and the filter, for example `(uid=%u)`                                                 |
| `searchRules`            | Search mode: more searches after the first one, each `<filter>\|<baseDN>`                                            |
| `groupBaseDN`            | Search mode: also search for groups that list the user as `member`, for a directory without `memberOf`               |
| `startTLS`               | Use StartTLS on an `ldap://` connection                                                                              |
| `trustedCA`              | The CA certificates (PEM) that the Backend trusts for this directory. They replace the system CAs for this directory |
| `clientCert`             | A client certificate and its key, for a directory that checks the client                                             |
| `insecureTLS`            | Do not check the certificate of the directory. Only for a test installation                                          |

Use `ldaps://` or StartTLS: without TLS, the passwords go over the network in clear text.

In Kubernetes, the Helm chart gives the bind password of each LDAP provider to the Backend as a file from its Secret. Each provider can have its own bind password: there is no limit on the number of providers.

**Search mode with ldaps:**

#### Variant: Kubernetes cluster

```sh
kubectl create secret generic platforma-ldap --namespace <namespace> \
  --from-literal=bind-password=<service-account-password>
```

*terraform.tfvars*

```hcl
backend_service = {
  auth = {
    providers = [
      {
        name  = "corp"
        title = "Company directory"
        ldap = {
          url           = "ldaps://ldap.example.com:636"
          bind_dn       = "cn=platforma,ou=services,dc=example,dc=com"
          bind_password = { name = "platforma-ldap", key = "bind-password" }
          base_dn       = "ou=people,dc=example,dc=com"
          user_filter   = "(uid=%u)"
        }
        map = { email = "mail" }
      },
    ]
  }
}
```

*values.yaml*

```yaml
auth:
  providers:
    - name: corp
      title: Company directory
      ldap:
        url: ldaps://ldap.example.com:636
        bindDN: cn=platforma,ou=services,dc=example,dc=com
        bindPassword: { name: platforma-ldap, key: bind-password }
        baseDN: ou=people,dc=example,dc=com
        userFilter: (uid=%u)
      map: { email: mail }
```

#### Variant: Single Server

*Options of the Backend*

```sh
--auth.provider-id=corp \
--auth.provider-type=corp=ldap \
--auth.title=corp='Company directory' \
--auth.ldap.url=corp=ldaps://ldap.example.com:636 \
--auth.ldap.bind-dn=corp=cn=platforma,ou=services,dc=example,dc=com \
--auth.ldap.base-dn=corp=ou=people,dc=example,dc=com \
--auth.ldap.user-filter='corp=(uid=%u)' \
--auth.ldap.bind-password-file=corp=/etc/platforma/ldap-corp-password \
--auth.map.email=corp=mail
```

The file `/etc/platforma/ldap-corp-password` holds only the password of the service account, and only the system user of the Backend can read it. The Backend removes the spaces and line ends around the value. Each provider can have its own file.

## Static list of users

A static list of users is a file with logins and password hashes, in the format of the `htpasswd` tool. It does not need any outside service, so it fits a small installation, a test, and an emergency login next to SSO or LDAP: see [When a sign-in provider fails](/security-access-control/#when-a-sign-in-provider-fails). For the security view, see [Static list of users](/security-access-control/#static-list-of-users).

Make the file with bcrypt hashes. The Backend also accepts the weaker formats of the tool, but MiLaboratories recommends bcrypt:

```sh
htpasswd -cB users.htpasswd alice   # makes the file; asks for the password
htpasswd -B users.htpasswd bob      # adds a user
```

Each login in the file can sign in, and the Backend creates its account at the first sign-in. When the file changes, the Backend reads it again without a restart.

#### Variant: Kubernetes cluster

Put the file in a Secret under the key `htpasswd`:

```sh
kubectl create secret generic platforma-users --namespace <namespace> \
  --from-file=htpasswd=users.htpasswd
```

*terraform.tfvars*

```hcl
backend_service = {
  auth = {
    providers = [
      {
        name     = "local"
        title    = "Local password"
        htpasswd = { secret = { name = "platforma-users", key = "htpasswd" } }
      },
    ]
  }
}
```

*values.yaml*

```yaml
auth:
  providers:
    - name: local
      title: Local password
      htpasswd:
        secret: { name: platforma-users, key: htpasswd }
```

To change the list, replace the Secret with the new file. Kubernetes updates the file in the pod after a short time, usually within one or two minutes, and the Backend then reads it.

#### Variant: Single Server

*Options of the Backend*

```sh
--auth.provider-id=local \
--auth.provider-type=local=htpasswd \
--auth.title=local='Local password' \
--auth.htpasswd.file=local=/etc/platforma/users.htpasswd
```

Make the file readable only by the system user of the Backend.

## Single-user token

With a single-user token, one user connects with a token: there is no sign-in provider and no list of users. Use it for a test or a personal installation. The Backend makes its other keys from the token, so the installation does not need a master secret, and a new token has the same effect as a new master secret (see [Secrets](/security-secrets/#the-secrets-of-platforma)).

#### Variant: Kubernetes cluster

```sh
kubectl create secret generic platforma-single-user-token --namespace <namespace> \
  --from-literal=token="$(openssl rand -hex 32)"
```

*terraform.tfvars*

```hcl
backend_service = {
  auth = {
    single_user = {
      enabled = true
      token   = { name = "platforma-single-user-token", key = "token" }
    }
  }
}
```

*values.yaml*

```yaml
auth:
  singleUser:
    enabled: true
    token: { name: platforma-single-user-token, key: token }
```

#### Variant: Single Server

This is the default mode when no sign-in options are given. Give the token in the environment of the Backend service:

*Environment of the Backend service*

```sh
PL_AUTH_TOKEN=<token>
```

Without a token, the Backend makes a random one at the first start and keeps it in the file `token.htpasswd` in its main folder (`--main-root`), as `default:<token>`.

## How the Backend finds the account of a user

Each account in the Backend has a login, and it can have an email address, a display name and a full name. Projects belong to the account. At each sign-in, the Backend fills these fields from the provider, and finds the account with one of them:

- **`map`** names the claim (SSO) or the attribute (LDAP) for each field: `login`, `email`, `displayName`, `fullName`, and `groups` for the role rules. Without `map.login`, the login is the ID of the user at the identity provider (SSO) or the login that the user typed (LDAP and a static list).
- **`lookUpAttr`** is the first field that the Backend uses to find an existing account: `login` by default, or `email`. When it finds nothing, it tries the login, and then an email address that the identity provider marks as verified. The Backend looks in all accounts, not only in the accounts of this provider: the same login from two providers is the same account. A found account keeps its login.
- **`trustUnverifiedEmail`** (SSO, with `lookUpAttr: email`): by default, an email address finds an account only when the identity provider marks it as verified. Microsoft Entra ID does not send this mark; set `trustUnverifiedEmail: true` for such a provider.

Custom fields of users are possible too: declare them in `extensionFields` and fill them with `mapFields`.

> **Caution:**
>
> Choose `map.login` and `lookUpAttr` before users sign in for the first time. When the login or the look-up value of a user changes later, the Backend does not find the old account, unless the provider sends the verified email address of that account. Then the user gets a new, empty account, or cannot sign in. To move users from one sign-in provider to another, see [Migrate between sign-in providers](/maintain-migrating-sign-in-providers/).

## New users at the first sign-in

With a static list of users, the file is the list of users: each login in it gets an account at its first sign-in.

With SSO and LDAP, the identity provider or the directory can accept many more people than the users of Platforma. So by default (`createUsers: false`), the Backend refuses a user who does not have an account. You have two ways to let new users in:

- **`createUsers: true`** on the provider. Each person whom the identity provider or the directory accepts gets an account at the first sign-in. Then limit who can sign in at the identity provider (the users assigned to the application) or in the directory (the `userFilter` of search mode). When `lookUpAttr` is not `login`, the provider must also map that field, for example `map.email`; otherwise the Backend does not start.

- **Accounts made in advance.** The Backend can read a CSV file of users at each start (`--user-provisioning`) and create or update their accounts. This also works for SSO and LDAP users: use the default match attribute `login`, and write in the column `login` the login that the provider will give (after `map.login`). A row without a matching account makes a new account. At the first sign-in, the user gets this account when the CSV `login` is the login from the provider, or when the CSV `email` is an email address that the provider marks as verified. The account keeps the login from the CSV.

  The option is not covered by the chart values or the module inputs: give it in `extra_args` or `extraArgs`. In the Kubernetes cluster, keep the file in a bucket (`s3://` or `gcs://`). Give an S3 key in `env.secretVariables` (`env.secret_variables` in Terraform), not in `extraArgs`: the chart refuses it there. For the file and its rules, see [Mapping file](/maintain-migrating-sign-in-providers/#mapping-file).

#### Variant: Kubernetes cluster

*terraform.tfvars*

```hcl
# in the provider entry
create_users = true
```

*values.yaml*

```yaml
# in the provider entry
createUsers: true
```

#### Variant: Single Server

*Options of the Backend*

```sh
--auth.create-users=<provider-id>=true
```

## Change the sign-in settings

A change of the settings or the options restarts the Backend: in Kubernetes, the pod starts again; in Single Server mode (The mode in which the Backend and all its jobs run on one Linux machine, the server, with no Kubernetes cluster.), restart the service. For what a restart does, see [Restart of the Backend](/configuration-storage/#restart-of-the-backend). What else happens depends on the change:

| Change                                                                                                         | Result                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A provider is added, removed or renamed                                                                        | All sessions end, and all users sign in again. Projects stay. A new order of the same providers does not end sessions.                                                                                                                                                                                                                    |
| The client ID, the scopes or the access type of an SSO provider (also `google.groupFetch`, which adds a scope) | The users of this provider sign in again.                                                                                                                                                                                                                                                                                                 |
| `map.login` or `lookUpAttr`                                                                                    | Users whose login or look-up value changes get a new, empty account at the next sign-in, or cannot sign in without `createUsers`, unless the provider sends the verified email address of the old account. See [How the Backend finds the account of a user](/configuration-authentication/#how-the-backend-finds-the-account-of-a-user). |
| The file of a static list of users                                                                             | No restart. A removed login cannot sign in, and the Backend refuses to renew its session. The Desktop App continues to work with its current session for at most 7 days (see [Remove a user](/configuration-users-and-roles/#remove-a-user)).                                                                                             |
| The master secret                                                                                              | All sessions end at once (see [Change the master secret](/configuration-users-and-roles/#change-the-master-secret)).                                                                                                                                                                                                                      |
| Other settings (titles, role rules, LDAP connection)                                                           | Sessions stay. Role rules apply at the next sign-in.                                                                                                                                                                                                                                                                                      |

For a move from a static list of users to LDAP or SSO, see [Migrate between sign-in providers](/maintain-migrating-sign-in-providers/).

## Start the Backend while the identity provider is down

With SSO, the Backend reads the discovery document of the identity provider when it starts. When the identity provider is unreachable at this time, the Backend does not start, also when other sign-in providers are set. To start the Backend while the identity provider is down, remove the SSO provider from the sign-in providers. Then users sign in with the other providers, for example with an administrator login in a static list of users. The users of SSO cannot sign in until you add the SSO provider again.

Each change of the set of providers ends all sessions: after the removal and after the return of the SSO provider, all users sign in again. The accounts and the projects of the users stay. See [Change the sign-in settings](/configuration-authentication/#change-the-sign-in-settings).

#### Variant: AWS installer

The administrator login `platforma` is always in the sign-in providers of the installer. Its password is in Parameter Store: see the output `AdminPasswordSSMConsole` in [Outputs of the AWS stack](/reference-installer-parameters/#outputs-of-the-aws-stack).

1. Update the stack with the current template, as in [Change settings](/maintain-updating-cloud-installer/#change-settings). Clear only the parameters that turn on the SSO provider: `GoogleClientId` for Google, or `EntraIssuer`, `EntraTenantId` and `EntraClientId` for Microsoft Entra ID. Keep `GoogleClientSecret`. Result: the status of the stack is `UPDATE_COMPLETE`, and the Backend runs.
2. Sign in with the login `platforma`.
3. When the identity provider is reachable again, update the stack again with the values of the parameters that you cleared.

#### Variant: Google Cloud installer

The administrator login `platforma` is always in the sign-in providers of the installer. Its password is in Secret Manager: see [What you get](/install-cloud-installer/#what-you-get).

1. Change the settings as in [Change settings](/maintain-updating-cloud-installer/#change-settings), with `export SSO_PROVIDER=none` in the file of the saved answers. Keep the other SSO variables in the file. Result: the installer shows `Done.`, and the Backend runs.
2. Sign in with the login `platforma`.
3. When the identity provider is reachable again, set `SSO_PROVIDER` back to its value, and run `bash install.sh` again.

#### Variant: Terraform modules

1. In `terraform.tfvars` of the root `services`, remove the entry of the SSO provider from `backend_service.auth.providers`. The list must keep at least one provider. When it does not have a static list of users with an administrator login, add one: see [Static list of users](/configuration-authentication/#static-list-of-users).

2. Apply the root:

   ```sh
   terraform plan -out=sso-off.tfplan
   terraform apply sso-off.tfplan
   ```

   Result: the Backend runs.

3. Sign in with the administrator login of the static list of users.

4. When the identity provider is reachable again, put the entry back, and apply the root again.

#### Variant: Helm chart

1. In the values file, remove the entry of the SSO provider from `auth.providers`. When the list does not have a static list of users with an administrator login, add one: see [Static list of users](/configuration-authentication/#static-list-of-users).

2. Upgrade the release with the same chart version and the changed values file:

   ```sh
   helm upgrade platforma oci://ghcr.io/milaboratory/platforma-install/platforma-backend \
     --version <chart-version> -n platforma -f values.yaml
   ```

   Result: the Backend runs.

3. Sign in with the administrator login of the static list of users.

4. When the identity provider is reachable again, put the entry back, and upgrade the release again.

#### Variant: Single Server

1. In `/etc/systemd/system/platforma.service`, remove all `--auth.` options of the SSO provider: the options with its ID, and its ID in `--auth.provider-id`. Also remove its `PL_AUTH_` variables from `/etc/platforma/platforma.env`, if there are any. When no static list of users with an administrator login is left, add one: see [Static list of users](/configuration-authentication/#static-list-of-users).

2. Start the Backend:

   ```sh
   sudo systemctl daemon-reload
   sudo systemctl restart platforma
   ```

   Result: `systemctl status platforma` shows `active (running)`.

3. Sign in with the administrator login of the static list of users.

4. When the identity provider is reachable again, put the options back, and restart the Backend again.

## Next

- [Users and roles](/configuration-users-and-roles/)

Source: https://docs.platforma.bio/configuration-authentication/
