Skip to main content

rustbasic_passport/
lib.rs

1//! OAuth2 server and personal access tokens for Rust applications.
2//!
3//! `rustbasic-passport` is a port of [`laravel/passport`](https://github.com/laravel/passport)
4//! to the Rust ecosystem. It provides:
5//!
6//! - `authorization_code` grant with PKCE (S256 / plain)
7//! - `password` grant
8//! - `client_credentials` grant
9//! - `refresh_token` grant with rotation
10//! - Device Authorization grant (RFC 8628): `issue_device_code` + `approve_device_code`
11//! - `personal_access` grant and `create_personal_access_token`
12//! - per-client `grant_types` (Passport 13.x schema)
13//! - JWT access tokens signed with RS256 (RFC 7519), revoked via the token store
14//! - an optional `axum` integration: routes and auth / scope middleware
15//! - an optional `loco` integration: loco.rs `Routes` / `Initializer`
16//!
17//! ```text
18//! let stores = StoreBundle::new(clients, tokens, auth_codes, refresh_tokens, device_codes, users);
19//! let server = PassportServer::new(stores, SigningKey::generate("default")?, Config::default());
20//!
21//! let response = server.issue_token(&TokenRequest {
22//!     grant_type: Some("password".into()),
23//!     client_id: Some("web".into()),
24//!     client_secret: Some("secret".into()),
25//!     username: Some("user@example.com".into()),
26//!     password: Some("password".into()),
27//!     ..Default::default()
28//! }).await?;
29//! ```
30//!
31//! Complete working examples: `examples/in_memory.rs` (full flow, no framework) and
32//! `examples/axum_server.rs` (axum middleware + routes).
33
34pub mod entity;
35pub mod error;
36pub mod jwt;
37pub mod server;
38pub mod store;
39
40#[cfg(feature = "axum")]
41pub mod axum;
42
43#[cfg(feature = "loco")]
44pub mod loco;
45
46pub use entity::*;
47pub use error::*;
48pub use server::*;
49pub use store::*;