Skip to main content

TokenValidator

Trait TokenValidator 

Source
pub trait TokenValidator:
    Send
    + Sync
    + 'static {
    // Required method
    fn validate<'a>(
        &'a self,
        token: &'a str,
    ) -> BoxFuture<'a, Result<TokenInfo, String>>;
}
Expand description

Token validator trait for authenticating WebSocket connections.

Implementations validate bearer tokens (JWT or otherwise) and return the validated token information including user identity and expiration.

The trait is object-safe (returns BoxFuture) so it can be stored as Arc<dyn TokenValidator> and mounted in build_base_router without adding a type parameter to Server<A>.

§Production implementation

JwtTokenValidator wraps the existing OidcValidator from fraiseql-core, reusing the same JWT validation path as the GraphQL endpoint’s OIDC middleware.

Required Methods§

Source

fn validate<'a>( &'a self, token: &'a str, ) -> BoxFuture<'a, Result<TokenInfo, String>>

Validate a bearer token and return the token info.

§Errors

Returns an error string if the token is invalid, expired, or cannot be validated.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§