class Kemal::BasicAuth::ProcVerifier

Overview

Dynamic verifier that delegates to a user-provided callback. Useful when credentials come from a database, environment variables, or any other external source.

The callback receives the submitted username and password and must return true if the credentials are valid.

verifier = Kemal::BasicAuth::ProcVerifier.new do |user, pass|
  User.authenticate(user, pass)
end

Note: timing characteristics of the callback are the implementer's responsibility. For password storage, prefer hashed comparison (e.g. Crypto::Bcrypt::Password).

Defined in:

kemal-basic-auth/proc_verifier.cr

Constructors

Instance Method Summary

Instance methods inherited from class Kemal::BasicAuth::Verifier

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

Constructor Detail

def self.new(&block : String, String -> Bool) #

[View source]

Instance Method Detail

def authorize?(username : String, password : String) : String | Nil #
Description copied from class Kemal::BasicAuth::Verifier

Returns the authorized username on success, or nil otherwise.


[View source]