Documentation ¶
Overview ¶
Package auth provides handlers to enable basic auth support. Simple Usage:
import( "github.com/izi-global/izigo" "github.com/izi-global/izigo/plugins/auth" ) func main(){ // authenticate every request izigo.InsertFilter("*", izigo.BeforeRouter,auth.Basic("username","secretpassword")) izigo.Run() }
Advanced Usage:
func SecretAuth(username, password string) bool { return username == "diepdt" && password == "helloIZIGo" } authPlugin := auth.NewBasicAuthenticator(SecretAuth, "Authorization Required") izigo.InsertFilter("*", izigo.BeforeRouter,authPlugin)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Basic ¶
func Basic(username string, password string) izigo.FilterFunc
Basic is the http basic auth
func NewBasicAuthenticator ¶
func NewBasicAuthenticator(secrets SecretProvider, Realm string) izigo.FilterFunc
NewBasicAuthenticator return the BasicAuth
Types ¶
type BasicAuth ¶
type BasicAuth struct { Secrets SecretProvider Realm string }
BasicAuth store the SecretProvider and Realm
func (*BasicAuth) CheckAuth ¶
CheckAuth Checks the username/password combination from the request. Returns either an empty string (authentication failed) or the name of the authenticated user. Supports MD5 and SHA1 password entries
func (*BasicAuth) RequireAuth ¶
func (a *BasicAuth) RequireAuth(w http.ResponseWriter, r *http.Request)
RequireAuth http.Handler for BasicAuth which initiates the authentication process (or requires reauthentication).
type SecretProvider ¶
SecretProvider is the SecretProvider function
Click to show internal directories.
Click to hide internal directories.