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
fix(auth): validate token audience by default (#149)
Built-in providers now default the audience to the MCP server's resource identifier, with an explicit opt-out, instead of disabling audience validation.
Assisted-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Sergey Vilgelm <sergey@vilgelm.com>
Co-authored-by: Ali Hashemi <14126952+hashemix@users.noreply.github.com>
/// Documentation URL for this resource (optional)
57
58
pubresource_documentation:Option<String>,
59
+
/// Audience to validate the token's `aud` claim against.
60
+
/// When `None`, the audience defaults to `mcp_server_url` (the resource
61
+
/// identifier), unless `disable_audience_validation` is set.
62
+
pubvalidate_audience:Option<Audience>,
63
+
/// Disables audience validation entirely. Strongly discouraged: without it a
64
+
/// token issued for another resource can be replayed against this server.
65
+
pubdisable_audience_validation:bool,
58
66
}
59
67
60
68
/// Keycloak integration implementing `AuthProvider` for MCP servers.
@@ -165,11 +173,17 @@ impl KeycloakAuthProvider {
165
173
tracing::warn!("Keycloak token verification is missing both Introspection and UserInfo strategies. Please provide client_id and client_secret, or ensure openid is included as a required scope.")
166
174
};
167
175
176
+
let validate_audience = resolve_audience(
177
+
options.disable_audience_validation,
178
+
options.validate_audience.take(),
179
+
&options.mcp_server_url,
180
+
);
181
+
168
182
let token_verifier:Box<dynOauthTokenVerifier> = match options.token_verifier{
0 commit comments