1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! # ironflow-auth
//!
//! Authentication library for the **ironflow** workflow engine.
//!
//! - JWT access + refresh tokens (HS256)
//! - Argon2id password hashing
//! - HttpOnly cookie management
//! - Axum `AuthenticatedUser` extractor
//!
//! # Quick start
//!
//! ```no_run
//! use ironflow_auth::jwt::{JwtConfig, AccessToken, RefreshToken};
//! use ironflow_auth::password;
//! use uuid::Uuid;
//!
//! # fn example() -> Result<(), ironflow_auth::error::AuthError> {
//! let config = JwtConfig {
//! secret: "my-secret".to_string(),
//! access_token_ttl_secs: 900,
//! refresh_token_ttl_secs: 604800,
//! cookie_domain: None,
//! cookie_secure: false,
//! };
//!
//! let hash = password::hash("hunter2")?;
//! assert!(password::verify("hunter2", &hash)?);
//!
//! let user_id = Uuid::now_v7();
//! let access = AccessToken::for_user(user_id, "alice", false, &config)?;
//! let claims = AccessToken::decode(&access.0, &config)?;
//! assert_eq!(claims.user_id, user_id);
//! # Ok(())
//! # }
//! ```