BUG/MINOR: htx: send the proper authenticate header when using http-request auth

When we use htx and http-request auth rules, we need to send WWW-Authenticate
with a 401 and Proxy-Authenticate with a 407. We only sent Proxy-Authenticate
regardless of status, with htx enabled.

To be backported to 1.9.
This commit is contained in:
Jrme Magnin 2018-12-28 14:49:08 +01:00 committed by Willy Tarreau
parent 09e498f1a1
commit 86cef23266

View File

@ -5435,10 +5435,12 @@ static int htx_reply_40x_unauthorized(struct stream *s, const char *auth_realm)
if (!htx_add_header(htx, ist("Cache-Control"), ist("no-cache")) ||
!htx_add_header(htx, ist("Connection"), ist("close")) ||
!htx_add_header(htx, ist("Content-Type"), ist("text/html")) ||
!htx_add_header(htx, ist("Proxy-Authenticate"), ist2(trash.area, trash.data)))
!htx_add_header(htx, ist("Content-Type"), ist("text/html")))
goto fail;
if (status == 401 && !htx_add_header(htx, ist("WWW-Authenticate"), ist2(trash.area, trash.data)))
goto fail;
if (status == 407 && !htx_add_header(htx, ist("Proxy-Authenticate"), ist2(trash.area, trash.data)))
goto fail;
if (!htx_add_endof(htx, HTX_BLK_EOH) || !htx_add_data(htx, body) || !htx_add_endof(htx, HTX_BLK_EOM))
goto fail;