class Kemal::BasicAuth::Handler

Overview

This middleware adds HTTP Basic Auth support to your application. Returns 401 "Unauthorized" with wrong credentials.

basic_auth "username", "password"
# basic_auth {"username1" => "password2", "username2" => "password2"}

HTTP::Server::Context#authorized_username is set when the user is authorized.

Defined in:

kemal-basic-auth/handler.cr

Constant Summary

AUTH = "Authorization"
AUTH_MESSAGE = "Could not verify your access level for that URL.\nYou have to login with proper credentials"
BASIC = "Basic"
HEADER_LOGIN_REQUIRED = "Basic realm=\"Login Required\""

Constructors

Instance Method Summary

Constructor Detail

def self.new(username : String, password : String) #

backward compatibility


[View source]
def self.new(credentials : Credentials) #

[View source]
def self.new(hash : Hash(String, String)) #

[View source]

Instance Method Detail

def authorize?(value) : String | Nil #

[View source]
def call(context) #

[View source]