Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigDefault = Config{ Next: nil, Users: map[string]string{}, Realm: "Restricted", Authorizer: nil, Unauthorized: nil, }
ConfigDefault is the default config
Functions ¶
func PasswordFromContext ¶
func PasswordFromContext(c fiber.Ctx) string
PasswordFromContext returns the password found in the context returns an empty string if the password does not exist
func UsernameFromContext ¶
func UsernameFromContext(c fiber.Ctx) string
UsernameFromContext returns the username found in the context returns an empty string if the username does not exist
Types ¶
type Config ¶
type Config struct { // Next defines a function to skip this middleware when returned true. // // Optional. Default: nil Next func(c fiber.Ctx) bool // Users defines the allowed credentials // // Required. Default: map[string]string{} Users map[string]string // Realm is a string to define realm attribute of BasicAuth. // the realm identifies the system to authenticate against // and can be used by clients to save credentials // // Optional. Default: "Restricted". Realm string // Authorizer defines a function you can pass // to check the credentials however you want. // It will be called with a username and password // and is expected to return true or false to indicate // that the credentials were approved or not. // // Optional. Default: nil. Authorizer func(string, string) bool // By default it will return with a 401 Unauthorized and the correct WWW-Auth header // // Optional. Default: nil Unauthorized fiber.Handler }
Config defines the config for middleware.
Click to show internal directories.
Click to hide internal directories.