Crate argon2_creds
source · [−]Expand description
Argon2-Creds provides abstractions over credential management and cuts down on boilerplate code required to implement authenticatin
Example
- The easiest way to use this crate is with the default configuration. See
Default
implementation for the default configuration.
use argon2_creds::Config;
let config = Config::default();
let password = "ironmansucks";
let hash = config.password(password).unwrap();
// email validation
config.email("batman@we.net").unwrap();
// process username
let username = config.username("Realaravinth").unwrap(); // process username
// generate hash
let hash = config.password(password).unwrap();
assert_eq!(username, "realaravinth");
assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
- To gain fine-grained control over how credentials are managed, consider using ConfigBuilder:
use argon2_creds::{ConfigBuilder, PasswordPolicy, Config};
let config = ConfigBuilder::default()
.username_case_mapped(false)
.profanity(true)
.blacklist(false)
.password_policy(PasswordPolicy::default())
.build()
.unwrap();
let password = "ironmansucks";
let hash = config.password(password).unwrap();
// email validation
config.email("batman@we.net").unwrap();
// process username
let username = config.username("Realaravinth").unwrap(); // process username
// generate hash
let hash = config.password(password).unwrap();
assert_eq!(username, "realaravinth");
assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
Documentation & Community Resources
In addition to this API documentation, other resources are available:
To get started navigating the API docs, you may consider looking at the following pages first:
-
Config: This struct is the entry point to
argon2_creds
-
CredsError: This module provides essential types for errors that can occur during credential processing
Features
- rust-argon2-based password hashing
- PRECIS Framework UsernameCaseMapped
- Keep-alive and slow requests handling
- Profanity filter based off of List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words
- Problematic usernames filter based off of The-Big-Username-Blacklist
- Email validation using validator
Re-exports
pub use crate::config::Config;
pub use crate::config::ConfigBuilder;
pub use crate::config::PasswordPolicy;
pub use crate::config::PasswordPolicyBuilder;
pub use crate::errors::CredsError;
pub use crate::errors::CredsResult;