Expand description
Authentication backends for trojan.
This crate provides authentication backends for the Trojan protocol.
§Example
use trojan_auth::{AuthBackend, MemoryAuth, sha224_hex};
// Create an auth backend from passwords
let auth = MemoryAuth::from_passwords(["my_password"]);
// Verify a hash
let hash = sha224_hex("my_password");
let result = auth.verify(&hash).await?;§SQL Backend
Enable the sql-postgres, sql-mysql, or sql-sqlite feature to use
SQL database authentication:
[dependencies]
trojan-auth = { version = "0.1", features = ["sql-postgres"] }See the [sql] module for more details.
Structs§
- Auth
Metadata - Optional metadata associated with an authenticated user.
- Auth
Result - Result of a successful authentication.
- Memory
Auth - Simple in-memory authentication backend using a hash set.
- Reloadable
Auth - A wrapper that allows hot-swapping the underlying auth backend.
Enums§
- Auth
Error - Authentication error.
Traits§
- Auth
Backend - Trait for authentication backends.
Functions§
- sha224_
hex - Compute SHA224 hash and return as lowercase hex string.
- verify_
password - Verify if a hash matches a plaintext password.