Skip to main content

Crate capy_auth

Crate capy_auth 

Source
Expand description

Optional conventional browser identity: database sessions and explicit policies. Applications normally use this through capy::auth and capy make:auth.

Re-exports§

pub use verification::LocalVerificationDelivery;
pub use verification::MemoryVerificationDelivery;
pub use verification::VerificationDelivery;
pub use verification::VerificationMessage;
pub use verification::VerificationStatus;
pub use verification::VerifyEmailRequest;
pub use password::PasswordService;

Modules§

migration
Conventional, reversible SeaORM identity schema shared with the installer.
password
Per-application bounded Argon2id workers. Admission is async; hashing is blocking.
verification
Framework-owned verification proofs with an application-owned delivery adapter.

Structs§

AuthService
Shared auth runtime. One instance per application preserves process-local throttles.
AuthSettings
Small, typed settings for the optional conventional identity system.
AuthThrottleLimit
Fixed-window abuse budget. Zero never implicitly disables a limit.
AuthThrottleSettings
Separate fixed windows for CSRF bootstrap, registration, login, reset request and reset completion. Limits apply per action; account keys span client IPs. Application-owned verification endpoints need their own request-level limiter.
AuthUser
Required authenticated identity. Invalid, expired, deleted, or absent identities return 401.
CsrfResponse
CSRF bootstrap response; do not log it or cache it.
EmailVerified
The first transition from unverified to verified, before commit. Replay does not emit another event. Verification proof is application-owned.
ForgotPasswordRequest
Password reset request; the public response does not reveal account existence.
LocalResetDelivery
Development-only private file inbox. Unix files are created with mode 0600 in a mode 0700 directory; production refuses this adapter. No reset secrets are logged.
LoggedOut
An authenticated session was actually deleted, before commit.
LoginRequest
Login input; failures do not distinguish unknown users from incorrect passwords.
LoginSucceeded
Password verification succeeded and a session was rotated, before commit.
MemoryResetDelivery
In-memory delivery for local development and tests. Refused in production. An application can expose a local CLI inbox without logging credentials.
OptionalAuth
Optional identity. Only an absent cookie or valid anonymous CSRF session yields None. Malformed, unknown, expired, or deleted-user sessions still return 401.
PasswordResetCompleted
A reset token was consumed, password changed and sessions revoked, before commit.
PasswordSettings
Per-application Argon2id admission and resource limits (AUTH_PASSWORD_*).
RegisterRequest
Registration input. Debug redacts the password.
ResetMessage
Explicit delivery payload, redacted in Debug and not serializable.
ResetPasswordRequest
Single-use reset credential and replacement password.
ResetRequestedResponse
Constant public reset-request response.
Secret
An input secret: deserializable, deliberately not serializable, redacted in Debug.
UserRegistered
A new user and authenticated session have been inserted, before commit.
UserResponse
Public identity; persistence/security fields never cross the API boundary.

Enums§

HashConcurrency
Automatic hardware/budget selection or an explicit worker count.
SameSite
Cookie policy. Cross-site cookies are intentionally outside the built-in path.

Traits§

Policy
A small explicit policy: applications choose their identity, action, and resource types. Use an action enum or distinct action types; no runtime permission registry is required.
ResetDelivery
Application-owned delivery. Never put reset credentials in logs or request URLs.

Functions§

normalize_email
Deterministic whole-address lowercase and whitespace trimming. This deliberately treats case variants as one account, with no alias/dot rewriting.
prune
Delete expired sessions and reset credentials. Invoke from a scheduled application/DB job or capy auth:prune; no scheduler is created by Capy.
routes
Typed conventional route contracts, mounted by App::auth under /api/auth.
verification_routes
Opt-in routes for the framework-owned email verification flow; mounted under /api/auth.