Rely on the official ModelContextProtocol.AspNetCore authentication handler and SessionId#19
Rely on the official ModelContextProtocol.AspNetCore authentication handler and SessionId#19abdebek merged 11 commits intoabdebek:mainfrom
ModelContextProtocol.AspNetCore authentication handler and SessionId#19Conversation
|
@abdebek let me know what you think. We must leverage as much as possible from the Also see https://github.com/modelcontextprotocol/csharp-sdk/blob/main/samples/ProtectedMcpServer/Program.cs for the official sdk implementation |
ModelContextProtocol.AspNetCore authentication handlerModelContextProtocol.AspNetCore authentication handler and SessionId
|
Thank you so much, @erwinkramer. I agree that moving to the official ModelContextProtocol.AspNetCore auth handler is the right direction, and it aligns with what we’ve been aiming for. One thing to clarify: today MCPify includes a login_auth_code_pkce tool plus session storage to support OAuth 2.0 Authorization Code Flow with PKCE for non-browser clients (browser-based consent, code exchange, token persistence/refresh). With the custom auth subsystem removed, do you expect this functionality to be retained, replaced, or dropped? If replaced, what mechanism would support auth code flow for headless clients going forward? |
Well, it's not part of the mcp spec, but I understand its current use-cases. It still fills a gap that the mcp spec didn't work out yet. Just like machine-to-machine auth. Even with the changes in this PR, the whole auth-tool setup should still work. If anything, I'd make it separate from this project and move it to |
Agreed. Ideally, we shouldn't need anything like MCPify.Extensions, but that would still be cleaner. By the way, I saw your last commit after my earlier comment; I really like the way you setup the sessionId. Good job! |
|
@erwinkramer, thank you once again. Next, we'll strip out the login tool and make it even cleaner: less maintenance overhead, better reliability and security. |
This pull request removes the entire token validation and scope requirement subsystem from the
MCPify.Core.Authnamespace. The changes eliminate all code related to access token validation, JWT parsing, scope requirement configuration, and related options and result types. This significantly simplifies the authentication codebase by removing support for validating JWT tokens and checking scope requirements.The most important changes are:
Removal of token validation system:
IAccessTokenValidatorinterface, which defined the contract for validating access tokens.JwtAccessTokenValidatorimplementation, which handled JWT parsing and validation logic.TokenValidationOptionsclass, which provided configuration for token validation behavior.TokenValidationResultclass, which represented the outcome of token validation.Removal of scope requirement system:
ScopeRequirementandScopeRequirementStoreclasses, which defined and managed per-tool scope requirements and validation logic. [1] [2]Configuration cleanup:
TokenValidationOptionsandScopeRequirementfrom theMcpifyOptionsconfiguration class, eliminating configuration for token validation and scope requirements.McpifyOptions.csto remove unnecessary dependencies.