1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
//! Argon2-Creds provides abstractions over credential management and cuts down on boilerplate code
//! required to implement authenticatin
//!
//! ## Example
//!
//! 1. The easiest way to use this crate is with the default configuration. See `Default`
//! implementation for the default configuration.
//!
//! ```rust
//! 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");
//! ```
//!
//! 2. To gain fine-grained control over how credentials are managed, consider using
//! [ConfigBuilder]:
//!
//!```rust
//! 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:
//! * [Examples](https://github.com/realaravinth/argon2-creds/)
//!
//! 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](https://crates.io/rust-argon2)-based password hashing
//! * PRECIS Framework [UsernameCaseMapped](https://tools.ietf.org/html/rfc8265#page-7)
//! * Keep-alive and slow requests handling
//! * Profanity filter based off of
//! [List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words](https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words)
//! * Problematic usernames filter based off of
//! [The-Big-Username-Blacklist](https://github.com/marteinn/The-Big-Username-Blacklist)
//! * Email validation using [validator](https://crates.io/validator)
pub mod config;
pub mod errors;
mod filters;
pub use crate::config::{Config, ConfigBuilder, PasswordPolicy, PasswordPolicyBuilder};
pub use crate::errors::{CredsError, CredsResult};