kit_rs/auth/
mod.rs

1//! Authentication module for Kit framework
2//!
3//! Provides Laravel-like authentication with guards and middleware.
4//!
5//! # Overview
6//!
7//! Kit provides a simple, session-based authentication system:
8//!
9//! - `Auth` facade for login/logout operations
10//! - `AuthMiddleware` for protecting routes
11//! - `GuestMiddleware` for guest-only routes
12//! - `Authenticatable` trait for user models
13//! - `UserProvider` trait for user retrieval
14//!
15//! # Example
16//!
17//! ```rust,ignore
18//! use kit::{Auth, AuthMiddleware, GuestMiddleware};
19//!
20//! // In a controller
21//! if Auth::check() {
22//!     let user_id = Auth::id().unwrap();
23//! }
24//!
25//! // Get the currently authenticated user
26//! if let Some(user) = Auth::user().await? {
27//!     println!("User ID: {}", user.auth_identifier());
28//! }
29//!
30//! // Get as concrete User type
31//! if let Some(user) = Auth::user_as::<User>().await? {
32//!     println!("Welcome, user #{}!", user.id);
33//! }
34//!
35//! // Login
36//! Auth::login(user.id);
37//!
38//! // Logout
39//! Auth::logout();
40//!
41//! // In routes
42//! group!("/dashboard")
43//!     .middleware(AuthMiddleware::redirect_to("/login"))
44//!     .routes([...]);
45//!
46//! group!("/")
47//!     .middleware(GuestMiddleware::redirect_to("/dashboard"))
48//!     .routes([
49//!         get!("/login", auth::show_login),
50//!     ]);
51//! ```
52
53pub mod authenticatable;
54pub mod guard;
55pub mod middleware;
56pub mod provider;
57
58pub use authenticatable::Authenticatable;
59pub use guard::Auth;
60pub use middleware::{AuthMiddleware, GuestMiddleware};
61pub use provider::UserProvider;