Uh oh!
There was an error while loading. Please reload this page.
Validate origin header - #771
Conversation
- Fixes#695 - Does not implement Host header validation yet Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>
e5624d4 to
68ed795Compare| @Test | ||
| void differentSchemeWithWildcard() { | ||
| var headers = originHeader("https://localhost:3000"); |
There was a problem hiding this comment.
shouldn't the port be 8080 to ensure that it fails because of the schema?
There was a problem hiding this comment.
It's using the the wildcard validator, so the port does not matter:
privatefinalDefaultServerTransportSecurityValidatorwildcardValidator =
DefaultServerTransportSecurityValidator
.builder()
.allowedOrigin("http://localhost:*")
.build();Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| try { | ||
| Map<String, List<String>> headers = extractHeaders(request); | ||
| this.securityValidator.validateHeaders(headers); | ||
| } | ||
| catch (ServerTransportSecurityException e) { | ||
| response.sendError(e.getStatusCode(), e.getMessage()); | ||
| return; | ||
| } |
There was a problem hiding this comment.
This code is duplicated across three implementations, perhaps we can have a centralized static utility for it?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Fixes#695 . Updates conformance tests.
Contents
Add Origin header validation for HTTP-based MCP server transports so servers can restrict which origins can connect (e.g. browser or cross-origin clients).
Introduces new
ServerTransportSecurityValidatorinterface, to validate transport-level security. Default behavior stays permissive: transports useServerTransportSecurityValidator.NOOPunless a validator is set via the builder.The provided implementation is
DefaultServerTransportSecurityValidatorand only validates the Origin header, for now.New APIs: example usage
Points of interest
Integration tests use the new JUnit 6
@ParameterizedClassAPI, which is another way of implementation "abstract base classes" for tests.