Make reverse proxy auth optional (#4643)

* Make reverse proxy auth optional

If the option ENABLE_REVERSE_PROXY_AUTHENTICATION is enabled, make
reverse proxy auth optional, instead of failing if the authentication
did not succeed.

Fixes #3973

Signed-off-by: Najib Idrissi <najib.idrissi.kaitouni@gmail.com>

* Update http.go
This commit is contained in:
Najib Idrissi 2018-08-29 16:39:16 +02:00 committed by techknowlogick
parent fcea86877f
commit b9ae16d15e

View File

@ -83,12 +83,8 @@ func HTTP(ctx *context.Context) {
// check access // check access
if askAuth { if askAuth {
if setting.Service.EnableReverseProxyAuth { authUsername = ctx.Req.Header.Get(setting.ReverseProxyAuthUser)
authUsername = ctx.Req.Header.Get(setting.ReverseProxyAuthUser) if setting.Service.EnableReverseProxyAuth && len(authUsername) > 0 {
if len(authUsername) == 0 {
ctx.HandleText(401, "reverse proxy login error. authUsername empty")
return
}
authUser, err = models.GetUserByName(authUsername) authUser, err = models.GetUserByName(authUsername)
if err != nil { if err != nil {
ctx.HandleText(401, "reverse proxy login error, got error while running GetUserByName") ctx.HandleText(401, "reverse proxy login error, got error while running GetUserByName")