-
Notifications
You must be signed in to change notification settings - Fork 406
Authorization Support (Using ASP.NET Core Native AuthN/AuthZ Integration) #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/ModelContextProtocol.AspNetCore/Auth/McpAuthorizationExtensions.cs
Outdated
Show resolved
Hide resolved
src/ModelContextProtocol.AspNetCore/Auth/McpAuthorizationExtensions.cs
Outdated
Show resolved
Hide resolved
src/ModelContextProtocol.AspNetCore/Auth/McpAuthorizationExtensions.cs
Outdated
Show resolved
Hide resolved
src/ModelContextProtocol.AspNetCore/Auth/McpAuthorizationExtensions.cs
Outdated
Show resolved
Hide resolved
src/ModelContextProtocol.AspNetCore/Auth/McpAuthenticationResponseMiddlewareExtensions.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Stephen Halter <[email protected]>
Co-authored-by: Stephen Halter <[email protected]>
…sions.cs Co-authored-by: Stephen Halter <[email protected]>
src/ModelContextProtocol.AspNetCore/Auth/McpAuthorizationExtensions.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # tests/ModelContextProtocol.AspNetCore.Tests/HttpServerIntegrationTests.cs
…zation more reliable
Hi! I tried by passing ProtocolVersion in Below is the sc to show how mcp-remote handles it - and I think as first party SDK this should also consider old specs Thanks, |
# Conflicts: # src/ModelContextProtocol.Core/Client/StreamableHttpClientSessionTransport.cs
Aiming for a merge in the next couple of days. Need to run a few extra tests. |
@localden I was trying to integrate with Auth0, and having some issue. I am using Client Id / Secrect so Dynamic Client Registration is off. As per the documentation authorization-code-flow-with-pkce we should pass audience however from As of now, my soln is like below, which works - ClientOAuthOptions.cs BuildAuthorizationUrl in ClientOAuthProvider.cs
ExchangeCodeForTokenAsync in ClientOAuthProvider.cs
essentially add the above block whereever required. and finally from Client
potentially, Another question in slightly different note, How do I get AccessToken and RefreshToken which we received from auth server for that McpTool. My scenario is - User will authenticate MCPtool in client but tool will be invoked from SignalR hub using SK, I would like to pass the same accesstoken in header which i received from client |
…id-configuration in TestOAuthServer
@anktsrkr ASP.NET Core has something similar to your proposed
You can use IHttpContextAccessor in |
- This takes inspiration from ASP.NET Core's OAuthOptions.AdditionalAuthorizationParameters
@halter73 thanks for considering and i could see it is now added, just tested works well!
Regarding the above do you have any feedback? I modified the code to ignore if RM is not available and worked, so wanted to check whether it is something we have in backlog ? Btw Huge round of applause for merging it! |
Implements the authorization flow for clients and servers, per specification. Instead of re-implementing everything from scratch, this follows the suggestions from #349 and uses the native ASP.NET Core constructs to handle post-discovery steps server-side.
Developer experience
Server
HTTP context in tools
.AddHttpContextAccessor
is used to ensure that tools can access the HTTP context (such as the authorization header contents).Tools that want to use the HTTP context will need to amend their signatures to include a reference to
IHttpContextAccessor
, like this:Client
Fixes #521