Package io.meeds.mcp.server.plugin
Class McpServerOauthOpaqueTokenIntrospector
java.lang.Object
io.meeds.mcp.server.plugin.McpServerOauthOpaqueTokenIntrospector
- All Implemented Interfaces:
org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector
@Component
public class McpServerOauthOpaqueTokenIntrospector
extends Object
implements org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.oauth2.server.resource.introspection.SpringOpaqueTokenIntrospectororg.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipalintrospect(String token) Validates an opaque access token before anything under/mcpruns.
-
Constructor Details
-
McpServerOauthOpaqueTokenIntrospector
public McpServerOauthOpaqueTokenIntrospector()
-
-
Method Details
-
introspect
public org.springframework.security.oauth2.core.OAuth2AuthenticatedPrincipal introspect(String token) Validates an opaque access token before anything under/mcpruns.validateMcpAudience(OAuth2AuthenticatedPrincipal)is the enforcement point of the MCP access gate on the request path, and covers the whole surface —initialize,tools/list,tools/calland the SSE stream alike. Being here also means it is re-evaluated on every request, so narrowing the audience takes a user's access away at once instead of at the expiry of a token already issued to them. One residual: an SSE stream already open when the audience narrows is not re-introspected, so server-to-client notifications keep flowing on it until it drops. Every new request, on that session or any other, is refused.- Specified by:
introspectin interfaceorg.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector- Parameters:
token- the opaque bearer token presented by the caller- Returns:
- the authenticated principal, carrying its scope authorities
-
getDelegate
public org.springframework.security.oauth2.server.resource.introspection.SpringOpaqueTokenIntrospector getDelegate()- Returns:
- the Spring introspector doing the actual call to the authorization server's introspection endpoint, built lazily because the internal client secret it authenticates with is generated on first use
-