Crate argon2_creds

source ·
Expand description

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.
    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");
  1. 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

Re-exports

Modules

  • Credential processor and configuration
  • Result and error datatypes