Authentication: users, sessions, passwords, API keys
| Tier | identity |
| Role | unclassified (baselined) |
| Path | crates/identity/auth |
| Edition | 2021 |
| Targets | gen_hash, identity_auth |
| Public items | 0 across 0 modules |
| Tests | 39 |
What it is for
Authentication library crates for Rust applications.
This crate provides:
- User model (links to Person from identity-parties)
- Session management (compatible with tower-sessions)
- Password hashing with Argon2
- Login attempt tracking for rate limiting
- API key authentication for service accounts
# Example
use identity_auth::{User, Password, Session};
// Create a user
let user = User::new("john@example.com")
.with_password("secure_password")?;
// Verify password
assert!(user.verify_password("secure_password")?);
// Create a session
let session = Session::new(user.id);
Capabilities
No public items.
How to use it
From `examples/gen_hash.rs`:
use identity_auth::Password;
use std::env;
fn main() {
let password = env::args()
.nth(1)
.unwrap_or_else(|| "changeme123".to_string());
match Password::hash(&password) {
Ok(hash) => println!("{}", hash),
Err(e) => eprintln!("Error: {}", e),
}
}
Module structure
No public modules: the crate root is its whole surface.
Public surface
No public items.
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
ApiKey | api_key::ApiKey |
AuthError | error::AuthError |
LoginAttempt | login_attempt::LoginAttempt |
Password | password::Password |
Session | session::Session |
{User,UserStatus} | user::{User,UserStatus} |
Boundary
Reaches into foundation.
Shares tier identity with 7 other crates: identity-identifiers, identity-impersonation, identity-parties, identity-party-places, identity-rbac, identity-tenant, identity-user-prefs.
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | identity |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/identity/auth |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_identity["identity"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-basemodels` | foundation | no | always |
| `identity-parties` | identity | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
argon2 | ^0.5 | — | no | always |
base64 | ^0.22 | — | no | always |
chrono | ^0.4 | serde | no | always |
hex | ^0.4 | — | no | always |
rand | ^0.8 | — | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sha2 | ^0.10 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
subtle | ^2 | — | no | always |
thiserror | ^2 | — | no | always |
tokio | ^1 | full | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio-test | ^0.4 | — | no | always |
Build. None.
Depended on by. 4 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_auth["application-auth"] -->|uses| SELF n_application_dlp["application-dlp"] -->|uses| SELF n_application_party_api["application-party-api"] -->|uses| SELF n_application_rbac["application-rbac"] -->|uses| SELF SELF["identity-auth"] SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"] SELF -->|runtime| n_identity_parties["identity-parties"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| example | gen_hash | `examples/gen_hash.rs` |
| lib | identity_auth | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | yes |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
4 workspace crates depend on this one: application-auth, application-dlp, application-party-api, application-rbac.
Verification
| Kind | Count |
|---|---|
| Unit tests | 39 |
| Integration tests | 0 |
| Examples | 1 |
| Doctests | 0 |
What the tests establish, by name:
verify_accepts_the_real_key_and_rejects_others—src/api_key.rsverify_uses_constant_time_byte_equality—src/api_key.rstest_api_key_is_valid—src/lib.rstest_api_key_last_used_tracking—src/lib.rstest_api_key_returns_plaintext_once—src/lib.rstest_api_key_revoke—src/lib.rstest_api_key_scopes—src/lib.rstest_api_key_verify—src/lib.rstest_api_key_with_expiry—src/lib.rstest_create_api_key—src/lib.rstest_create_login_attempt_failure—src/lib.rstest_create_login_attempt_success—src/lib.rstest_create_session—src/lib.rstest_create_user_with_email—src/lib.rstest_login_attempt_with_user_agent—src/lib.rstest_password_hash_creates_argon2_hash—src/lib.rstest_password_hash_is_unique_each_time—src/lib.rstest_password_minimum_length—src/lib.rstest_password_reject_empty—src/lib.rstest_password_reject_too_short—src/lib.rstest_password_verify_correct—src/lib.rstest_password_verify_incorrect—src/lib.rstest_session_custom_expiry—src/lib.rstest_session_default_expiry—src/lib.rstest_session_extend—src/lib.rstest_session_is_expired—src/lib.rstest_session_is_valid—src/lib.rstest_session_revoke—src/lib.rstest_session_token_is_secure—src/lib.rstest_session_tokens_are_unique—src/lib.rs- _… 9 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 0 | 0 |
Public modules with a //! block | 0 | 0 |
Metrics
| Metric | Value |
|---|---|
| Rust source files | 7 |
| Source lines | 1051 |
| Code lines | 681 |
| Public API items | 0 |
| Public modules | 0 |
| Tests | 39 |
| Examples | 1 |
| Cargo features | 0 |
| Direct runtime dependencies | 15 |
| Workspace reverse dependencies | 4 |
pie showData
title Rust source composition
"Code" : 681
"Blank or comment" : 370
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.