# SSO with Entra

_For tartan 0.9.36._

Your people sign in with their passkey, and your Microsoft Entra ID sign-in rides along as the check that they still work for you.

Your people sign in with their passkey, and your Microsoft Entra ID sign-in rides along as the check that they
still work for you.

The passkey always signs a person in. With SSO, their Entra sign-in also comes with each sign-in and each change
they make: remove someone from your Entra group, or from the app's assignment, and their next change is refused.
Your groups decide who gets which role. Tartan holds no secret and no credential in your tenant.

Microsoft Entra ID is the supported provider.

## Before you start

- An Entra administrator who may grant admin consent (Global Administrator or Application Administrator).
- Tartan's app (client) id, written `<tartan app id>` below.
- Your organization's Owner for any rule that grants Admin, or for requiring SSO. An Admin adds Tech and Viewer rules.

## 1. Groups in Entra

Create a security group for each role you'll give, for example one for Techs and one for Admins. Put the right
people in them, and note each group's **object id**.

## 2. Consent to Tartan's app

```sh
tartan sso consent --tenant <tenant id or verified domain> --client-id <tartan app id>
```

Your browser opens Microsoft's admin-consent page. An Entra administrator signs in and accepts. This creates the
**Tartan** enterprise application in your tenant.

In Entra, open **Enterprise applications**, then **Tartan**. Under **Properties**, set **Assignment required** to
**Yes** and **Visible to users** to **No**. Under **Users and groups**, assign your groups. Someone not assigned
gets no token.

## 3. Check the set-up

Signed in as someone in one of the groups:

```sh
tartan sso check --issuer https://login.microsoftonline.com/<tenant id>/v2.0 --client-id <tartan app id> --group <group object id>
```

It runs one browser sign-in and reports each check by name. It talks to no Tartan server, never prints a token and
changes nothing. The issuer is exact: your tenant id, `/v2.0`, no trailing slash. Fix what failed and run it again
until it says `ok: true`.

## 4. Trust your groups

One rule per group and role. An outsourced IT provider uses other rules for its own organization:
[Stand up your outsourced IT org](outsourced-it.md).

```sh
tartan idp trust add --org acme --issuer https://login.microsoftonline.com/<tenant id>/v2.0 --client_id <tartan app id> --value <techs group object id> --role tech
tartan idp trust add --org acme --issuer https://login.microsoftonline.com/<tenant id>/v2.0 --client_id <tartan app id> --value <admins group object id> --role admin
```

Each rule steps up on its own: one passkey prompt each. Leave `--mfa_claim` out: your Tartan passkey is the MFA.
Add `--dry-run` to see a rule without adding it.

## 5. Invite people with their work sign-in

Invite each person with `--upn`, their Entra sign-in name. Their SSO sign-in must match it to join, and the invite
can approve the computer they join from: [Invite people](invite-people.md). From then on, `tartan login` takes the
Microsoft step by itself.

## 6. Require SSO (optional)

Your Owner can make every sign-in into the organization carry your SSO. It is a security setting: the Owner's
passkey approves it, every time, on its own:

```sh
tartan org set --org acme --key require_sso --value true
```

## Owners never use SSO

An Owner signs in with their passkey alone, whatever the organization's settings. Keep the Owner passkey for Owner acts,
invite yourself as an Admin, and work day to day as that Admin with SSO.

## Check it worked

```sh
tartan idp trust list --org acme
tartan login
tartan me show --json
```

`me show` passes when `sso` is `true` and your organization is listed with your role. In the console, **Settings**, then
**Sign-in trust**, lists the rules. **Add a rule** adds another for a sign-in already trusted, and **Remove** takes
one away.

## Turn it off

- **One person:** remove them from the Entra group or the app's assignment.
- **One rule:** `tartan idp trust remove --org acme --rule <rule id>`. The roles it gave go with it.
- **Your organization's SSO:** your Owner runs `tartan org sso-off --org acme --issuer <issuer>`. In one passkey prompt
  it removes the rules naming your issuer, turns off requiring SSO, and clears your people's links to it. Your people
  then sign in with their passkey alone.

## Next

- [Invite people](invite-people.md)
- [Admins and passkeys](admins-passkeys.md)
- [The audit log](audit-log.md)
