# Microsoft Entra ID SSO for AlmaForge

Last verified: December 1, 2026

Connect AlmaForge to Microsoft Entra ID (formerly Azure Active Directory) with OpenID Connect (OIDC) and map Entra security groups to AlmaForge roles. Users sign in with their Microsoft organizational account and receive roles from their current group memberships.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

### AlmaForge cluster[​](#almaforge-cluster "Direct link to AlmaForge cluster")

Use a running cluster. If you already have an admin CLI profile, run this on your workstation and confirm the active profile points to your cluster.

******Terminal

```bash
alma status
```

If Entra ID will be your first SSO connector, use the local admin identity on the Auth Service host to apply it. See [Connect your first identity provider](https://almaforge.com/deployment/standalone.md#step-5-connect-your-identity-provider).

Have the public HTTPS address of the Proxy Service ready. You will use its hostname to build the Entra ID redirect URI.

### Microsoft Entra ID administrator[​](#microsoft-entra-id-administrator "Direct link to Microsoft Entra ID administrator")

You need an Entra ID administrator account with permission to register applications and inspect security groups. The **Application Administrator**, **Cloud Application Administrator**, or **Global Administrator** directory roles cover all required permissions.

Have your **Directory (tenant) ID** ready. Find it on the **Overview** page in the Entra admin center or with the Azure CLI:

******Terminal

```bash
az account show --query tenantId -o tsv
```

### Entra security groups[​](#entra-security-groups "Direct link to Entra security groups")

Have at least one Entra ID security group ready to map to AlmaForge roles. AlmaForge matches each group by its immutable **Object ID** (UUID), not its display name. Copy each group's **Object ID** from its **Overview** page in the Entra admin center.

Use a direct member of a mapped group for the first sign-in test.

### Network access from Auth Service hosts[​](#network-access-from-auth-service-hosts "Direct link to Network access from Auth Service hosts")

The Auth Service uses `login.microsoftonline.com` to discover Entra's OIDC configuration, verify token signatures, and exchange authorization codes for tokens. Allow outbound HTTPS (TCP port 443) from every Auth Service host to this endpoint.

Run this check from each Auth Service host.

******Terminal

```bash
curl -sS --max-time 10 -o /dev/null \
    -w "login.microsoftonline.com: HTTP %{http_code}\n" \
    "https://login.microsoftonline.com/"
```

An HTTP response confirms connectivity. If `curl` reports `HTTP 000`, check DNS, firewall, proxy, or TLS settings before continuing.

## Step 1. Configure Microsoft Entra ID with Terraform[​](#step-1-configure-microsoft-entra-id-with-terraform "Direct link to Step 1. Configure Microsoft Entra ID with Terraform")

If you do not use Terraform, follow [Entra admin center setup](#step-1-configure-microsoft-entra-id-in-entra-admin-center) below instead.

Save [`almaforge-microsoft-entra-sso.tf`](https://almaforge.com/examples/sso/entra-id/terraform/almaforge-microsoft-entra-sso.tf) in a new private working directory. It creates a single-tenant app registration with the callback URI, adds the `groups` claim to ID tokens, creates the enterprise application and client secret, and creates the `AlmaForge-Admins` and `AlmaForge-Developers` security groups. Keep Terraform state, state backups, and exported secrets out of source control.

Authenticate with the Azure CLI, replace `almaforge.example.com` with your public Proxy Service hostname, and apply:

******Terminal

```bash
umask 077
az login
terraform init
terraform apply -var='proxy_public_addr=almaforge.example.com'
terraform output -raw tenant_id
terraform output -raw application_id
terraform output group_object_ids
terraform output -raw client_secret > microsoft-secret.txt
```

Continue to [Step 2](#step-2-apply-the-oidcconnector). You will install `microsoft-secret.txt` and map the `group_object_ids` output to AlmaForge roles.

## Step 1. Configure Microsoft Entra ID in Entra admin center[​](#step-1-configure-microsoft-entra-id-in-entra-admin-center "Direct link to Step 1. Configure Microsoft Entra ID in Entra admin center")

Use this section if you do not use Terraform. If you already provisioned Entra ID with Terraform above, skip to [Step 2](#step-2-apply-the-oidcconnector).

### Step 1.1. Register the application[​](#step-11-register-the-application "Direct link to Step 1.1. Register the application")

1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com/).

2. Open **Entra ID → App registrations** and click **New registration**.

3. Set these fields.

   * **Name**: `AlmaForge SSO`
   * **Supported account types**: **Single tenant only** (accounts in your organizational directory only).
   * **Redirect URI**: Select **Web** and enter `https://almaforge.example.com/api/v1/oidc/callback`. Replace `almaforge.example.com` with your public Proxy Service hostname. Keep `https://`, omit `:443`, and omit the trailing slash.

   ![Register an application form in the Microsoft Entra admin center with the AlmaForge callback URI](/examples/sso/entra-id/screenshots/microsoft-entra-register-application.png)

4. Click **Register**.

5. On the application **Overview** page, copy the **Application (client) ID** and **Directory (tenant) ID**.

### Step 1.2. Create a client secret[​](#step-12-create-a-client-secret "Direct link to Step 1.2. Create a client secret")

1. In the application sidebar, open **Manage → Certificates & secrets**.

2. Open the **Client secrets** tab and click **New client secret**.

   ![Certificates and secrets page in Microsoft Entra ID showing the New client secret button](/examples/sso/entra-id/screenshots/microsoft-entra-new-client-secret.png)

3. Enter a description (for example, `AlmaForge Auth Service`), choose an expiration period that matches your rotation policy (Entra ID caps client secrets at 24 months), and click **Add**.

4. Copy the **Value** column before leaving the page. Entra ID masks the secret as soon as you leave and never shows it again. Do not copy the **Secret ID** column.

Treat the client secret as a password

Anyone with the client secret can impersonate AlmaForge to Entra ID's OAuth endpoints. Store it in the same secret manager you use for production credentials. Do not commit it to Git.

### Step 1.3. Configure the groups claim[​](#step-13-configure-the-groups-claim "Direct link to Step 1.3. Configure the groups claim")

Entra ID does not include group memberships in ID tokens by default. Configure the app registration to emit security group Object IDs in the `groups` claim so AlmaForge can map them to roles in [Step 2](#step-2-apply-the-oidcconnector):

1. In the application sidebar, open **Manage → Token configuration**.

2. Click **Add groups claim**.

3. Under **Select group types to include in Access, ID, and SAML tokens**, select **Security groups**. If a user belongs to more than 200 groups, Entra ID omits the `groups` claim from the ID token and emits a Graph overage pointer that AlmaForge does not follow. For users who exceed this limit, select **Groups assigned to the application** and assign only the groups needed for AlmaForge access. This option requires Microsoft Entra ID P1 or a license that includes it.

   ![Edit groups claim panel in Microsoft Entra ID with Security groups selected](/examples/sso/entra-id/screenshots/microsoft-entra-add-groups-claim.png)

4. Under **Customize token properties by type**, expand **ID**, keep **Group ID** selected so Entra ID emits immutable Object IDs rather than display names, and leave **Emit groups as role claims** unchecked.

   ![Customize token properties by type in Microsoft Entra ID with Group ID selected under ID](/examples/sso/entra-id/screenshots/microsoft-entra-groups-claim-id-token.png)

5. Click **Add** (or **Save**). Confirm that `groups` appears in the **Optional claims** table with **ID** listed under **Token type**.

   ![Token configuration page in Microsoft Entra ID listing the groups claim](/examples/sso/entra-id/screenshots/microsoft-entra-token-configuration-groups.png)

## Step 2. Apply the OIDCConnector[​](#step-2-apply-the-oidcconnector "Direct link to Step 2. Apply the OIDCConnector")

Store the client secret in a root-only file on each Auth Service host. `almad` runs as root, so only root needs read access to the file.

******Terminal

```bash
sudo install -o root -g root -m 0600 /dev/stdin /etc/almaforge/microsoft-secret.txt <<'EOF'
<client-secret-value>
EOF
```

In a multi-node Auth Service cluster, every host needs an identical secret file at this exact path. The instance that handles a login reads the file locally. See [High availability](#high-availability) to prevent intermittent login failures.

Write a YAML file describing the connector. Set `clientSecret` to a `${file:PATH}` reference so the Auth Service reads the secret from disk, and map Entra's `groups` claim Object IDs to AlmaForge roles under `claimsToRoles`:

[`microsoft.yaml`](https://almaforge.com/examples/sso/entra-id/almad.d/microsoft.yaml):

examples/sso/entra-id/almad.d/microsoft.yaml

```yaml
# Microsoft Entra ID connector loading clientSecret from a local file.

apiVersion: almaforge.com/v1

kind: OIDCConnector

metadata:

  name: microsoft

spec:

  display: Microsoft

  provider: microsoft

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

  clientID: <application-client-id>

  clientSecret: ${file:/etc/almaforge/microsoft-secret.txt}

  usernameClaim: preferred_username

  # Use each group's Object ID (UUID) from Entra ID under value, not its

  # display name, and list existing AlmaForge roles.

  claimsToRoles:

    # AlmaForge-Admins

    - claim: groups

      value: <admins-group-object-id>

      roles: [admin, access]

    # AlmaForge-Developers

    - claim: groups

      value: <developers-group-object-id>

      roles: [access]
```

Replace:

* `<tenant-id>` with the Directory (tenant) ID from [Step 1](#step-1-configure-microsoft-entra-id-with-terraform) (or [Step 1.1](#step-11-register-the-application)).
* `<application-client-id>` with the Application (client) ID from [Step 1](#step-1-configure-microsoft-entra-id-with-terraform) (or [Step 1.1](#step-11-register-the-application)).
* The path inside `${file:...}` with the path where you installed `microsoft-secret.txt` on every Auth Service host.
* `<admins-group-object-id>` and `<developers-group-object-id>` with your Entra security group **Object IDs** (UUIDs from each group's **Overview** page). A display name such as `AlmaForge-Admins` will not match. Keep the group name in a comment above each entry so the mapping stays readable.

These fields are specific to Entra ID:

* `issuerURL` uses the tenant-specific v2.0 endpoint. The token's `iss` claim must match this issuer.
* `usernameClaim: preferred_username` maps the AlmaForge username to the Entra user principal name, such as `alice@example.com`, instead of the immutable subject ID.

Alternative: load the client secret from an environment variable or inline

`clientSecret` also accepts an environment variable reference (`${env:MICROSOFT_CLIENT_SECRET}`) or an inline string. An inline value stores the secret directly in the cluster state store, where it is returned by `alma get oidcconnector/microsoft -o yaml --with-secrets` and included in backend backups. Prefer `${file:PATH}` or `${env:VAR}` in production. See [Secret storage](https://almaforge.com/sso/oidc.md#secret-storage).

Test break-glass before applying

AlmaForge has no local accounts. If this is the only connector, a wrong claim mapping or expired client secret prevents new logins. Confirm your [break-glass procedure](https://almaforge.com/break-glass.md) works before applying the connector to a production cluster.

If you have a cluster admin profile, apply the connector from your workstation.

******Terminal

```bash
alma apply -f microsoft.yaml
```

If this is your first connector, copy `microsoft.yaml` to the Auth Service host and apply it there using the local admin identity.

******Terminal

```bash
sudo alma apply -f microsoft.yaml
```

## Step 3. Verify the connector[​](#step-3-verify-the-connector "Direct link to Step 3. Verify the connector")

Open the cluster's [audit log](https://almaforge.com/reference/audit.md) for your test account. See [SSO verification](https://almaforge.com/sso/oidc.md#step-4-apply-and-verify) for event fields and the distinction from service logs.

Keep your admin session open. From a separate workstation or OS account, sign in as a direct member of a mapped Entra security group. Replace the example proxy address with yours.

******Terminal

```bash
alma login --proxy=almaforge.example.com
```

Choose **Microsoft** in the browser. The test passes when `alma` prints the roles expected for that user.

If this is the cluster's first connector, also sign in with an account mapped to `admin`. Confirm that `alma` prints the `admin` role before closing the local admin session on the Auth Service host.

Audit events from a successful sign-in

A successful first-time login emits a `UserLogin` event and the `CertificateCreate` event for the certificate it mints:

JSON

```json
{

  "kind": "AuditEvent",

  "apiVersion": "almaforge.com/v1",

  "spec": {

    "id": "1a2b3c4d-5e6f-4071-8293-a4b5c6d7e8f9",

    "index": 0,

    "timestamp": "2026-03-30T15:58:58.999000Z",

    "clusterName": "almaforge.example.com",

    "code": "T1001I",

    "type": "UserLogin",

    "verb": "login",

    "actor": {

      "name": "alice@example.com",

      "type": "user"

    },

    "status": {

      "success": true

    },

    "userLogin": {

      "method": "oidc",

      "attributes": {

        "connector_id": "microsoft",

        "connector_type": "oidc",

        "name": "Alice Example",

        "request_id": "8f0c1e6a-2f7e-4a7a-9f1e-1f0b6d0f1a2b",

        "username": "alice@example.com"

      }

    }

  }

}
```

JSON

```json
{

  "kind": "AuditEvent",

  "apiVersion": "almaforge.com/v1",

  "spec": {

    "id": "6d7e8f90-a1b2-43c4-95d6-e7f8091a2b3c",

    "index": 0,

    "timestamp": "2026-03-30T15:58:58.999000Z",

    "clusterName": "almaforge.example.com",

    "code": "TC000I",

    "type": "CertificateCreate",

    "verb": "create",

    "certificateCreate": {

      "certType": "user",

      "identity": {

        "user": "alice@example.com",

        "roles": [

          "admin",

          "access"

        ],

        "logins": [

          "tester",

          "ec2-user",

          "root"

        ],

        "traits": {

          "groups": [

            "11111111-1111-1111-1111-111111111111",

            "22222222-2222-2222-2222-222222222222"

          ],

          "name": [

            "Alice Example"

          ],

          "preferred_username": [

            "alice@example.com"

          ]

        }

      }

    }

  }

}
```

Check these fields on the `CertificateCreate` event:

* `spec.certificateCreate.identity.traits.groups`: the group Object IDs Entra ID emitted in the ID token. Compare these UUIDs with your `claimsToRoles` entries. If `groups` is missing, the `groups` claim was not configured in [Step 1.3](#step-13-configure-the-groups-claim) or the user exceeded the 200-group overage limit.
* `spec.certificateCreate.identity.traits.preferred_username`: compare with `spec.certificateCreate.identity.user` to confirm `usernameClaim`.
* `spec.certificateCreate.identity.roles` and `logins`: confirm the expected roles and SSH logins.

Read the full audit-event breakdown on the [generic OIDC verification section](https://almaforge.com/sso/oidc.md#step-4-apply-and-verify).

## Troubleshooting[​](#troubleshooting "Direct link to Troubleshooting")

### AADSTS50011: reply URL does not match[​](#aadsts50011-reply-url-does-not-match "Direct link to AADSTS50011: reply URL does not match")

The **Redirect URI** registered in [Step 1.1](#step-11-register-the-application) does not match the URL AlmaForge sends as `redirect_uri`. Open the app registration in the Entra admin center, select **Authentication**, and verify that the Web platform contains `https://<proxy-public-addr>/api/v1/oidc/callback` with exact casing, port `443` omitted, and no trailing slash.

### Login fails with invalid\_client[​](#login-fails-with-invalid_client "Direct link to Login fails with invalid_client")

The client secret on the connector does not match what Entra ID has on file. Common causes are copying the **Secret ID** instead of the **Value**, rotating the secret in Entra without updating `/etc/almaforge/microsoft-secret.txt` on every Auth Service host, or letting the secret expire (Entra secrets cap at 24 months). Generate a new secret under **Certificates & secrets**, copy the **Value** column, and follow [Client secret rotation](#client-secret-rotation).

### No roles match the login[​](#login-succeeds-but-no-roles-are-assigned "Direct link to No roles match the login")

The login is rejected when no mapping assigns a role. Check these conditions first:

* Every `claimsToRoles` value is the group's **Object ID** (UUID), not its display name.
* Under **Token configuration** in the app registration, a groups claim exists with **ID → Group ID** selected.

With `ALMA_LOG_LEVEL=debug` on the Auth Service host, sign in again and inspect the claims Entra ID sent:

******Terminal

```bash
journalctl -u almad -f | grep 'Extracted claims'
```

Every `claimsToRoles` value must exactly match an Object ID in the emitted `groups` array. After a successful login, inspect `spec.certificateCreate.identity.traits.groups` in the `CertificateCreate` audit event. See [Claims, traits, and role templates](https://almaforge.com/sso/oidc.md#claims-traits-and-role-templates).

### Admin group missing for a user with many groups[​](#admin-group-missing-for-a-user-with-many-groups "Direct link to Admin group missing for a user with many groups")

When a user belongs to more than 200 groups, Entra ID omits the `groups` claim from the ID token and emits `_claim_names` and `_claim_sources` pointers to Microsoft Graph instead. AlmaForge does not currently follow the overage pointer.

Under **Token configuration → Edit groups claim**, switch to **Groups assigned to the application**, then assign each required security group to the Enterprise Application. Users must be direct members of those assigned groups because this option excludes nested membership. Assigning groups to an enterprise application requires Microsoft Entra ID P1 or a license that includes it. Reducing `claimsToRoles` in AlmaForge does not reduce the groups Entra emits. See [Microsoft's group-claim guidance](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-fed-group-claims).

### AADSTS700016: Application not found in directory[​](#aadsts700016-application-not-found-in-directory "Direct link to AADSTS700016: Application not found in directory")

The `clientID` in `microsoft.yaml` does not match the app registration, or `issuerURL` contains the wrong tenant ID. Compare both values with the application's **Overview** page in the Entra admin center.

## Operations[​](#operations "Direct link to Operations")

### Break-glass access[​](#break-glass-access "Direct link to Break-glass access")

Test [break-glass access](https://almaforge.com/sso/oidc.md#break-glass-access) before relying on this connector. Entra-specific recovery cases include an expired client secret, a misconfigured `groups` claim, or an Entra ID outage.

### Revocation[​](#revocation "Direct link to Revocation")

Removing a user from an Entra security group takes effect on their next sign-in. Existing certificates remain valid until they expire. For an immediate cutoff, [lock the user](https://almaforge.com/revoking-access.md#lock-a-user).

### Secret storage[​](#secret-storage "Direct link to Secret storage")

Use `${file:PATH}` or `${env:VAR}` to keep `clientSecret` out of the cluster state store and its backups. Follow [Secret storage](https://almaforge.com/sso/oidc.md#secret-storage) to protect secrets in production.

### Client secret rotation[​](#client-secret-rotation "Direct link to Client secret rotation")

Entra ID caps client secrets at 24 months. An app registration can hold multiple active secrets, so you can rotate one without downtime:

1. In the app registration, open **Manage → Certificates & secrets → Client secrets** and click **New client secret**. Do not delete the old secret yet.
2. Copy the new secret's **Value** column immediately.
3. Replace `/etc/almaforge/microsoft-secret.txt` on every Auth Service host using your configuration management tool (Ansible, Puppet, cloud-init, or Kubernetes secret mounts).
4. Confirm a test login works through `alma login`.
5. Delete the old secret in Entra ID.

The connector reads the file on the next login. No `almad` restart is required. If you configured an inline `clientSecret`, re-apply the connector with the new value. Track the expiration date in your alerting system because Entra ID does not alert when a secret expires.

### Lifecycle[​](#lifecycle "Direct link to Lifecycle")

Apply connector changes before testing the next login. No `almad` restart is needed. See [When connector changes take effect](https://almaforge.com/sso/oidc.md#when-connector-changes-take-effect) for discovery caching and IdP-side changes.

### High availability[​](#high-availability "Direct link to High availability")

AlmaForge reads `/etc/almaforge/microsoft-secret.txt` on the Auth Service instance that handles each login callback. In a multi-node Auth Service cluster, a missing or stale file on one instance causes intermittent login failures. Deploy the file through configuration management so every Auth Service host has an identical copy at the same path with mode `0600`.

Every Auth Service instance also calls `login.microsoftonline.com` independently and caches the OIDC discovery document for one hour. See [High availability](https://almaforge.com/sso/oidc.md#high-availability) on the generic OIDC page for the full list of per-instance assumptions.

### Monitoring[​](#monitoring "Direct link to Monitoring")

Monitor the [audit log](https://almaforge.com/reference/audit.md) for login outcomes. For diagnostics, inspect the Auth journal for token validation and the Proxy journal for browser callbacks. On each service host, tail OIDC-related messages with:

******Terminal

```bash
journalctl -u almad -f | grep -Ei 'microsoft|oidc'
```

Check `UserLogin` failures and their `spec.status.error` field. See [SSO verification](https://almaforge.com/sso/oidc.md#step-4-apply-and-verify) for event codes, certificate fields, and debug-only journal copies. Collect records from [audit event storage](https://almaforge.com/storage.md#audit-events) for SIEM ingestion. Collect service diagnostics from the journal separately.

### Removal[​](#removal "Direct link to Removal")

Delete the connector resource:

******Terminal

```bash
alma delete oidcconnector/microsoft
```

Existing sessions issued through the connector remain valid until their certificates expire. No new sessions will be issued.

On the Entra side, remove `/etc/almaforge/microsoft-secret.txt` from Auth Service hosts and delete the app registration in Microsoft Entra ID so the client ID and secret can no longer be used.

## References[​](#references "Direct link to References")

* [`OIDCConnector` resource reference](https://almaforge.com/reference/configuration.md#oidcconnector)
* [`AuthConfig` resource reference](https://almaforge.com/reference/configuration.md#authconfig)
* [Generic OIDC integration guide](https://almaforge.com/sso/oidc.md)
* [Break-glass access guide](https://almaforge.com/break-glass.md)
* [Microsoft: Register an application with the Microsoft identity platform](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app)
* [Microsoft: Configure group claims for applications with Microsoft Entra ID](https://learn.microsoft.com/en-us/entra/identity-platform/optional-claims#configure-groups-optional-claims)
* [Microsoft: Configure group claims in tokens (overage guidance)](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-fed-group-claims)
