Skip to main content

Crate trojan_auth

Crate trojan_auth 

Source
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§

AuthMetadata
Optional metadata associated with an authenticated user.
AuthResult
Result of a successful authentication.
MemoryAuth
Simple in-memory authentication backend using a hash set.
ReloadableAuth
A wrapper that allows hot-swapping the underlying auth backend.

Enums§

AuthError
Authentication error.

Traits§

AuthBackend
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.