pas-external 0.6.0

Ppoppo Accounts System (PAS) external SDK — OAuth2 PKCE, JWT verification port, Axum middleware, session liveness
Documentation
//! Plug-and-play PAS authentication middleware for Axum.
//!
//! This module eliminates OAuth2 boilerplate for Axum applications
//! integrating with [PAS](https://accounts.ppoppo.com) (Ppoppo Accounts System).
//!
//! # Quick Start
//!
//! ```rust,ignore
//! use pas_external::middleware::{PasAuth, PasAuthConfig, SessionResolution};
//!
//! // 1. Implement AccountResolver and SessionStore for your app.
//! //    Typical pattern: one PasAdapter implements both; share a
//! //    single Arc<PasAdapter>. AuthContext (returned from
//! //    SessionStore::find) must impl SvAware.
//! // 2. Configure from environment, including the refresh-token cipher.
//! let cipher = TokenCipher::from_base64_key(&std::env::var("REFRESH_TOKEN_KEY")?)?;
//! let config = PasAuthConfig::from_env()?
//!     .with_refresh_token_cipher(cipher);
//!
//! // 3. Bundle the router + a matching SessionValidator.
//! let pas_auth = PasAuth::new(
//!     config,
//!     Arc::clone(&adapter),  // AccountResolver
//!     Arc::clone(&adapter),  // SessionStore (also returns ciphertext via get_refresh_ciphertext)
//! );
//! let validator = pas_auth.session_validator();
//!
//! // 4. Mount the router.
//! let app = axum::Router::new()
//!     .merge(pas_auth.into_router());
//!
//! // 5. Use the validator in your own middleware.
//! match validator.validate(&jar).await? {
//!     SessionResolution::Authenticated(ctx) => { /* happy path */ }
//!     SessionResolution::Expired            => { /* cookie stale */ }
//!     SessionResolution::NoCookie           => { /* first visit */ }
//! }
//! ```

mod auth;
mod config;
mod cookies;
mod error;
mod extractor;
mod routes;
mod session;
mod state;
mod sv;
mod validator;
mod sv_cache;
mod traits;
mod types;

pub use auth::PasAuth;
pub use config::PasAuthConfig;
pub use error::AuthError;
pub use extractor::AuthPpnum;
pub use session::{SessionResolution, SessionResolver};
pub use validator::SessionValidator;
pub use sv_cache::{MemorySvBackend, SvCachePort};
pub use traits::{AccountResolver, SessionStore, SvAware};
pub use types::NewSession;

/// Re-export cookie key type for builder API.
pub use axum_extra::extract::cookie::Key as CookieKey;