diff -r 42114bf12da0 src/http/modules/ngx_http_auth_basic_module.c
|
a
|
b
|
ngx_http_auth_basic_set_realm(ngx_http_r
|
| 351 | 351 | { |
| 352 | 352 | size_t len; |
| 353 | 353 | u_char *basic, *p; |
| | 354 | ngx_table_elt_t **wwauth; |
| 354 | 355 | |
| 355 | | r->headers_out.www_authenticate = ngx_list_push(&r->headers_out.headers); |
| 356 | | if (r->headers_out.www_authenticate == NULL) { |
| | 356 | wwauth = r->headers_out.www_authenticate.elts; |
| | 357 | if (wwauth == NULL) { |
| | 358 | if (ngx_array_init(&r->headers_out.www_authenticate, r->pool, |
| | 359 | 1, sizeof(ngx_table_elt_t *)) != NGX_OK) { |
| | 360 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
| | 361 | } |
| | 362 | |
| | 363 | wwauth = ngx_array_push(&r->headers_out.www_authenticate); |
| | 364 | |
| | 365 | if (wwauth == NULL) { |
| | 366 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
| | 367 | } |
| | 368 | } |
| | 369 | |
| | 370 | *wwauth = ngx_list_push(&r->headers_out.headers); |
| | 371 | if (*wwauth == NULL) { |
| 357 | 372 | return NGX_HTTP_INTERNAL_SERVER_ERROR; |
| 358 | 373 | } |
| 359 | 374 | |
| … |
… |
ngx_http_auth_basic_set_realm(ngx_http_r
|
| 368 | 383 | p = ngx_cpymem(p, realm->data, realm->len); |
| 369 | 384 | *p = '"'; |
| 370 | 385 | |
| 371 | | r->headers_out.www_authenticate->hash = 1; |
| 372 | | ngx_str_set(&r->headers_out.www_authenticate->key, "WWW-Authenticate"); |
| 373 | | r->headers_out.www_authenticate->value.data = basic; |
| 374 | | r->headers_out.www_authenticate->value.len = len; |
| | 386 | (*wwauth)->hash = 1; |
| | 387 | ngx_str_set(&(*wwauth)->key, "WWW-Authenticate"); |
| | 388 | (*wwauth)->value.data = basic; |
| | 389 | (*wwauth)->value.len = len; |
| 375 | 390 | |
| 376 | 391 | return NGX_HTTP_UNAUTHORIZED; |
| 377 | 392 | } |
diff -r 42114bf12da0 src/http/modules/ngx_http_auth_request_module.c
|
a
|
b
|
ngx_module_t ngx_http_auth_request_modu
|
| 101 | 101 | static ngx_int_t |
| 102 | 102 | ngx_http_auth_request_handler(ngx_http_request_t *r) |
| 103 | 103 | { |
| 104 | | ngx_table_elt_t *h, *ho; |
| | 104 | ngx_table_elt_t *h, *ho, **hh; |
| 105 | 105 | ngx_http_request_t *sr; |
| 106 | 106 | ngx_http_post_subrequest_t *ps; |
| 107 | 107 | ngx_http_auth_request_ctx_t *ctx; |
| … |
… |
ngx_http_auth_request_handler(ngx_http_r
|
| 140 | 140 | |
| 141 | 141 | if (ctx->status == NGX_HTTP_UNAUTHORIZED) { |
| 142 | 142 | sr = ctx->subrequest; |
| 143 | | |
| 144 | | h = sr->headers_out.www_authenticate; |
| | 143 | h = NULL; |
| | 144 | if (sr->headers_out.www_authenticate.elts != NULL) { |
| | 145 | hh = sr->headers_out.www_authenticate.elts; |
| | 146 | h = *hh; |
| | 147 | } |
| 145 | 148 | |
| 146 | 149 | if (!h && sr->upstream) { |
| 147 | 150 | h = sr->upstream->headers_in.www_authenticate; |
| … |
… |
ngx_http_auth_request_handler(ngx_http_r
|
| 153 | 156 | return NGX_ERROR; |
| 154 | 157 | } |
| 155 | 158 | |
| | 159 | hh = r->headers_out.www_authenticate.elts; |
| | 160 | if (hh == NULL) { |
| | 161 | if (ngx_array_init(&r->headers_out.www_authenticate, r->pool, |
| | 162 | 1, sizeof(ngx_table_elt_t *)) != NGX_OK) { |
| | 163 | return NGX_ERROR; |
| | 164 | } |
| | 165 | |
| | 166 | hh = ngx_array_push(&r->headers_out.www_authenticate); |
| | 167 | if (hh == NULL) { |
| | 168 | return NGX_ERROR; |
| | 169 | } |
| | 170 | } |
| | 171 | |
| 156 | 172 | *ho = *h; |
| 157 | | |
| 158 | | r->headers_out.www_authenticate = ho; |
| | 173 | *hh = ho; |
| 159 | 174 | } |
| 160 | 175 | |
| 161 | 176 | return ctx->status; |
diff -r 42114bf12da0 src/http/ngx_http_core_module.c
|
a
|
b
|
ngx_int_t
|
| 1101 | 1101 | ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph) |
| 1102 | 1102 | { |
| 1103 | 1103 | ngx_int_t rc; |
| | 1104 | ngx_uint_t i; |
| 1104 | 1105 | ngx_http_core_loc_conf_t *clcf; |
| | 1106 | ngx_table_elt_t **wwauth; |
| 1105 | 1107 | |
| 1106 | 1108 | if (r != r->main) { |
| 1107 | 1109 | r->phase_handler = ph->next; |
| … |
… |
ngx_http_core_access_phase(ngx_http_requ
|
| 1135 | 1137 | if (rc == NGX_OK) { |
| 1136 | 1138 | r->access_code = 0; |
| 1137 | 1139 | |
| 1138 | | if (r->headers_out.www_authenticate) { |
| 1139 | | r->headers_out.www_authenticate->hash = 0; |
| | 1140 | if (r->headers_out.www_authenticate.elts) { |
| | 1141 | wwauth = r->headers_out.www_authenticate.elts; |
| | 1142 | |
| | 1143 | for (i = 0; i < r->headers_out.www_authenticate.nelts; i++) { |
| | 1144 | wwauth[i]->hash = 0; |
| | 1145 | } |
| 1140 | 1146 | } |
| 1141 | 1147 | |
| 1142 | 1148 | r->phase_handler = ph->next; |
diff -r 42114bf12da0 src/http/ngx_http_request.h
|
a
|
b
|
typedef struct {
|
| 255 | 255 | ngx_table_elt_t *last_modified; |
| 256 | 256 | ngx_table_elt_t *content_range; |
| 257 | 257 | ngx_table_elt_t *accept_ranges; |
| 258 | | ngx_table_elt_t *www_authenticate; |
| 259 | 258 | ngx_table_elt_t *expires; |
| 260 | 259 | ngx_table_elt_t *etag; |
| 261 | 260 | |
| … |
… |
typedef struct {
|
| 268 | 267 | ngx_uint_t content_type_hash; |
| 269 | 268 | |
| 270 | 269 | ngx_array_t cache_control; |
| | 270 | ngx_array_t www_authenticate; |
| 271 | 271 | |
| 272 | 272 | off_t content_length_n; |
| 273 | 273 | time_t date_time; |
diff -r 42114bf12da0 src/http/ngx_http_upstream.c
|
a
|
b
|
ngx_http_upstream_intercept_errors(ngx_h
|
| 2010 | 2010 | { |
| 2011 | 2011 | ngx_int_t status; |
| 2012 | 2012 | ngx_uint_t i; |
| 2013 | | ngx_table_elt_t *h; |
| | 2013 | ngx_table_elt_t *h, **wwauth; |
| 2014 | 2014 | ngx_http_err_page_t *err_page; |
| 2015 | 2015 | ngx_http_core_loc_conf_t *clcf; |
| 2016 | 2016 | |
| … |
… |
ngx_http_upstream_intercept_errors(ngx_h
|
| 2048 | 2048 | } |
| 2049 | 2049 | |
| 2050 | 2050 | *h = *u->headers_in.www_authenticate; |
| 2051 | | |
| 2052 | | r->headers_out.www_authenticate = h; |
| | 2051 | wwauth = r->headers_out.www_authenticate.elts; |
| | 2052 | |
| | 2053 | if (wwauth == NULL) { |
| | 2054 | if (ngx_array_init(&r->headers_out.www_authenticate, |
| | 2055 | r->pool, 1, |
| | 2056 | sizeof(ngx_table_elt_t *)) != NGX_OK) { |
| | 2057 | return NGX_ERROR; |
| | 2058 | } |
| | 2059 | |
| | 2060 | wwauth = ngx_array_push(&r->headers_out.www_authenticate); |
| | 2061 | |
| | 2062 | if (wwauth == NULL) { |
| | 2063 | return NGX_ERROR; |
| | 2064 | } |
| | 2065 | } |
| | 2066 | |
| | 2067 | *wwauth = h; |
| 2053 | 2068 | } |
| 2054 | 2069 | |
| 2055 | 2070 | #if (NGX_HTTP_CACHE) |