class
Kemal::BasicAuth::Handler
- Kemal::BasicAuth::Handler
- Kemal::Handler
- Reference
- Object
Overview
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.
Defined in:
kemal-basic-auth/handler.crConstant Summary
-
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)
-
.new(username : String, password : String, realm : String = DEFAULT_REALM, message : String = AUTH_MESSAGE, rate_limiter : RateLimiter | Nil = nil)
backward compatibility
- .new(hash : Hash(String, String), realm : String = DEFAULT_REALM, message : String = AUTH_MESSAGE, rate_limiter : RateLimiter | Nil = nil)
Macro Summary
Instance Method Summary
- #authorize?(value) : String | Nil
- #call(context)
- #message : String
- #rate_limiter : RateLimiter | Nil
- #realm : String
Constructor Detail
def self.new(verifier : Verifier, realm : String = DEFAULT_REALM, message : String = AUTH_MESSAGE, rate_limiter : RateLimiter | Nil = nil)
#
def self.new(username : String, password : String, realm : String = DEFAULT_REALM, message : String = AUTH_MESSAGE, rate_limiter : RateLimiter | Nil = nil)
#
backward compatibility
def self.new(hash : Hash(String, String), realm : String = DEFAULT_REALM, message : String = AUTH_MESSAGE, rate_limiter : RateLimiter | Nil = nil)
#