Undid last commit and added auth challenge
This commit is contained in:
parent
ed85d11d96
commit
aa2e12496a
|
@ -40,10 +40,13 @@ func AdminAtomFeed(c *RequestContext) ResponseData {
|
|||
creds := fmt.Sprintf("%s:%s", config.Config.Admin.AtomUsername, config.Config.Admin.AtomPassword)
|
||||
expectedAuth := fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(creds)))
|
||||
auth, hasAuth := c.Req.Header["Authorization"]
|
||||
if hasAuth {
|
||||
c.Logger.Warn().Str("auth", auth[0]).Msg("Got auth")
|
||||
}
|
||||
if !hasAuth || auth[0] != expectedAuth {
|
||||
if !hasAuth {
|
||||
res := ResponseData{
|
||||
StatusCode: http.StatusUnauthorized,
|
||||
}
|
||||
res.Header().Set("WWW-Authenticate", "Basic realm=\"Admin\"")
|
||||
return res
|
||||
} else if auth[0] != expectedAuth {
|
||||
return FourOhFour(c)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue