Expand description
Core implementation for the Axess authentication and authorization library.
§Re-export strategy
Public types have one canonical location (the module that defines or
that owns the canonical re-export from a sibling crate) and may also be
convenience-re-exported at the crate root. Adopters can use either path;
the canonical path is what rustdoc displays. When in doubt, prefer the
canonical path in import statements; it survives crate-root churn.
| Concern | Canonical | Crate-root convenience |
|---|---|---|
| Session state | session::* | (none; depth-2 access only) |
| Authn service / state machine | authn::* | (none) |
| Authn factor configs | authn::factor::* | (none) |
| Authn errors | authn::error::* | (none) |
| Authz policy / decision | authz::* | (none) |
| Identity (principal, IDs) | principal::* (re-exports axess-identity) | (none) |
| Clock / RNG (DST foundation) | axess_clock::* / axess_rng::* | Clock, SecureRng, SystemClock, SystemRng |
| Health checks | health::* | HealthCheck, HealthStatus, CompositeHealthCheck |
| Authn metrics | metrics::* | AuthnMetrics, NoopMetrics |
| Middleware (CSRF, rate-limit, request-id, trace-id) | middleware::* | RateLimitLayer + helpers; RequestIdLayer (feature-gated); TraceIdLayer + TraceContext (feature-gated) |
| Test fixtures | testing::* (gated cfg(any(test, feature = "testing"))) | MockClock, MockRng, MockIdentityStore, … |
Why some types have crate-root convenience and others don’t: the
ones promoted to the crate root are either DST primitives that every
adopter touches (Clock, SecureRng) or framework integration points
that read naturally as axess_core::RateLimitLayer. Authn / authz
types stay at depth-2 so the import line reveals which layer the
type belongs to. Useful when reading a route handler that mixes
authn and authz concerns.
§Feature flags
| Feature | What it enables |
|---|---|
authz | Cedar Policy authorization (RBAC + ABAC + ReBAC). On by default. |
device | First-class device::Device identity with three-stage assurance ladder (Unknown → Seen → Trusted, plus terminal Revoked), per-tenant fingerprint pepper, refresh-family cascade, retention sweep, and CachedDeviceStore decorator. On by default. Pair with sqlite / postgres / mysql / valkey for persistent backends (SqliteDeviceStore, PostgresDeviceStore, MysqlDeviceStore, ValkeyDeviceStore). See device and docs/identity/device.md. |
memory | In-memory session store and registry (MemorySessionStore, MemorySessionRegistry). Dev/test only, not in default features. Production builds without this flag cannot import these types. |
sqlite | SQLite session store with AES-256-GCM encryption. |
postgres | PostgreSQL session store with AES-256-GCM encryption. |
valkey | Valkey/Redis session store and registry with optional encryption. |
fido2 | FIDO2/WebAuthn passkey authentication. |
oauth | OAuth 2.0 / OIDC (AuthCode+PKCE, Client Credentials, Device Code). |
ldap | LDAP bind authentication (Active Directory, OpenLDAP). |
request-id | X-Request-Id middleware. |
trace-id | W3C Trace Context (traceparent) middleware. |
default-error-response | Built-in IntoResponse mapping for AuthnError (on by default). Disable to ship your own HTTP mapping; see authn::error for the recommended status-code table. |
full | All of the above. |
Internal features (used by the library, not intended for direct use):
accept_client_id.
Re-exports§
pub use session::AuthSession;pub use session::AuthState;pub use session::RefreshError;pub use session::RefreshToken;pub use session::RefreshTokenConfig;pub use session::RefreshTokenStore;pub use session::SessionBinding;pub use session::SessionConfig;pub use session::SessionConfigBuilder;pub use session::SessionData;pub use session::SessionLayer;pub use session::SessionRegistry;pub use session::SessionRegistryAdapter;pub use session::SessionRegistryHandle;pub use session::SessionRevoker;pub use session::SessionStore;pub use session::UserAgentBinding;pub use session::MemorySessionRegistry;memorypub use session::MemorySessionStore;memorypub use authn::AuditContext;pub use authn::AuditQuery;pub use authn::AuthEvent;pub use authn::AuthEventBuilder;pub use authn::AuthEventStatus;pub use authn::AuthEventType;pub use authn::AuthMethod;pub use authn::AuthnBackend;pub use authn::AuthnError;pub use authn::AuthnScope;pub use authn::AuthnService;pub use authn::EntityState;pub use authn::EventQueryFilter;pub use authn::FactorConfig;pub use authn::FactorCredential;pub use authn::FactorKind;pub use authn::FactorOutcome;pub use authn::FactorStep;pub use authn::FactorStore;pub use authn::FactorTemplate;pub use authn::FederatedProvider;pub use authn::IdentityAdmin;pub use authn::IdentityAuthnLog;pub use authn::IdentityLookup;pub use authn::IdentityStore;pub use authn::IpPolicy;pub use authn::LdapBindFactorConfig;pub use authn::LockoutPolicy;pub use authn::LoginOutcome;pub use authn::NoSessionRegistryError;pub use authn::NoopAuthnLog;pub use authn::PrepareOutcome;pub use authn::ProvisioningError;pub use authn::SessionValidator;pub use authn::SignupOutcome;pub use authn::StatusDetail;pub use authn::Tenant;pub use authn::TenantBootstrap;pub use authn::User;pub use authn::create_tenant;pub use authn::default_catalog;pub use authn::extract_audit_context;pub use authn::extract_audit_context_async;pub use authn::require_valid_session;pub use authz::AuthzDecision;authzpub use authz::AuthzDenied;authzpub use authz::AuthzEntityProvider;authzpub use authz::AuthzError;authzpub use authz::AuthzSession;authzpub use authz::AuthzStore;authzpub use authz::BuildRequestContext;authzpub use authz::NoContext;authzpub use authz::PolicyEvaluator;authzpub use authz::PolicyStore;authzpub use authz::StandardRequestContext;authzpub use authz::ip_from_headers;authzpub use authz::make_action_uid;authzpub use authz::make_entity_uid;authzpub use session::storage::in_memory_backend::InMemoryBackend;testingpub use session::storage::sqlite::SqliteSessionStore;sqlitepub use session::storage::postgres::PostgresSessionStore;postgrespub use session::storage::postgres::PostgresStoreError;postgrespub use session::storage::mysql::MysqlSessionStore;mysqlpub use session::storage::mysql::MysqlStoreError;mysqlpub use session::storage::valkey::ValkeySessionRegistry;valkeypub use session::storage::valkey::ValkeySessionStore;valkeypub use session::storage::valkey::ValkeyStoreError;valkeypub use device::AttestationClass;devicepub use device::CachedDeviceStore;devicepub use device::DefaultFingerprintExtractor;devicepub use device::Device;devicepub use device::DeviceBinding;devicepub use device::DeviceEventSink;devicepub use device::DeviceFingerprintExtractor;devicepub use device::DeviceLifecycleService;devicepub use device::DevicePiiCategory;devicepub use device::DevicePiiMapping;devicepub use device::DevicePiiResolver;devicepub use device::DevicePiiStore;devicepub use device::DeviceResolver;devicepub use device::DeviceStore;devicepub use device::DeviceTrustLevel;devicepub use device::FingerprintHash;devicepub use device::LifecycleDeviceResolver;devicepub use device::MemoryDevicePiiStore;devicepub use device::MemoryDevicePiiStoreError;devicepub use device::MemoryDeviceStore;devicepub use device::MemoryDeviceStoreError;devicepub use device::NoopDeviceEventSink;devicepub use device::NoopDeviceResolver;devicepub use device::PiiToken;devicepub use device::REDACTED_PLACEHOLDER;devicepub use device::RedactedResolver;devicepub use device::SweepConfig;devicepub use device::SweepConfigBuilder;devicepub use device::SweepCounts;devicepub use device::TenantPepperResolver;devicepub use device::cascade_revoke_by_refresh_family;devicepub use device::cascade_revoke_devices;devicepub use authn::service::StepUpPolicy;devicepub use authn::service::StepUpPolicyBuilder;devicepub use authn::service::decide_step_up;devicepub use device::storage::SqlDeviceStoreError;deviceand (mysqlorpostgresorsqlite)pub use device::storage::SqliteDeviceStore;deviceandsqlitepub use device::storage::PostgresDeviceStore;deviceandpostgrespub use device::storage::MysqlDeviceStore;deviceandmysqlpub use device::storage::ValkeyDeviceStore;deviceandvalkeypub use device::storage::ValkeyDeviceStoreError;deviceandvalkeypub use principal::AuthHumanPrincipal;pub use principal::AuthPrincipal;pub use principal::AuthWorkloadPrincipal;pub use principal::PrincipalRejection;pub use principal::SessionResolver;pub use principal::ToCedarEntity;authzpub use session::hmac;pub use health::CompositeHealthCheck;pub use health::CompositeStatus;pub use health::HealthCheck;pub use health::HealthStatus;pub use metrics::AuthnMetrics;pub use metrics::NoopMetrics;pub use testing::mock_tracing::TracingCapture;testingpub use testing::MemoryRefreshStoreError;testingpub use testing::MemoryRefreshTokenStore;testingpub use testing::MockFactorStore;testingpub use testing::MockIdentityStore;testingpub use testing::mock_policy::MockEntityProvider;authzand (testing)pub use testing::mock_policy::MockPolicyEvaluator;authzand (testing)pub use middleware::request_id::RequestIdLayer;request-idpub use middleware::trace_id::TraceContext;trace-idpub use middleware::trace_id::TraceContextLayer;trace-idpub use middleware::trace_id::TraceIdLayer;trace-idpub use middleware::ratelimit::KeyExtractor;pub use middleware::ratelimit::RateLimitConfig;pub use middleware::ratelimit::RateLimitConfigBuilder;pub use middleware::ratelimit::RateLimitLayer;pub use middleware::ratelimit::RateLimitLoginIdentifier;pub use middleware::ratelimit::RateLimitService;pub use middleware::ratelimit::RateLimitTenantId;pub use middleware::ratelimit::RateLimitUserId;
Modules§
- authn
- Authentication service: identity lookup, factor verification, session management. Authentication layer: identity lookup, factor verification, session management.
- authz
authz - Cedar Policy authorization for Axum applications.
- delegated
delegated-exchangeordelegated-stored - On-behalf-of (OBO) access: axess acts as a user at a
downstream service. Two flow shapes share one conceptual
abstraction; see
delegated::storedanddelegated::exchangefor the per-flow contracts. On-behalf-of (OBO) access: axess acting as a user at a downstream service. - device
device - First-class typed
Deviceaggregate + three-layer assurance ladder. Device identity. TypedDeviceaggregate, three-stage assurance ladder plus terminalRevokedstate, fingerprint extraction, lifecycle service, PII tokenisation, in-process cache decorator, refresh-family cascade, retention sweep, and SQL / Valkey persistence backends. Implements the proposal indocs/identity/device.md. All types are gated on thedevicefeature; storage backends are double-gated (device,sqlite,device,postgres,device,valkey). - federation
- External-IdP federation adapters: per-protocol + per-issuer. Orchestrator-side external-IdP integration code.
- health
- Composite health-check primitives. Health-check abstraction for operational readiness probes.
- local_
idp local-idp - Production-grade in-process IdP: mints workload-identity JWTs
against an adopter-supplied
local_idp::LocalIdpKeyStoreand exposes JWKS for verifiers. Test counterpart lives attesting::local_idp. Gated on thelocal-idpfeature. Production in-process IdP. Mints workload-identity JWTs against an adopter-supplied key store, serves the matching JWKS, and emits issuance events through the same audit hook the test fixture uses. - metrics
AuthnMetricstrait +NoopMetricsdefault implementation. Metrics hook trait for observability.- middleware
- Optional axum/tower middleware: request ID, W3C trace context, rate
limiting, CSRF. Renamed from
extrasin (the prior name was meant to signal “outside the core auth flow”;middlewareis what these actually are). Optional axum/tower middleware that sits outside the core auth flow: request ID, W3C trace context, rate limiting, CSRF. - principal
- Unified identity abstraction covering humans and workloads.
See
docs/workload-identity/README.md. Principal abstraction. - session
- Custom tower session layer with HMAC-signed cookies and typed session data. Session layer: custom tower middleware providing signed cookies and typed session data.
- store
- Generic key/value-with-TTL store + codec, shared across backend implementations. Shared key/value-with-TTL store abstraction.
- testing
testing - Mock authentication/identity stores, deterministic clocks/RNGs,
fixture builders, and other test doubles. Gated behind
cfg(any(test, feature = "testing"))so production builds cannot import them; in-crate tests get them viacfg(test). Deterministic-simulation-testing (DST) fixtures: mocks, fakes, and record builders that adopter test suites can use againstaxess-core’s production traits. - validation
- Identifier / e-mail / URL validation helpers. Input validation helpers for Axess forms and factor flows.
- workload
- Workload identity hub: re-exports inbound resolvers and houses
outbound primitives. See
workloadmodule docs. Outbound workload identity: axess presenting its own identity to a 3rd party (OAuthclient_credentials/private_key_jwt, client-side mTLS, signed JWT assertions, cloud-STS exchanges). Each mechanism lives undercrate::workload::outbound.
Structs§
- CliResolver
- CLI / environment-sourced workload-identity resolver.
- CliResolver
Builder - Builder for
CliResolver. Every field exceptattributesis required;build()returnsErrif any are missing. - Device
Id - Device identifier, sibling to
UserId/TenantId. axess-minted: cryptographic opacity is the security contract, so preferSelf::newoverSelf::from_namespaced_strin production paths. - Dpop
Proof fapi - A DPoP proof and its associated public key thumbprint.
- Email
OtpConfig - Email OTP factor configuration.
- Fapi
Config fapi - FAPI 2.0 Baseline Profile configuration.
- Fido2
Config - FIDO2/WebAuthn factor configuration.
- Hotp
Config - HOTP factor configuration (RFC 4226).
- Human
Principal - A human user authenticated through an interactive session.
- Ldap
Bind Result ldap - Result of a successful LDAP bind.
- Ldap
Group Search ldap - Configuration for LDAP group membership searches after a successful bind.
- Ldap
Provider Config ldap - Production LDAP provider wrapping the
ldap3crate. - Mock
Clock testing - A clock whose current time can be set from test code.
- Mock
Ldap Provider ldap - Test double for
LdapProvider. Configure accepted credentials viawith_user; unconfigured users and wrong passwords are rejected. - MockO
Auth Provider oauth - Mock OAuth/OIDC provider for deterministic simulation testing.
- Mock
Resolver testing - Mock
PrincipalResolverreturning a cannedPrincipalorIdentityErrorfor tests. - MockRng
testing - Deterministic RNG for testing (NOT cryptographically secure).
- OAuth
Claims oauth - OIDC claims extracted from a validated ID token.
- OAuth
Login Options oauth - Options for a single OAuth login flow.
- OAuth
Provider Config oauth - Configuration for an OAuth 2.0 / OIDC identity provider.
- ParResponse
fapi - Response from a Pushed Authorization Request (RFC 9126).
- Password
Config - Password factor configuration.
- Password
Rules - Complexity requirements for passwords.
- Session
Id - Session identifier. axess-minted; cryptographic opacity is the
security contract. A session-id leak that revealed login time
would be a vulnerability for forensic correlation against
externally-observed events, so prefer
Self::new(UUID v4 random) over time-prefixed variants. - System
Clock - Production
Clockbacked bychrono::Utc::now. - System
Rng - Production implementation using OS-provided cryptographically secure RNG.
- Tenant
Id - Tenant identifier. Scopes principals and events to a
multi-tenant boundary. Adopter-supplied: see
Self::from_uuidfor direct UUID adoption,Self::from_namespaced_strfor v5 mapping of non-UUID identifiers,Self::SYSTEMfor the reserved platform-operator sentinel. - Totp
Config - TOTP factor configuration (RFC 6238).
- Trust
Domain - SPIFFE trust domain: the authority component of a SPIFFE-ID URI.
- UserId
- User (subject / principal) identifier. Adopter-supplied, same
constructor surface as
TenantId. DistinctSelf::SYSTEMsentinel from the tenant so applications installing real rows for both don’t collapse them. - User
Info Claims oauth - Claims returned by the OIDC UserInfo endpoint.
- Workload
Id - SPIFFE-ID-shaped workload identifier.
- Workload
Principal - A workload principal: a service, batch job, agent, or other non-human compute identity. Carries the SPIFFE-shaped workload id, its trust domain, the issuer that vouched for it, the tenant scope, and arbitrary attributes (empty today; populated from JWT claims when JWT-SVID resolution lands).
- Zeroized
String - A
Stringthat is zeroed in memory on drop.
Enums§
- Identity
Error - Errors from principal construction and identity parsing.
- Issuer
- How a principal’s identity was vouched for at resolution time.
- Ldap
Error ldap - Errors returned by the LDAP provider during connect, bind, or search operations.
- OAuth
Error oauth - Errors returned by OAuth 2.0 / OIDC operations across discovery, token exchange, ID-token validation, and refresh.
- OtpAlgorithm
- The HMAC algorithm used for OTP generation.
- Principal
- An authenticated principal: either a human user or a workload.
- Response
Mode oauth - OAuth 2.0 response mode: how the authorization server returns parameters.
- Same
Site - The
SameSitecookie attribute. - Sender
Constraint fapi - Sender-constraint mechanism for FAPI 2.0.
Traits§
- Clock
- Clock trait to enable deterministic simulation/testing.
- Ldap
Provider ldap - Abstraction over LDAP bind operations.
- OAuth
Provider oauth - Abstraction over OAuth/OIDC token operations.
- Principal
Resolver - Async resolver that produces a
Principalfrom a context-specific identity source. See module-level docs for the dispatch model. - Secure
Rng - Trait for secure random number generation (DST-friendly).
Functions§
- spawn_
jwks_ refresh oauth - Spawn a background task that periodically calls
OAuthProvider::refresh_jwksonprovider.
Type Aliases§
- Auth
UrlResult oauth - Result type for
build_auth_urlandbuild_auth_url_par.