Skip to content

Commit e3f4b88

Browse files
sveneldVolodymyr Panivko
andauthored
[Server] Oauth2 based on middleware (#221)
* Add Middleware handlers to StreamableHttpTransport * OAuth Implementation based on middleware * OAuth Implementation based on middleware * Add Middleware handlers to StreamableHttpTransport * OAuth Implementation based on middleware * OAuth Implementation based on middleware Signed-off-by: Volodymyr Panivko <sveneld300@gmail.com> * Address PR review feedback for OAuth middleware * Apply php-cs-fixer to satisfy QA * Use Mcp exception classes in OAuth middleware * Refactor OAuth HTTP stack and add Microsoft example policies * Fix QA PHPStan findings in OAuth examples and auth middleware * Require OIDC discovery in JWKS provider and refine OAuth proxy behavior * Remove local development docker artifacts from VCS * Revert .gitignore changes for local docker files * Fix body retrieval in OAuthRequestMetaMiddleware for proper string conversion Signed-off-by: Volodymyr Panivko <sveneld300@gmail.com> * Address OAuth PR review feedback and align example configs * Fix QA style issues and add authorization docs * Fix PHPStan typing issues in OAuth middleware * Remove duplicate Middleware namespace, consolidate under Http\Middleware Remove old Mcp\Server\Transport\Middleware\ classes that were duplicated in Mcp\Server\Transport\Http\Middleware\ and Http\OAuth\. Update docs to reference the correct namespaces. * Address PR review: replace Throwable catch with specific exceptions, add JSON_THROW_ON_ERROR - JwtTokenValidator: replace catch(\Throwable) with explicit \InvalidArgumentException|\UnexpectedValueException|\DomainException, letting RuntimeException from JwksProvider propagate as infrastructure errors - OAuthProxyMiddleware: add \JSON_THROW_ON_ERROR to json_encode for metadata response - Update tests to expect RuntimeException for JWKS infrastructure failures --------- Signed-off-by: Volodymyr Panivko <sveneld300@gmail.com> Co-authored-by: Volodymyr Panivko <volodymyr.panivko@togethernetworks.com>
1 parent 61c20f1 commit e3f4b88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+6038
-0
lines changed

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"psr/clock": "^1.0",
2727
"psr/container": "^1.0 || ^2.0",
2828
"psr/event-dispatcher": "^1.0",
29+
"psr/http-client": "^1.0",
2930
"psr/http-factory": "^1.1",
3031
"psr/http-message": "^1.1 || ^2.0",
3132
"psr/http-server-handler": "^1.0",
@@ -35,6 +36,8 @@
3536
"symfony/uid": "^5.4 || ^6.4 || ^7.3 || ^8.0"
3637
},
3738
"require-dev": {
39+
"ext-openssl": "*",
40+
"firebase/php-jwt": "^6.10 || ^7.0",
3841
"laminas/laminas-httphandlerrunner": "^2.12",
3942
"nyholm/psr7": "^1.8",
4043
"nyholm/psr7-server": "^1.1",
@@ -46,6 +49,7 @@
4649
"psr/simple-cache": "^2.0 || ^3.0",
4750
"symfony/cache": "^5.4 || ^6.4 || ^7.3 || ^8.0",
4851
"symfony/console": "^5.4 || ^6.4 || ^7.3 || ^8.0",
52+
"symfony/http-client": "^5.4 || ^6.4 || ^7.3 || ^8.0",
4953
"symfony/process": "^5.4 || ^6.4 || ^7.3 || ^8.0"
5054
},
5155
"autoload": {
@@ -68,6 +72,8 @@
6872
"Mcp\\Example\\Server\\DiscoveryUserProfile\\": "examples/server/discovery-userprofile/",
6973
"Mcp\\Example\\Server\\EnvVariables\\": "examples/server/env-variables/",
7074
"Mcp\\Example\\Server\\ExplicitRegistration\\": "examples/server/explicit-registration/",
75+
"Mcp\\Example\\Server\\OAuthKeycloak\\": "examples/server/oauth-keycloak/",
76+
"Mcp\\Example\\Server\\OAuthMicrosoft\\": "examples/server/oauth-microsoft/",
7177
"Mcp\\Example\\Server\\SchemaShowcase\\": "examples/server/schema-showcase/",
7278
"Mcp\\Tests\\": "tests/"
7379
}

0 commit comments

Comments
 (0)