update deps and fix typos
This commit is contained in:
parent
2a3df16a61
commit
a12beebdc8
6 changed files with 40 additions and 39 deletions
12
Cargo.toml
12
Cargo.toml
|
@ -3,13 +3,13 @@ name = "argon2-creds"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
authors = ["realaravinth <realaravinth@batsense.net>"]
|
authors = ["realaravinth <realaravinth@batsense.net>"]
|
||||||
description = "Convenient abstractions for all things credentials"
|
description = "Convenient abstractions for all things credentials"
|
||||||
keywords = ["credentials", "password"]
|
keywords = ["credentials", "password", "argon2"]
|
||||||
homepage = "https://github.com/realaravinth/argon2-creds"
|
homepage = "https://github.com/realaravinth/argon2-creds"
|
||||||
repository = "https://github.com/realaravinth/argon2-creds"
|
repository = "https://github.com/realaravinth/argon2-creds"
|
||||||
documentation = "https://doc.rs/argon2-creds"
|
documentation = "https://doc.rs/argon2-creds"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
[lib]
|
[lib]
|
||||||
|
@ -19,11 +19,11 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rust-argon2 = "0.8.3"
|
rust-argon2 = "0.8.3"
|
||||||
derive_more = "0.99.11"
|
derive_more = "0.99.17"
|
||||||
unicode-normalization = "0.1.6"
|
unicode-normalization = "0.1.6"
|
||||||
ammonia = "3.1.0"
|
ammonia = "3.1.2"
|
||||||
validator = { version = "0.14.0", features = ["derive"]}
|
validator = { version = "0.14.0", features = ["derive"]}
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
regex = { version = "1.3.9", features = [ "perf-inline", "perf-dfa", "perf-literal", "perf-cache", "perf"]}
|
regex = { version = "1.5.4", features = [ "perf-inline", "perf-dfa", "perf-literal", "perf-cache", "perf"]}
|
||||||
rand = "0.8.0"
|
rand = "0.8.4"
|
||||||
derive_builder = "0.10"
|
derive_builder = "0.10"
|
||||||
|
|
47
README.md
47
README.md
|
@ -8,56 +8,57 @@
|
||||||
![CI (Linux)](<https://github.com/realaravinth/argon2-creds/workflows/CI%20(Linux)/badge.svg>)
|
![CI (Linux)](<https://github.com/realaravinth/argon2-creds/workflows/CI%20(Linux)/badge.svg>)
|
||||||
[![dependency status](https://deps.rs/repo/github/realaravinth/argon2-creds/status.svg)](https://deps.rs/repo/github/realaravinth/argon2-creds)
|
[![dependency status](https://deps.rs/repo/github/realaravinth/argon2-creds/status.svg)](https://deps.rs/repo/github/realaravinth/argon2-creds)
|
||||||
<br />
|
<br />
|
||||||
[![codecov](https://codecov.io/gh/realaravinth/argon2-creds/branch/master/graph/badge.svg)](https://codecov.io/gh/realaravinth/argon2-creds)
|
[![codecov](https://codecov.io/gh/realaravinth/argon2-creds/branch/master/graph/badge.svg)](https://codecov.io/gh/realaravinth/argon2-creds)
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- [x] PRECIS Framework [UsernameCaseMapped](https://tools.ietf.org/html/rfc8265#page-7)
|
|
||||||
- [x] Password hashing and validation using
|
- [x] PRECIS Framework [UsernameCaseMapped](https://tools.ietf.org/html/rfc8265#page-7)
|
||||||
[rust-argon2](https://crates.io/crates/rust-argon2)
|
- [x] Password hashing and validation using
|
||||||
- [x] Filters for words that might cause ambiguity. See
|
[rust-argon2](https://crates.io/crates/rust-argon2)
|
||||||
[Blacklist](https://github.com/shuttlecraft/The-Big-Username-Blacklist)
|
- [x] Filters for words that might cause ambiguity. See
|
||||||
- [x] Profanity filter
|
[Blacklist](https://github.com/shuttlecraft/The-Big-Username-Blacklist)
|
||||||
- [x] Email validation(Regex validation not verification)
|
- [x] Profanity filter
|
||||||
|
- [x] Email validation(Regex validation not verification)
|
||||||
|
|
||||||
## Usage:
|
## Usage:
|
||||||
|
|
||||||
Add this to your `Cargo.toml`:
|
Add this to your `Cargo.toml`:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
argon2-creds = { version = "0.2", git = "https://github.com/realaravinth/argon2-creds" }
|
argon2-creds = "0.2"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Examples:
|
## Examples:
|
||||||
|
|
||||||
1. The easiest way to use this crate is with the default configuration. See `Default`
|
1. The easiest way to use this crate is with the default configuration. See `Default`
|
||||||
implementation for the default configuration.
|
implementation for the default configuration.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use argon2_creds::Config;
|
use argon2_creds::Config;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let config = Config::default();
|
let config = Config::default();
|
||||||
|
|
||||||
let password = "ironmansucks";
|
let password = "ironmansucks";
|
||||||
|
|
||||||
// email validation
|
// email validation
|
||||||
config.email(Some("batman@we.net")).unwrap();
|
config.email(Some("batman@we.net")).unwrap();
|
||||||
|
|
||||||
// process username
|
// process username
|
||||||
let username = config.username("Realaravinth").unwrap(); // process username
|
let username = config.username("Realaravinth").unwrap(); // process username
|
||||||
|
|
||||||
// generate hash
|
// generate hash
|
||||||
let hash = config.password(password).unwrap();
|
let hash = config.password(password).unwrap();
|
||||||
|
|
||||||
assert_eq!(username, "realaravinth");
|
assert_eq!(username, "realaravinth");
|
||||||
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. To gain fine-grained control over how credentials are managed, consider using
|
2. To gain fine-grained control over how credentials are managed, consider using
|
||||||
[ConfigBuilder]:
|
[ConfigBuilder]:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use argon2_creds::{Config, ConfigBuilder, PasswordPolicyBuilder};
|
use argon2_creds::{Config, ConfigBuilder, PasswordPolicyBuilder};
|
||||||
|
@ -90,6 +91,6 @@ fn main() {
|
||||||
let hash = config.password(password).unwrap();
|
let hash = config.password(password).unwrap();
|
||||||
|
|
||||||
assert_eq!(username, "realaravinth");
|
assert_eq!(username, "realaravinth");
|
||||||
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -32,5 +32,5 @@ fn main() {
|
||||||
let hash = config.password(password).unwrap();
|
let hash = config.password(password).unwrap();
|
||||||
|
|
||||||
assert_eq!(username, "realaravinth");
|
assert_eq!(username, "realaravinth");
|
||||||
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,5 @@ fn main() {
|
||||||
let hash = config.password(password).unwrap();
|
let hash = config.password(password).unwrap();
|
||||||
|
|
||||||
assert_eq!(username, "realaravinth");
|
assert_eq!(username, "realaravinth");
|
||||||
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub struct PasswordPolicy {
|
||||||
/// See [argon2 config][argon2::Config]
|
/// See [argon2 config][argon2::Config]
|
||||||
#[builder(default = "argon2::Config::default()")]
|
#[builder(default = "argon2::Config::default()")]
|
||||||
argon2: argon2::Config<'static>,
|
argon2: argon2::Config<'static>,
|
||||||
/// minium password length
|
/// minimum password length
|
||||||
#[builder(default = "8")]
|
#[builder(default = "8")]
|
||||||
min: usize,
|
min: usize,
|
||||||
/// maximum password length(to protect against DoS attacks)
|
/// maximum password length(to protect against DoS attacks)
|
||||||
|
@ -72,7 +72,7 @@ impl Default for Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
/// Mormalises, converts to lowercase and applies filters to the username
|
/// Normalises, converts to lowercase and applies filters to the username
|
||||||
pub fn username(&self, username: &str) -> CredsResult<String> {
|
pub fn username(&self, username: &str) -> CredsResult<String> {
|
||||||
use ammonia::clean;
|
use ammonia::clean;
|
||||||
use unicode_normalization::UnicodeNormalization;
|
use unicode_normalization::UnicodeNormalization;
|
||||||
|
@ -145,7 +145,7 @@ impl Config {
|
||||||
Ok(status)
|
Ok(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize filters accoding to configuration.
|
/// Initialize filters according to configuration.
|
||||||
///
|
///
|
||||||
/// Filters are lazy initialized so there's a slight delay during the very first use of
|
/// Filters are lazy initialized so there's a slight delay during the very first use of
|
||||||
/// filter. By calling this method during the early stages of program execution,
|
/// filter. By calling this method during the early stages of program execution,
|
||||||
|
@ -214,7 +214,7 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(username, "realaravinth");
|
assert_eq!(username, "realaravinth");
|
||||||
|
|
||||||
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
//! let hash = config.password(password).unwrap();
|
//! let hash = config.password(password).unwrap();
|
||||||
//!
|
//!
|
||||||
//! assert_eq!(username, "realaravinth");
|
//! assert_eq!(username, "realaravinth");
|
||||||
//! assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
//! assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! 2. To gain fine-grained control over how credentials are managed, consider using
|
//! 2. To gain fine-grained control over how credentials are managed, consider using
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
//! let hash = config.password(password).unwrap();
|
//! let hash = config.password(password).unwrap();
|
||||||
//!
|
//!
|
||||||
//! assert_eq!(username, "realaravinth");
|
//! assert_eq!(username, "realaravinth");
|
||||||
//! assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
|
//! assert!(Config::verify(&hash, password).unwrap(), "verify hashing");
|
||||||
//!```
|
//!```
|
||||||
//!
|
//!
|
||||||
//! ## Documentation & Community Resources
|
//! ## Documentation & Community Resources
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
//!
|
//!
|
||||||
//! * [Config]: This struct is the entry point to `argon2_creds`
|
//! * [Config]: This struct is the entry point to `argon2_creds`
|
||||||
//!
|
//!
|
||||||
//! * [CredsError]: This module provides essential types for errors that can occour during
|
//! * [CredsError]: This module provides essential types for errors that can occur during
|
||||||
//! credential processing
|
//! credential processing
|
||||||
//!
|
//!
|
||||||
//! ## Features
|
//! ## Features
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
//! * Keep-alive and slow requests handling
|
//! * Keep-alive and slow requests handling
|
||||||
//! * Profanity filter based off of
|
//! * 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)
|
//! [List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words](https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words)
|
||||||
//! * Problamatic usernames filter based off of
|
//! * Problematic usernames filter based off of
|
||||||
//! [The-Big-Username-Blacklist](https://github.com/marteinn/The-Big-Username-Blacklist)
|
//! [The-Big-Username-Blacklist](https://github.com/marteinn/The-Big-Username-Blacklist)
|
||||||
//! * Email validation using [validator](https://crates.io/validator)
|
//! * Email validation using [validator](https://crates.io/validator)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue