[nginx] Auth request: multiple WWW-Authenticate headers (ticket #485).
Sergey Kandaurov
pluknet at nginx.com
Mon May 30 22:33:02 UTC 2022
details: https://hg.nginx.org/nginx/rev/8272c823a7d0
branches:
changeset: 8037:8272c823a7d0
user: Maxim Dounin <mdounin at mdounin.ru>
date: Mon May 30 21:25:54 2022 +0300
description:
Auth request: multiple WWW-Authenticate headers (ticket #485).
When using auth_request with an upstream server which returns 401
(Unauthorized), multiple WWW-Authenticate headers from the upstream server
response are now properly copied to the response.
diffstat:
src/http/modules/ngx_http_auth_request_module.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diffs (35 lines):
diff -r f739c8142fb2 -r 8272c823a7d0 src/http/modules/ngx_http_auth_request_module.c
--- a/src/http/modules/ngx_http_auth_request_module.c Mon May 30 21:25:53 2022 +0300
+++ b/src/http/modules/ngx_http_auth_request_module.c Mon May 30 21:25:54 2022 +0300
@@ -101,7 +101,7 @@ ngx_module_t ngx_http_auth_request_modu
static ngx_int_t
ngx_http_auth_request_handler(ngx_http_request_t *r)
{
- ngx_table_elt_t *h, *ho;
+ ngx_table_elt_t *h, *ho, **ph;
ngx_http_request_t *sr;
ngx_http_post_subrequest_t *ps;
ngx_http_auth_request_ctx_t *ctx;
@@ -147,7 +147,9 @@ ngx_http_auth_request_handler(ngx_http_r
h = sr->upstream->headers_in.www_authenticate;
}
- if (h) {
+ ph = &r->headers_out.www_authenticate;
+
+ while (h) {
ho = ngx_list_push(&r->headers_out.headers);
if (ho == NULL) {
return NGX_ERROR;
@@ -156,7 +158,10 @@ ngx_http_auth_request_handler(ngx_http_r
*ho = *h;
ho->next = NULL;
- r->headers_out.www_authenticate = ho;
+ *ph = ho;
+ ph = &ho->next;
+
+ h = h->next;
}
return ctx->status;
More information about the nginx-devel
mailing list