Skip to main content

Crate tesseral_axum

Crate tesseral_axum 

Source
Expand description

Tesseral SDK for axum.

Typically, you will construct an Authenticator, and then add require_auth to your router. From there, you can extract the Auth object from the request extensions.

use axum::{Router, routing::get};
use tesseral_axum::{Auth, Authenticator, require_auth};

let authenticator = Authenticator::new("publishable_key_...".into());

let app: Router = Router::new()
    .route("/", get(handler))
    .layer(require_auth(authenticator));

async fn handler(auth: Auth) -> String {
    format!("You work for {}", auth.organization_id())
}

Documentation: https://tesseral.com/docs/sdks/serverside-sdks/tesseral-sdk-axum

Re-exports§

pub use crate::auth::Auth;
pub use crate::auth::CredentialsType;

Modules§

auth

Structs§

Authenticator
Authenticates access tokens and API keys. Must be used with require_auth.
RequireAuth
A middleware service that requires authentication for all requests.
RequireAuthLayer
A middleware layer that requires authentication for all requests.

Functions§

require_auth
Middleware layer that requires requests be authenticated.