You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mcp-core/src/main/java/io/modelcontextprotocol/server/transport/DefaultServerTransportSecurityValidator.java
+83-8Lines changed: 83 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,11 @@
12
12
13
13
/**
14
14
* Default implementation of {@link ServerTransportSecurityValidator} that validates the
15
-
* Origin header against a list of allowed origins.
15
+
* Origin and Host headers against lists of allowed values.
16
16
*
17
17
* <p>
18
-
* Supports exact matches and wildcard port patterns (e.g., "http://example.com:*").
18
+
* Supports exact matches and wildcard port patterns (e.g., "http://example.com:*" for
19
+
* origins, "example.com:*" for hosts).
19
20
*
20
21
* @author Daniel Garnier-Moiroux
21
22
* @see ServerTransportSecurityValidator
@@ -25,29 +26,49 @@ public final class DefaultServerTransportSecurityValidator implements ServerTran
25
26
26
27
privatestaticfinalStringORIGIN_HEADER = "Origin";
27
28
29
+
privatestaticfinalStringHOST_HEADER = "Host";
30
+
28
31
privatefinalList<String> allowedOrigins;
29
32
33
+
privatefinalList<String> allowedHosts;
34
+
30
35
/**
31
-
* Creates a new validator with the specified allowed origins.
36
+
* Creates a new validator with the specified allowed origins and hosts.
32
37
* @param allowedOrigins List of allowed origin patterns. Supports exact matches
33
38
* (e.g., "http://example.com:8080") and wildcard ports (e.g., "http://example.com:*")
39
+
* @param allowedHosts List of allowed host patterns. Supports exact matches (e.g.,
40
+
* "example.com:8080") and wildcard ports (e.g., "example.com:*")
0 commit comments