> ## Documentation index
> Fetch the complete documentation index at: https://context7.com/docs/llms.txt
> Ask it with GET https://context7.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://context7.com/docs/resources/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://context7.com/docs/feedback?path=/docs/enterprise/security/adfs-sso&helpful={true|false}&comment={comment}` records whether this page helped. The `comment` (URL-encoded, at most 500 characters) says what helped, or what was missing or wrong; a `helpful=false` rating needs it. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# ADFS (SSO)

> Let your team sign in to Context7 On-Premise with Active Directory Federation Services (ADFS) over SAML 2.0.

Context7 On-Premise connects to Active Directory Federation Services (ADFS) through its **SAML 2.0** provider. You add Context7 as a relying party trust in ADFS, send four claims, and import the ADFS metadata in Context7. Context7 reads the standard ADFS claim types, so you do not need to map attributes by hand.

This page gives the ADFS-specific steps. For the full field reference, see [SAML SSO](/enterprise/security/saml-sso).

## Before you start

You need:

- An ADFS admin who can add relying party trusts in the **AD FS Management** console.
- A running Context7 On-Premise instance, served over HTTPS at the address your users will open.
- A Context7 admin account. On a fresh install it is `admin` / `admin` until you change it.
- The Active Directory groups that will get the Context7 **admin** and **member** roles, for example `Context7-Admins` and `Context7-Users`.

<Note>
Context7 builds its SAML URLs from the address it is reached at. Behind a reverse proxy, the proxy must send the `X-Forwarded-Proto` and `X-Forwarded-Host` headers with your public scheme and host. Otherwise sign-in fails.
</Note>

## Part 1: Add Context7 to ADFS

1. In Context7, open **Workspace Settings › Authentication**. In the **Single sign-on** card, select the **SAML 2.0** tab. In the **Service provider** section, click **Download metadata**.
2. In **AD FS Management**, right-click **Relying Party Trusts** and click **Add Relying Party Trust**. Select **Claims aware**.
3. Select **Import data about the relying party from a file** and select the Context7 metadata file. If ADFS can reach Context7, you can use **Import data about the relying party published online** with the **SP metadata URL** instead.
4. Enter `Context7` as the display name. Select an access control policy, for example **Permit everyone**, and finish the wizard.

The metadata sets the identifier, the Assertion Consumer Service URL, the logout URL and the Context7 certificates. ADFS signs and encrypts the assertion by default. Context7 accepts both, so keep the defaults.

## Part 2: Add the claim rules

Right-click the new **Context7** trust and click **Edit Claim Issuance Policy**. Add two rules.

**Rule 1: Send LDAP attributes as claims**

Click **Add Rule**, select **Send LDAP Attributes as Claims**, name it `Context7 attributes`, and select **Active Directory** as the attribute store. Add these rows:

| LDAP attribute | Outgoing claim type |
| --- | --- |
| E-Mail-Addresses | E-Mail Address |
| Given-Name | Given Name |
| Surname | Surname |
| Token-Groups - Unqualified Names | Role |

The **Role** claim carries the user's group names, such as `Context7-Admins`. Context7 reads it as the groups attribute.

**Rule 2: Send the NameID**

Click **Add Rule**, select **Transform an Incoming Claim**, and name it `Context7 NameID`. Set:

- **Incoming claim type**: E-Mail Address
- **Outgoing claim type**: Name ID
- **Outgoing name ID format**: Email

Context7 recognizes returning users by the NameID. Without this rule, ADFS sends no NameID and sign-in fails.

<Warning>
Choose the NameID source before your users sign in, and do not change it later. If the NameID changes, Context7 creates a new user record for each person on their next sign-in.
</Warning>

## Part 3: Configure Context7

<Steps>
  <Step title="Import the ADFS metadata">
    Turn on **Enable SAML 2.0**. In **IdP metadata URL**, enter:

    ```
    https://<your-adfs-host>/FederationMetadata/2007-06/FederationMetadata.xml
    ```

    Click **Import**. Context7 fills in the IdP entity ID, the sign-in and logout URLs, and the ADFS token-signing certificates.

    If the import fails because Context7 cannot reach ADFS or does not trust its certificate, open the metadata URL in your browser, click **Paste XML** in Context7, and paste the file. To trust an internal CA for all outbound HTTPS, set `NODE_EXTRA_CA_CERTS` on the server (see [configuration](/enterprise/on-premise)).
  </Step>

  <Step title="Map groups to roles">
    Leave the attribute fields blank. Context7 detects the ADFS claims for email, name, username and groups.

    - **Admin group value**: the AD group that gets the admin role, for example `Context7-Admins`.
    - **Member group value**: the AD group that gets the member role, for example `Context7-Users`.

    Group values are case-sensitive. Users in neither group cannot sign in.
  </Step>

  <Step title="Test and save">
    Click **Check configuration**, then **Save and apply**. Open `/login` in a new browser window, click the SSO button, and sign in with an AD account in one of the groups.
  </Step>
</Steps>

On the first sign-in Context7 creates the user. On later sign-ins it updates the name, email, role and groups from ADFS.

## Keep it running

- **Token-signing certificate rollover.** When ADFS publishes a new token-signing certificate, open the SAML 2.0 tab and click **Import** again. Context7 does not reload the ADFS metadata by itself. If you import while ADFS publishes both the old and the new certificate, sign-in keeps working through the switch.
- **Clocks.** Context7 allows 60 seconds of clock difference with ADFS. Keep both servers on NTP.
- **Removing a user.** Disabling someone in Active Directory stops their next sign-in. It does not end browser sessions, MCP client authorizations or personal API keys. To end all access at once, also choose **Disable sign-in** for the user on the **Members** page. See [Managing users](/enterprise/security/saml-sso#managing-users).

## Troubleshooting

### "SAML assertion has no NameID"

Rule 2 is missing or its incoming claim is empty. Check that the user has an email address in Active Directory and that the rule sends it as the Name ID.

### "This account is not assigned a supported Context7 group"

The **Role** claim does not contain the admin or member group value. Check that rule 1 sends **Token-Groups - Unqualified Names** as **Role**, that the user is in the group, and that the value in Context7 matches the group name exactly.

### "The SAML response signature could not be verified"

Context7 does not have the current ADFS token-signing certificate. Click **Import** again.

For other errors, see [SAML SSO troubleshooting](/enterprise/security/saml-sso#troubleshooting), or contact [context7@upstash.com](mailto:context7@upstash.com).
