Skip to main content

rskit_auth/
traits.rs

1use async_trait::async_trait;
2use rskit_errors::AppResult;
3
4/// Validates a bearer token and returns the extracted claims.
5#[async_trait]
6pub trait TokenValidator<C>: Send + Sync {
7    /// Validate `token` and extract claims of type `C`.
8    async fn validate(&self, token: &str) -> AppResult<C>;
9}
10
11/// Generates a signed bearer token from claims.
12#[async_trait]
13pub trait TokenGenerator<C>: Send + Sync {
14    /// Sign `claims` and return the token string.
15    async fn generate(&self, claims: &C) -> AppResult<String>;
16}