io.randomseed.utils.auth.pwd
added in 2.0.6
Random Utilities, authentication, passwords handling.
*default-settings*
dynamic
Default password authentication timing settings: base wait (seconds), random wait range, and extra delay when user does not exist.
check
(check plain settings shared-suite intrinsic-suite & other-suites)(check plain user-suite user-settings)Checks if the given plain text password is correct by comparing it with the result of calling all checkers in the given encryption suite with memorized options applied.
encrypt
(encrypt plain local-settings)Encrypts the given plain text password using all encryption functions in the given encryption suite.
expand-settings
(expand-settings k config)Returns prepared settings associated with key k.
find-handler
(find-handler password-or-cipher)Tries to get an encryption handler from an entry map by accessing :handler key or using :handler-id as fallback (and dereferencing it).
from-json
(from-json suite)(from-json suite tr-map)Converts JSON data to suite by applying transformations to keys described by tr-map. If no map is given the json-translation is used.
generate-salt
(generate-salt length possible-chars prefix suffix)Builds salt bytes from random core with optional prefix and suffix.
human-readable
(human-readable pwd)Converts binary fields in a crypto entry to string representation.
human-readable-suite
(human-readable-suite suite)Converts every entry in suite to human-readable form.
init
(init k config)(init k config log-fn)Initializes password settings from auth config and optional logger.
init-wait
(init-wait {:keys [wait-nouser], pwait :wait, [wmin wmax] :wait-random, :as config})Initializes wait function and derived wait configuration values.
json-translation
Translation map for JSON deserialization: converts Base64-encoded fields back to byte arrays and :handler-id to a symbol.
json-write-translation
Translation map for JSON serialization: converts byte-array fields to URL-safe Base64 strings.
merge-suites
(merge-suites crypto-suites-dual)(merge-suites defaults-crypto-suite user-crypto-suite & more)Merges shared and intrinsic suite chains entry-wise.
Accepts either a Suites value or explicit suite chains.
new-checker
(new-checker settings)Builds checker function for split suites or separate shared/intrinsic chains.
new-encryptor
(new-encryptor settings)Builds encryptor function returning split shared/intrinsic suites.
new-json-checker
(new-json-checker settings)Builds checker function for JSON-encoded shared and intrinsic suites.
new-json-encryptor
(new-json-encryptor settings)Builds encryptor function returning SuitesJSON (shared and intrinsic).
post-parse-json
(post-parse-json tr-map m)Post-parses JSON data by transforming certain values with the given translation map.
pre-generate-json
(pre-generate-json tr-map m)Prepares suite entry for JSON serialization using translation map tr-map.
prepare-settings
(prepare-settings config)Merges provided settings with defaults and removes empty values.
printable-suite
(printable-suite suite)Returns normalized printable handler names from a suite definition.
salt-bytes
(salt-bytes)(salt-bytes size)Generates cryptographically strong random salt bytes.
salt-string
(salt-string length possible-chars)Generates random salt string of length from possible-chars.
split
(split crypto-entry)Splits a cipher entry or a password into two parts and returns a Suite record with two fields :shared and :intrinsic with these parts.
split-suite
(split-suite suite)Splits all entries in suite into Suites with shared/intrinsic chains.
standard-check
(standard-check encrypt-fn plain encrypted salt settings)(standard-check encrypt-fn plain opts encrypted salt settings)(standard-check encrypt-fn plain opts-or-enc settings)Performs a standard authentication check based on the provided plain text password given as the second argument). The first argument should be an encryption function used to perform the encryption operation on the provided password and compare the result with the encrypted password that should be provided as third argument or as a value associated with the :password key if this argument is a map. The last argument should be settings map that will be passed to the encryption function.
This is a low-level function that is intended to be used by different authentication modules which are implementing pretty standard way of checking the password.
wait
(wait wait-start wait-randmax)Sleeps for wait-start seconds plus random delay up to wait-randmax.