add header for basic auth

This commit is contained in:
ginuerzh 2024-01-07 19:40:42 +08:00
parent c959fc2f73
commit 262ac0e9a5

View File

@ -36,6 +36,7 @@ func mwBasicAuth(auther auth.Authenticator) gin.HandlerFunc {
}
u, p, _ := c.Request.BasicAuth()
if _, ok := auther.Authenticate(c, u, p); !ok {
c.Writer.Header().Set("WWW-Authenticate", "Basic")
c.AbortWithStatus(http.StatusUnauthorized)
}
}