pub trait AuthProvider: Send + Sync {
// Required method
fn authenticate(
&self,
ctx: &McpContext,
request: AuthRequest<'_>,
) -> McpResult<AuthContext>;
}Expand description
Authentication provider interface.
Implementations decide whether a request is allowed and may return
an AuthContext describing the authenticated subject.
Required Methods§
Sourcefn authenticate(
&self,
ctx: &McpContext,
request: AuthRequest<'_>,
) -> McpResult<AuthContext>
fn authenticate( &self, ctx: &McpContext, request: AuthRequest<'_>, ) -> McpResult<AuthContext>
Authenticate an incoming request.
Return Ok(AuthContext) to allow, or an Err(McpError) to deny. When
admitting a credential, AuthContext::subject must be a nonempty,
stable, provider-scoped owner identifier. Scopes and claims are
authorization facts and are deliberately not session-owner identity.
Provider error messages and data are treated as private diagnostics and
are replaced at the framework boundary before middleware or peers see
them.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".