feat: Add Enterprise Managed Authorization (SEP-990) support#607
Open
prachi-okta wants to merge 3 commits intomodelcontextprotocol:mainfrom
Open
feat: Add Enterprise Managed Authorization (SEP-990) support#607prachi-okta wants to merge 3 commits intomodelcontextprotocol:mainfrom
prachi-okta wants to merge 3 commits intomodelcontextprotocol:mainfrom
Conversation
kpavlov
reviewed
Mar 17, 2026
Contributor
kpavlov
left a comment
There was a problem hiding this comment.
Thank you, @prachi-okta
I see this plugin is pretty generic and does not have any MCP-specifics. Not sure if it should belong to this project.
Did you consider submitting a PR to the Ktor project instead?
cc: @e5l
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements Enterprise Managed Authorization (SEP-990) for the Kotlin MCP SDK
Enables MCP clients to leverage enterprise Identity Providers for seamless authorization without per-server user authentication.
Motivation and Context
Enterprise environments require OAuth flows where users authenticate with a centralized IdP, and applications need to securely access protected MCP resources on their behalf. SEP-990 addresses this via:
This follows the same provider pattern as existing auth implementations and is consistent with the Java, TypeScript, C#, and Go SDK implementations. The provider is implemented as a Ktor
HttpClientPluginthat intercepts outgoing requests viaHttpSend, making it a first-class citizen of the Ktor client ecosystem.How Has This Been Tested?
Added 32 unit tests across two test classes using Kotlin Multiplatform (
commonTest), Kotest assertions, and KtorMockEngine:EnterpriseAuthTest(20 tests):oauth-authorization-server, fallback toopenid-configurationon 404/500, both-fail error, trailing slash strippingissued_token_typethrows, non-standardtoken_typesucceeds (informational per RFC 8693 §2.2.1), missingaccess_tokenthrows, HTTP error throwsdiscoverAndRequestJwtAuthorizationGrant— full discovery flow, skips discovery whenidpTokenEndpointprovided, notoken_endpointin metadata throwsexpiresAtcomputed from monotonic clock, missingaccess_tokenthrows, HTTP error throwsisExpired— nullexpiresAt, futureexpiresAt, pastexpiresAtEnterpriseAuthProviderTest(12 tests):Authorization: Bearerheader injection via Ktor plugininvalidateCacheforces re-fetch on next requestresourceUrlandauthorizationServerUrlpassed to callbackpreparevalidation —clientIdnull throws,assertionCallbacknull throwsIllegalArgumentExceptionexpires_incached indefinitelyexpiryBufferrespectedBreaking Changes
None — this is a purely additive feature. No existing APIs are modified.
Types of changes
Checklist
./gradlew :kotlin-sdk-client:jvmTest)./gradlew apiCheckpassesAdditional context
Key design decisions:
EnterpriseAuthProviderimplementsHttpClientPlugin<Config, EnterpriseAuthProvider>, installed viainstall(EnterpriseAuthProvider) { ... }DSL; usesHttpSendinterceptor for transparent header injectionclient_secret_basic(Basic Auth header) used for JWT bearer grant, aligned with SEP-990 conformance requirements (RFC 6749 §2.3.1)token_typein JAG response is not strictly validated per RFC 8693 §2.2.1 — it is informational and strict checking rejects conformant IdPsTimeSource.Monotonic) used for token expiry to avoid wall-clock skew issuesMutexfor thread-safe token caching on coroutinesRelated SDK implementations: