/argon2-provider

Vapor 2.x provider for the Argon2 password hash

Primary LanguageSwift

Argon2 Provider for Vapor 2.x CircleCI

This package allows you to integrate the Argon2 password hash with Vapor applications.

Installation

  1. Add the following dependency to your Package.swift:
    .Package(url: "https://github.com/vzsg/vapor-argon2-provider.git", majorVersion: 0, minor: 1)
  2. Call swift package update and swift package generate-xcodeproj.
  3. Register the provider with your Config instance. In the Vapor templates, this is done in Config+Setup.swift:
    import Argon2Provider
    
    extension Config {
        ...
        
        func addProviders() throws {
            ...
            try addProvider(Argon2Provider.Provider.self)
        }
    }
  4. Update the droplet.json file in the Config folder to use argon2 as the hash implementation:
    {
        ...
        "hash": "argon2"
    }
  5. (Optional) Customize Argon2 with the argon2.json file.

Customization

You can create a new configuration file called argon2.json in the Config folder to override the parameters of the Argon2 function. See the following table for possible options and their default values:

Key Type Default value Explanation
variant string "i" The Argon2 algorithm has three variants with different performance characteristics: d, i and id. See here for more details. Setting an invalid name will throw an error on boot.
timeCost number 3 The number of iterations
memoryCost number 12 Memory usage of the function as 2^N KiB
parallelism number 1 Number of threads used for parallelism
saltLength number 32 Length of the random salt in bytes