prisma_auth 0.2.0

A simple authentication crate supporting both Rocket backend API and Yew frontend authentication components
Documentation
// src/lib.rs

//! Simple authentication for Rust web apps with JWT tokens and user management.
//!
//! Supports both Rocket backends and Yew frontends with role-based permissions.
//!
//! # Quick Start
//!
//! ## Backend (Rocket)
//!
//! ```rust
//! use rocket::State;
//! use prisma_auth::multi_user::{AuthService, MultiUserTokenStore, MultiUserAuthGuard, multi_user_login_handler};
//! use prisma_auth::storage::InMemoryStorage;
//! use prisma_auth::{LoginRequest, TokenResponse};
//!
//! #[rocket::post("/login", format = "json", data = "<body>")]
//! pub fn login(
//!     body: Json<LoginRequest>,
//!     token_store: &State<MultiUserTokenStore>,
//!     auth_service: &State<AuthService<InMemoryStorage>>,
//! ) -> Result<Json<TokenResponse>, Status> {
//!     multi_user_login_handler(body, token_store, auth_service)
//! }
//!
//! #[rocket::get("/protected")]
//! pub fn protected_route(auth: MultiUserAuthGuard) -> String {
//!     format!("Hello, {}! Your role: {}", auth.username, auth.role)
//! }
//!
//! #[launch]
//! fn rocket() -> _ {
//!     let storage = InMemoryStorage::new().with_default_roles();
//!     let auth_service = AuthService::new(storage);
//!
//!     rocket::build()
//!         .manage(MultiUserTokenStore::new())
//!         .manage(auth_service)
//!         .mount("/api", routes![login, protected_route])
//! }
//! ```
//!
//! ## Frontend (Yew)
//!
//! ```rust
//! use yew::prelude::*;
//! use prisma_auth::frontend::{MultiUserLoginComponent, AuthGuardComponent, UserInfo};
//!
//! #[function_component(App)]
//! pub fn app() -> Html {
//!     let on_success = Callback::from(|user_info: UserInfo| {
//!         web_sys::console::log_1(&format!("Login successful! User: {}", user_info.username).into());
//!     });
//!
//!     html! {
//!         <div>
//!             <MultiUserLoginComponent
//!                 api_base_url={"http://localhost:8000/api".to_string()}
//!                 on_success={on_success}
//!                 title={"My App".to_string()}
//!                 show_username={true}
//!             />
//!
//!             <AuthGuardComponent>
//!                 <div>{"This content is only visible to authenticated users"}</div>
//!             </AuthGuardComponent>
//!         </div>
//!     }
//! }
//! ```

/// Data types for authentication requests and responses
pub mod types;
/// Error handling for authentication operations
pub mod error;

#[cfg(feature = "rocket_backend")]
/// Rocket route handlers for authentication endpoints
pub mod backend;

#[cfg(feature = "rocket_backend")]
/// User and role data storage implementations
pub mod storage;

#[cfg(feature = "rocket_backend")]
/// Multi-user authentication service with role management
pub mod multi_user;

#[cfg(feature = "yew_frontend")]
/// Yew components and utilities for frontend authentication
pub mod frontend;

pub use types::*;
pub use error::AuthError;