Skip to main content

Crate rustbasic_passport

Crate rustbasic_passport 

Source
Expand description

OAuth2 server and personal access tokens for Rust applications.

rustbasic-passport is a port of laravel/passport to the Rust ecosystem. It provides:

  • authorization_code grant with PKCE (S256 / plain)
  • password grant
  • client_credentials grant
  • refresh_token grant with rotation
  • Device Authorization grant (RFC 8628): issue_device_code + approve_device_code
  • personal_access grant and create_personal_access_token
  • per-client grant_types (Passport 13.x schema)
  • JWT access tokens signed with RS256 (RFC 7519), revoked via the token store
  • an optional axum integration: routes and auth / scope middleware
  • an optional loco integration: loco.rs Routes / Initializer
let stores = StoreBundle::new(clients, tokens, auth_codes, refresh_tokens, device_codes, users);
let server = PassportServer::new(stores, SigningKey::generate("default")?, Config::default());

let response = server.issue_token(&TokenRequest {
    grant_type: Some("password".into()),
    client_id: Some("web".into()),
    client_secret: Some("secret".into()),
    username: Some("user@example.com".into()),
    password: Some("password".into()),
    ..Default::default()
}).await?;

Complete working examples: examples/in_memory.rs (full flow, no framework) and examples/axum_server.rs (axum middleware + routes).

Re-exports§

pub use entity::*;
pub use error::*;
pub use server::*;
pub use store::*;

Modules§

entity
error
jwt
server
store