added new basic auth endpoint
This commit is contained in:
parent
804842e7c5
commit
8c9ab3b8d2
10 changed files with 249 additions and 51 deletions
|
|
@ -576,3 +576,20 @@ func logoutHandler(ctx *Context) {
|
|||
ctx.SetCookie(nil, 0)
|
||||
ctx.Redirect(root, http.StatusFound)
|
||||
}
|
||||
|
||||
func authBasicHandler(ctx *Context) {
|
||||
if ctx.Method() != "GET" {
|
||||
ctx.PlainUnauthorized()
|
||||
return
|
||||
}
|
||||
username, password, ok := ctx.Request.BasicAuth()
|
||||
if !ok {
|
||||
ctx.PlainUnauthorized()
|
||||
return
|
||||
}
|
||||
if ctx.Srv.BasicAuth.Auth(username, password) {
|
||||
ctx.PlainOK()
|
||||
return
|
||||
}
|
||||
ctx.PlainForbidden()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue