# Enterprise-managed authorization

Let a company's Claude organization or identity provider grant its members access to Ferrite Apps or your own application's MCP endpoint, without a browser sign-in for each person.

A company that uses Ferrite or your application through Claude or another assistant usually manages people in one organization directory or identity provider. Enterprise-managed authorization (Auto-connect) lets that trusted issuer decide who may connect: an administrator approves the connection once, and members use the MCP server without completing individual OAuth sign-ins.

The assistant exchanges the person's sign-in for a short-lived assertion at the trusted issuer (an Identity Assertion JWT Authorization Grant, or ID-JAG, profile `urn:ietf:params:oauth:grant-profile:id-jag`) and presents it to the MCP authorization server with the `urn:ietf:params:oauth:grant-type:jwt-bearer` grant. The server verifies the assertion and issues a short-lived access token with no refresh token.

Enterprise-managed authorization is available at two layers on Ferrite:

- **For internal company apps on `Ferrite Apps` (`https://mcp.ferrite.cloud/apps`):** Built into the Ferrite Dashboard authorization server with 1-click Express Admin Setup (`ema_issuer:manage`), Claude as a trusted issuer (no external IdP needed), Okta XAA, DNS-verified domain JIT provisioning, and instant revocation. See [Internal company apps in Claude](/developers/claude-internal-apps/).
- **For your own SaaS applications built on Ferrite:** Implemented in [`poppy-oauth`](/developers/poppy-oauth/) (server half) and [`mcp`](/developers/packages/) (client half). See [Build Claude-enabled apps](/developers/claude-apps/).

## Express Admin Setup on Ferrite Apps

When a Claude Team or Enterprise administrator enables **Auto-connect with Claude** on **Ferrite Apps**, Claude runs the Express Admin Setup flow against `https://mcp.ferrite.cloud`:

1. Claude discovers `ema_issuer:manage` in `/.well-known/oauth-authorization-server` (`scopes_supported`) alongside `urn:ietf:params:oauth:grant-type:jwt-bearer`, `urn:ietf:params:oauth:grant-profile:id-jag`, `none`, and `private_key_jwt`.
2. Claude initiates an authorization code flow requesting only `ema_issuer:manage` from Claude's published Client ID Metadata Document (`https://claude.ai/oauth/mcp-oauth-client-metadata` or `/confidential_client`) with callback `https://claude.ai/api/mcp/auth_callback`. Non-Claude clients, mixed scopes, alternate redirect URIs, and trial accounts are refused.
3. The workspace owner approves the link in the Dashboard, and `POST /token` returns a 300-second single-use setup token (`fmcs...`), `ema_setup_endpoint` (`https://mcp.ferrite.cloud/ema/trusted-issuer`), and no `refresh_token`.
4. Claude sends `PUT https://mcp.ferrite.cloud/ema/trusted-issuer` with `{"ema_issuer": "https://identity.anthropic.com/issuers/<org-id>"}`. Ferrite validates the Claude issuer prefix, enforces global uniqueness across workspaces (`409 issuer_in_use`), burns the setup token atomically, and returns `{"aud_tenant": "ftn_..."}`.

Every subsequent employee assertion carries `aud_tenant` pinned to that workspace. Disabling Enterprise Auth or removing an issuer immediately invalidates active Hub tokens on the next `/apps` request.

## Trust a customer's identity provider in your own app

In your own Ferrite application, configure each trusted issuer (either a customer's Claude organization issuer `https://identity.anthropic.com/issuers/<org-id>` or their Okta issuer) with the assistants it may delegate to and the scopes it may grant, then answer your token route with `handle_token_with_enterprise`:

```rust filename="src/oauth.rs"
let cfg = cfg.with_enterprise(vec![
    TrustedIdp::new(
        "https://login.customer.example",
        keys,
        vec!["https://claude.ai/oauth/mcp-oauth-client-metadata/confidential_client".to_string()],
        vec!["notes:read".to_string()],
    )
    .with_tenant("tenant-acme"),
]);
let subjects = |grant: &VerifiedIdJag| Ok(account_for_verified_identity(grant));
let reply = handle_token_with_enterprise(
    &cfg, body, None, &directory, &store, &subjects, now_ms,
);
```

`keys` come from `fetch_idp_keys`, which reads the provider's OpenID discovery document over a declared [egress](/developers/secrets-egress/#declare-egress) destination and requires it to name the exact configured issuer. Cache them, and fetch again when `CachedIdpKeys::needs_refresh` says an assertion names a key you do not hold. Take the issuer from your configuration and never from the assertion.

An empty client or scope list delegates nothing. A provider that serves several companies from one issuer needs `with_tenant`, so one company's assertion cannot open another's data.

## Decide whose account it is

The resolver maps a verified assertion to one of your accounts. Two mappings are safe:

- Store `(iss, aud_tenant, sub)` when the person first signs in or is provisioned, and match on that tuple. This works even when an enterprise IdP such as Okta XAA omits the `email` claim.
- Match the assertion's verified `email` against an address your application has verified or pre-invited, when the company owns the domain (verified via DNS TXT, never a consumer free-mail provider).

Return `None` for anyone else. `poppy-oauth` then refuses the grant, and no account is created.

## What each assertion must prove

Both Ferrite Apps and `poppy-oauth` enforce strict ID-JAG validation before issuing a token:

- `typ` header equals `oauth-id-jag+jwt`, signed with `RS256` or `ES256` by a key published at the configured issuer's `jwks_uri`.
- `iss` matches an active configured issuer string verbatim; `aud` names this authorization server only; `aud_tenant` (when configured) matches verbatim.
- `client_id` matches the authenticated MCP client. When a client publishes a confidential `private_key_jwt` metadata document, it must authenticate with `private_key_jwt` and cannot downgrade to `none`.
- `resource` (normalized for scheme/host case, default port `:443`, and trailing slash) names an allowed protected resource.
- Lifetime (`exp - iat`) is at most one hour (3600 seconds) with bounded clock skew, and `(iss, jti)` is burned atomically so every assertion works once. A store that cannot record the `jti` refuses the grant.
- The issued access token works only at the named resource and comes with no `refresh_token`. When it expires, the assistant presents a fresh assertion, so an offboarded employee loses access at the next exchange.

Metadata advertises the `jwt-bearer` grant and `urn:ietf:params:oauth:grant-profile:id-jag` profile only while Enterprise Managed Authorization is enabled.

## Use it as a client

An agent inside your application can use the same flow to reach another company's MCP server on behalf of a person who signed in to you. An agent built with `agent-sdk` does this with [`EnterpriseTokens`](/developers/agent-sdk/#sign-in-to-a-server). Directly, exchange their identity token at the identity provider:

```rust filename="src/connect.rs"
let form = oauth::id_jag_exchange_form(&IdJagExchange {
    audience: "https://auth.notes.example",
    resource: Some("https://notes.example/mcp"),
    scopes: &["notes:read".to_string()],
    subject_token,
    subject_token_type: oauth::TOKEN_TYPE_ID_TOKEN,
});
let request = oauth::authenticated(form, "my-client", &ClientAuth::SecretPost(idp_secret));
```

Redeem the reply at the MCP server's authorization server:

```rust filename="src/connect.rs"
let grant = oauth::parse_id_jag_response(&idp_reply)?;
let form = oauth::jwt_bearer_form(&grant.assertion, &["notes:read".to_string()]);
let request = oauth::authenticated(
    form, "https://client.example/oauth/client.json", &ClientAuth::None,
);
```

`parse_token_server_metadata(&document, issuer)` followed by `supports_id_jag()` tells you whether that server participates before you try. Declare both servers as egress destinations in `ferrite.json`.

## Next steps

- [Internal company apps in Claude](/developers/claude-internal-apps/) for 1-click Auto-connect on `Ferrite Apps`.
- [Build Claude-enabled apps](/developers/claude-apps/) for building customer-facing Claude connectors on Ferrite.
- [Authentication](/developers/authentication/) to sign people in to your own web pages.
- [Interactive MCP tools](/developers/mcp-interactive-tools/#require-sign-in) to protect the MCP endpoint the tokens are for.
