# Sign-in and security

Sign in with a passkey or your identity provider, add a code from an authenticator app, and require it for everyone.

URL: /docs/sign-in-and-security

Passkeys, two-factor authentication and single sign-on are available from `0.1.0-alpha.10`.

With two-factor authentication, signing in asks for your password and then a 6-digit code
from an authenticator app on your phone or computer. Any app that supports standard
time-based codes works, for example Aegis, 2FAS, Google Authenticator, 1Password or
Bitwarden. Postdot does not depend on any outside service for this.

## Turn it on [#turn-it-on]

1. Open **Settings**, then **Account**. In **Security**, choose **Turn on** next to
   **Two-factor authentication**.
2. Enter your password.
3. Scan the QR code with your authenticator app. If you cannot scan, copy the setup key
   into the app instead.
4. Enter the 6-digit code the app shows, then **Confirm and turn on**.
5. Save the 10 backup codes: copy them or download them as a text file, and keep them
   somewhere other than the device that holds your authenticator app.

Postdot shows the backup codes only once.

## Sign in with a code [#sign-in-with-a-code]

After your password, Postdot asks for the code from your app. **Trust this device for 30
days** skips the code on that browser for 30 days.

If you do not have your app, choose **Use a backup code instead**. Each backup code works
once. After using one, create new codes with **New backup codes** in **Account**: this
replaces all previous codes.

## Turn it off [#turn-it-off]

In **Account**, choose **Turn off** and enter your password. This removes your authenticator
secret, your backup codes and every trusted device. To turn it on again later, scan a new QR
code and save new backup codes.

## Passkeys [#passkeys]

A passkey lets you sign in with your fingerprint, your face, your device's screen lock or a
security key, without typing a password or a code. It is stored by your device, your
browser or your password manager, and it only works on your Postdot address.

To add one, open **Account**, choose **Add passkey** in **Security**, give it a name you
will recognize, then confirm the prompt from your browser. You can add several, for
example one per device, and rename or remove each one from its menu.

On the sign-in page, choose **Sign in with a passkey**. A passkey counts as both steps:
Postdot does not ask for a code afterwards. Your password keeps working.

Passkeys need Postdot to be served on a domain name over HTTPS, as in the
[installation guide](/docs/installation/). They are tied to that domain: if the
installation moves to another domain, existing passkeys stop working and each person adds
new ones.

## Require it for everyone [#require-it-for-everyone]

An administrator can require two-factor authentication for every person on the
installation. Open **Settings → Installation → Sign-in and security** and turn on
**Require two-factor for everyone**. It is off by default.

Postdot asks you to confirm first and says who is affected: everyone who signs in with a
Postdot password and has no authenticator app yet. Accounts that sign in only through single
sign-on, and API keys, are not affected. If your own account has no authenticator app yet,
choose **Set up yours first**: the requirement stays off until you finish and choose
**Done and require for everyone**. Turn the setting off at any time to undo it.

When it is on, a person who has not set up an authenticator app is asked to do it right
after signing in, before reaching Studio, or can choose **Sign out**. People who already use two-factor authentication
see no change. Passkeys do not replace the authenticator app for this requirement, because
the password still works next to them.

The same setting is available through the API (`GET` and `PUT /api/settings/security`),
the MCP tools `get_security_settings` and `save_security_settings`, and
`postdot settings security` in the CLI.

## Single sign-on with your identity provider [#single-sign-on-with-your-identity-provider]

If your team already signs in to its tools through an identity provider that speaks OpenID
Connect, such as Authentik, Keycloak, Pocket ID or Authelia, Postdot can use it. The sign-in
page then shows **Sign in with** followed by the name you choose. Passwords and passkeys keep
working next to it. One provider can be configured per installation.

### Set it up [#set-it-up]

1. In Postdot, open **Settings → Installation → Sign-in and security** and turn on
   **Sign in with an identity provider** in **Single sign-on**. Copy the **Redirect URL** it shows.
2. In your provider, create an OpenID Connect application (a confidential client using the
   authorization code flow) with that redirect URL and the scopes `openid`, `email` and
   `profile`.
3. Back in Postdot, enter the provider's **Issuer URL**, the **Client ID**, the **Client
   secret** and the **Button label**, then choose **Save** in the bottom bar.

Postdot checks that it can read the provider's OpenID configuration before saving, and the
button appears on the sign-in page at once, without a restart. The client secret is stored
encrypted and never shown again.

Where to find the issuer URL:

| Provider  | Issuer URL                                                                |
| --------- | ------------------------------------------------------------------------- |
| Authentik | `https://authentik.example.com/application/o/<application-slug>/`         |
| Keycloak  | `https://keycloak.example.com/realms/<realm>`                             |
| Pocket ID | `https://id.example.com`                                                  |
| Authelia  | `https://auth.example.com`, with the client declared in its configuration |

These addresses follow each provider's documentation. Postdot's own tests use a generic
OpenID Connect provider.

### Who can sign in [#who-can-sign-in]

- A person whose Postdot account has the same e-mail address signs in to that account. The
  provider must mark the address as verified; otherwise Postdot refuses, so that nobody can
  claim an account by typing someone else's address in the provider.
- A person with a pending invitation signs in and joins as invited.
- Anyone else is refused, with a message asking them to request an invitation. Turn on
  **Create accounts automatically** to let in everyone your provider accepts instead: they
  join the default workspace as members, with no project access until someone grants it.

Accounts created through the provider have no Postdot password. They are not asked to set up
two-factor authentication in Postdot when it is required: your provider handles that step.

### Configure it from scripts [#configure-it-from-scripts]

The same settings are available through the API (`GET` and `PUT
/api/settings/single-sign-on`), the MCP tools `get_single_sign_on_settings` and
`save_single_sign_on_settings`, and the CLI:

```sh
postdot settings single-sign-on set --enable --issuer https://id.example.com \
    --client-id postdot --client-secret-file ./client-secret --label "Pocket ID"
```

The deployment can also provide the first settings with environment variables, as for
SMTP: `POSTDOT_OIDC_ISSUER`, `POSTDOT_OIDC_CLIENT_ID`, `POSTDOT_OIDC_CLIENT_SECRET`,
`POSTDOT_OIDC_LABEL` and `POSTDOT_OIDC_AUTO_CREATE`. Studio then says the settings come from
the deployment, and saving them in Studio replaces them.

## API keys are not affected [#api-keys-are-not-affected]

API keys used by the CLI, the MCP server, n8n or your own scripts keep working without a
code, with or without the requirement. Treat them as passwords: give each one only the
capabilities it needs, and revoke it in **API keys** when you no longer use it.

## Lost your app and your backup codes [#lost-your-app-and-your-backup-codes]

The administrator of the installation can turn two-factor authentication off for your
account with an offline command on the server. See
[Reset two-factor authentication for an account](/docs/operations/#reset-two-factor-authentication-for-an-account).
You then sign in with your password and can turn it on again.
