Skip to content

Commit ed87d4b

Browse files
committed
feat: Add Enterprise Managed Authorization (SEP-990) support
1 parent 7662ce6 commit ed87d4b

File tree

5 files changed

+1875
-0
lines changed

5 files changed

+1875
-0
lines changed

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,67 @@ For more information about MCP:
3131
- [Protocol Specification](https://modelcontextprotocol.io/specification/)
3232
- [GitHub Organization](https://github.com/modelcontextprotocol)
3333

34+
## Enterprise Auth / Enterprise Managed Authorization (SEP-990)
35+
36+
The SDK provides Enterprise Auth utilities for the Identity Assertion Authorization Grant flow (SEP-990),
37+
enabling enterprise SSO scenarios where users authenticate once via their enterprise Identity Provider and
38+
access MCP servers without per-server authorization prompts.
39+
40+
The flow consists of two token operations:
41+
1. **RFC 8693 Token Exchange** at the IdP: ID Token → JWT Authorization Grant (JAG)
42+
2. **RFC 7523 JWT Bearer Grant** at the MCP Server: JAG → Access Token
43+
44+
### Using the Layer 2 utilities directly
45+
46+
```csharp
47+
using ModelContextProtocol.Authentication;
48+
49+
// Step 1: Exchange ID token for a JAG at the enterprise IdP
50+
var jag = await EnterpriseAuth.DiscoverAndRequestJwtAuthorizationGrantAsync(
51+
new DiscoverAndRequestJwtAuthGrantOptions
52+
{
53+
IdpUrl = "https://company.okta.com",
54+
Audience = "https://auth.mcp-server.example.com",
55+
Resource = "https://mcp-server.example.com",
56+
IdToken = myIdToken, // obtained via SSO/OIDC login
57+
ClientId = "idp-client-id",
58+
});
59+
60+
// Step 2: Exchange JAG for an access token at the MCP authorization server
61+
var tokens = await EnterpriseAuth.ExchangeJwtBearerGrantAsync(
62+
new ExchangeJwtBearerGrantOptions
63+
{
64+
TokenEndpoint = "https://auth.mcp-server.example.com/token",
65+
Assertion = jag,
66+
ClientId = "mcp-client-id",
67+
});
68+
```
69+
70+
### Using the EnterpriseAuthProvider (Layer 3)
71+
72+
```csharp
73+
var provider = new EnterpriseAuthProvider(new EnterpriseAuthProviderOptions
74+
{
75+
ClientId = "mcp-client-id",
76+
AssertionCallback = async (context, ct) =>
77+
{
78+
return await EnterpriseAuth.DiscoverAndRequestJwtAuthorizationGrantAsync(
79+
new DiscoverAndRequestJwtAuthGrantOptions
80+
{
81+
IdpUrl = "https://company.okta.com",
82+
Audience = context.AuthorizationServerUrl.ToString(),
83+
Resource = context.ResourceUrl.ToString(),
84+
IdToken = myIdToken,
85+
ClientId = "idp-client-id",
86+
}, ct);
87+
}
88+
});
89+
90+
var tokens = await provider.GetAccessTokenAsync(
91+
resourceUrl: new Uri("https://mcp-server.example.com"),
92+
authorizationServerUrl: new Uri("https://auth.mcp-server.example.com"));
93+
```
94+
3495
## License
3596

3697
This project is licensed under the [Apache License 2.0](LICENSE).

0 commit comments

Comments
 (0)