Authentication
Set up how users sign in to the Backend.
For an installation made with an installer, see Install in cloud with installer.
Users sign insign 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". Glossary with the accounts that they already have: you connect the BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary 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 providerssign-in provider — 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. Glossary, and the Desktop AppDesktop App — The program that each user installs on their own computer to work with Platforma. It is a client of the Backend. Glossary 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: the corporate identity provider, with OpenID Connect.
- LDAP: the corporate LDAPLDAP — The directory of users of a company. The Backend can check logins and passwords in it. Glossary directory.
- Static list of users: logins and passwords in a file.
- Single-user token: one user, for a test installation.
You can combine providers of all three kinds, for example SSOsingle sign-on — Sign-in through the identity service of the company, with the same account as for other company systems. Glossary for all users and a static list of usersstatic 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. Glossary 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. The single-user token cannot be combined with providers. Sign-in providers need a master secret.
For how each provider works, how long a session lasts and what each provider checks, see 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 optionaldescriptionunder it.- exactly one group of settings:
sso,ldaporhtpasswd. 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.
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 librarydata library — A folder or bucket with input data of the company. Users select files from it in the Desktop App. Platforma only reads it. Glossary with stored access keys gets the status
“secret lost”: see Master secret.
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 and
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):
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 KubernetesKubernetes — A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster. Glossary 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. The chart refuses sign-in
options in extraArgs and sign-in variables in env: use the auth settings.
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.
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.
At the identity provider, register a client (an application) for Platforma: see 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.
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.
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).
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.
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" } }, ] }}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 }--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=emailGoogle 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 Identitycloud 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. Glossary 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.
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.
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). |
| 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. |
The claim of map.groups, for example groups |
Gives the groups to the role rules. 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.
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 ofredirectPorts. 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,%uis 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.
| 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.
kubectl create secret generic platforma-ldap --namespace <namespace> \ --from-literal=bind-password=<service-account-password>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" } }, ] }}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 }--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=mailThe 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. For the
security view, see Static list of users.
Make the file with bcrypt hashes. The Backend also accepts the weaker formats of the tool, but MiLaboratories recommends bcrypt:
htpasswd -cB users.htpasswd alice # makes the file; asks for the passwordhtpasswd -B users.htpasswd bob # adds a userEach 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.
Put the file in a Secret under the key htpasswd:
kubectl create secret generic platforma-users --namespace <namespace> \ --from-file=htpasswd=users.htpasswdbackend_service = { auth = { providers = [ { name = "local" title = "Local password" htpasswd = { secret = { name = "platforma-users", key = "htpasswd" } } }, ] }}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.
--auth.provider-id=local \--auth.provider-type=local=htpasswd \--auth.title=local='Local password' \--auth.htpasswd.file=local=/etc/platforma/users.htpasswdMake 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).
kubectl create secret generic platforma-single-user-token --namespace <namespace> \ --from-literal=token="$(openssl rand -hex 32)"backend_service = { auth = { single_user = { enabled = true token = { name = "platforma-single-user-token", key = "token" } } }}auth: singleUser: enabled: true token: { name: platforma-single-user-token, key: token }This is the default mode when no sign-in options are given. Give the token in the environment of the Backend service:
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:
mapnames the claim (SSO) or the attribute (LDAP) for each field:login,email,displayName,fullName, andgroupsfor the role rules. Withoutmap.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).lookUpAttris the first field that the Backend uses to find an existing account:loginby default, oremail. 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, withlookUpAttr: 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; settrustUnverifiedEmail: truefor such a provider.
Custom fields of users are possible too: declare them in extensionFields and fill them with
mapFields.
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: trueon 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 (theuserFilterof search mode). WhenlookUpAttris notlogin, the provider must also map that field, for examplemap.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 attributelogin, and write in the columnloginthe login that the provider will give (aftermap.login). A row without a matching account makes a new account. At the first sign-in, the user gets this account when the CSVloginis the login from the provider, or when the CSVemailis 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_argsorextraArgs. In the Kubernetes cluster, keep the file in a bucket (s3://orgcs://). Give an S3 key inenv.secretVariables(env.secret_variablesin Terraform), not inextraArgs: the chart refuses it there. For the file and its rules, see Mapping file.
# in the provider entrycreate_users = true# in the provider entrycreateUsers: true--auth.create-users=<provider-id>=trueChange the sign-in settings
A change of the settings or the options restarts the Backend: in Kubernetes, the pod starts again; in Single Server modeSingle Server mode — The mode in which the Backend and all its jobs run on one Linux machine, the server, with no Kubernetes cluster. Glossary, restart the service. For what a restart does, see 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. |
| 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). |
| The master secret | All sessions end at once (see 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.
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.
Tool: CloudFormation template
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.
- Update the stack with the current template, as in
Change settings. Clear only the
parameters that turn on the SSO provider:
GoogleClientIdfor Google, orEntraIssuer,EntraTenantIdandEntraClientIdfor Microsoft Entra ID. KeepGoogleClientSecret. Result: the status of the stack isUPDATE_COMPLETE, and the Backend runs. - Sign in with the login
platforma. - When the identity provider is reachable again, update the stack again with the values of the parameters that you cleared.
Tool: install.sh in Cloud Shell
The administrator login platforma is always in the sign-in providers of the installer. Its
password is in Secret Manager: see
What you get.
- Change the settings as in
Change settings, with
export SSO_PROVIDER=nonein the file of the saved answers. Keep the other SSO variables in the file. Result: the installer showsDone., and the Backend runs. - Sign in with the login
platforma. - When the identity provider is reachable again, set
SSO_PROVIDERback to its value, and runbash install.shagain.
Tool: platforma-tf-* modules (cloud and cloud-agnostic)
-
In
terraform.tfvarsof the rootservices, remove the entry of the SSO provider frombackend_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. -
Apply the root:
Terminal window terraform plan -out=sso-off.tfplanterraform apply sso-off.tfplanResult: the Backend runs.
-
Sign in with the administrator login of the static list of users.
-
When the identity provider is reachable again, put the entry back, and apply the root again.
Tool: platforma-backend
-
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. -
Upgrade the release with the same chart version and the changed values file:
Terminal window helm upgrade platforma oci://ghcr.io/milaboratory/platforma-install/platforma-backend \--version <chart-version> -n platforma -f values.yamlResult: the Backend runs.
-
Sign in with the administrator login of the static list of users.
-
When the identity provider is reachable again, put the entry back, and upgrade the release again.
Tool: platforma binary
-
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 itsPL_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. -
Start the Backend:
Terminal window sudo systemctl daemon-reloadsudo systemctl restart platformaResult:
systemctl status platformashowsactive (running). -
Sign in with the administrator login of the static list of users.
-
When the identity provider is reachable again, put the options back, and restart the Backend again.