| Crates.io | user_trait |
| lib.rs | user_trait |
| version | 0.1.1 |
| created_at | 2025-01-14 17:57:35.190156+00 |
| updated_at | 2025-01-14 18:12:33.209221+00 |
| description | A library for user authentication abstraction in Rust. |
| homepage | https://github.com/e1732a364fed/user_trait |
| repository | https://github.com/e1732a364fed/user_trait |
| max_upload_size | |
| id | 1516413 |
| size | 13,051 |
This library provides basic traits and helper structures for user authentication in Rust. It includes functionality for user identification, authentication, and storage, aiming to provide a simple enough interface for user authentication.
User trait, with support for hashing and ordering.UserBox with additional functionality for sorting and hashing.UserAuthenticator.To use this library, add it as a dependency in your Cargo.toml:
[dependencies]
user_trait = "0.1.0"
use user_trait::{PlainText, UsersMap, UserAuthenticator};
fn main() {
let user1 = PlainText::new("user1".to_string(), "password1".to_string());
let user2 = PlainText::new("user2".to_string(), "password2".to_string());
let mut users_map = UsersMap::new();
users_map.add_user(user1);
users_map.add_user(user2);
if let Some(authenticated_user) = users_map.auth_user_by_authstr("plaintext:user2\npassword2") {
println!("User authenticated: {}", authenticated_user.identity_str());
} else {
println!("Authentication failed.");
}
}
This project is licensed under the MIT OR Apache-2.0 License.