Kemal::BasicAuth::Handler
Inherits Kemal::Handler < Kemal::HandlerInterface < HTTP::Handler < Reference < Object
This middleware adds HTTP Basic Auth support to your application. Returns 401 "Unauthorized" with wrong credentials.
basic_auth "username", "password"
# basic_auth({"username1" => "password1", "username2" => "password2"})
HTTP::Server::Context#kemal_authorized_username? is set when the user is
authorized.
Constants
AUTH = "Authorization"
AUTH_MESSAGE = "Could not verify your access level for that URL.\nYou have to login with proper credentials"
BASIC = "Basic"
BASIC_PREFIX = "Basic "
DEFAULT_REALM = "Login Required"
HEADER_LOGIN_REQUIRED = "Basic realm=\"#{DEFAULT_REALM}\""
RATE_LIMIT_MESSAGE = "Too many failed authentication attempts. Please try again later."
RATE_LIMIT_RETRY_AFTER = "60"
Constructors
new(verifier : Verifier, realm : String = DEFAULT_REALM, message : String = AUTH_MESSAGE, rate_limiter : RateLimiter | Nil = nil)
SourceInstance methods
call(context)
Sourcemessage
Sourcerate_limiter
Sourcerealm
SourceMacros
exclude(paths, method = "GET")
Sourceonly(paths, method = "GET")
Source