unilim-cas 1.0.1

A purrfect CAS authentication wrapper for Unilim.
Documentation
//! authentication client for the central authentication service of
//! [unilim](https://www.unilim.fr), the university of limoges.
//!
//! talks to the lemonldap::ng portal at `cas.unilim.fr` and covers the whole
//! session lifecycle:
//!
//! - [`CAS::initialize`] submits credentials and returns a [`PendingAuth`]
//!   holding the 2fa challenge.
//! - [`PendingAuth`] solves the challenge with an email code or a totp code,
//!   then [`PendingAuth::finish`] establishes the session.
//! - [`CAS::restore`] brings back a persisted session without solving 2fa
//!   again.
//! - [`CAS::service`] returns a ticket url for one of the supported
//!   [`Services`].
//! - [`CAS::authorize`], [`CAS::tokenize`] and [`CAS::userinfo`] handle the
//!   oauth2 flow of the portal.
//!
//! # quick start
//!
//! ```no_run
//! use unilim_cas::CAS;
//!
//! # async fn quick_start() -> unilim_cas::Result<()> {
//! // on first login, solve the 2fa challenge manually.
//! let mut auth = CAS::initialize("username", "password").await?;
//!
//! if !auth.solved {
//!     if auth.is_totp_available {
//!         auth.solve_with_totp("123456").await?;
//!     }
//!     else if auth.is_email_available {
//!         auth.send_email_code().await?;
//!         auth.solve_with_email_code("123456").await?;
//!     }
//! }
//!
//! let cas = auth.finish().await?;
//!
//! // store `cas.connection` and `cas.key` somewhere safe, then restore
//! // later without any 2fa prompt.
//! let cas = CAS::restore("username", "password", &cas.connection, &cas.key).await?;
//! # Ok(())
//! # }
//! ```
//!
//! # session model
//!
//! an established [`CAS`] session is made of three strings:
//!
//! - [`CAS::cookie`], the `lemonldap` session cookie sent on every request.
//! - [`CAS::connection`], the `llngconnection` persistence cookie obtained
//!   by registering the browser.
//! - [`CAS::key`], the totp secret answering the browser check during
//!   [`CAS::restore`].
//!
//! the session cookie expires quickly, so store the other two for the long
//! term.
//!
//! # features
//!
//! - `client`, the default, provides the native client documented here. http
//!   goes through [rikka](https://docs.rs/rikka), so it also runs on
//!   `wasm32`.
//! - `wasm` only provides the `unilim_cas::wasm` module, extern declarations
//!   of the `@unilim/cas` js classes for packages receiving the session from
//!   javascript. pulls no client code and only compiles on `wasm32`.

#[cfg(feature = "client")]
mod native;
#[cfg(feature = "client")]
pub use native::*;

#[cfg(all(target_arch = "wasm32", feature = "npm"))]
mod npm;

#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
pub mod wasm;