class

Kemal::BasicAuth::BcryptVerifier

Inherits Kemal::BasicAuth::Verifier < Reference < Object

Verifier backed by bcrypt-hashed passwords.

Entries map a username to an existing bcrypt hash string (e.g. produced via Crypto::Bcrypt::Password.create("plain").to_s). Verification always performs a bcrypt computation (real or dummy) so that response time does not reveal whether the username exists.

hash = Crypto::Bcrypt::Password.create("xyz").to_s
verifier = Kemal::BasicAuth::BcryptVerifier.new({"admin" => hash})

Constructors

new(entries : Hash(String, String))
Source

Class methods

dummy_hash
Source

Instance methods

authorize?(username : String, password : String) : String | Nil

Returns the authorized username on success, or nil otherwise.

Source