Mercurial > hg > nginx
diff src/http/ngx_http_variables.c @ 539:371c1cee100d release-0.1.44
nginx-0.1.44-RELEASE import
*) Feature: the IMAP/POP3 proxy supports SSL.
*) Feature: the "proxy_timeout" directive of the ngx_imap_proxy_module.
*) Feature: the "userid_mark" directive.
*) Feature: the $remote_user variable value is determined independently
of authorization use.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 06 Sep 2005 16:09:32 +0000 |
parents | d6e48c08d718 |
children | 45033d85b30e |
line wrap: on
line diff
--- a/src/http/ngx_http_variables.c Tue Aug 30 10:55:07 2005 +0000 +++ b/src/http/ngx_http_variables.c Tue Sep 06 16:09:32 2005 +0000 @@ -32,6 +32,8 @@ ngx_http_variable_document_root(ngx_http_request_t *r, uintptr_t data); static ngx_http_variable_value_t * ngx_http_variable_request_filename(ngx_http_request_t *r, uintptr_t data); +static ngx_http_variable_value_t * + ngx_http_variable_remote_user(ngx_http_request_t *r, uintptr_t data); /* @@ -108,8 +110,7 @@ { ngx_string("request_method"), ngx_http_variable_request, offsetof(ngx_http_request_t, method_name), 0, 0 }, - { ngx_string("remote_user"), ngx_http_variable_request, - offsetof(ngx_http_request_t, headers_in.user), 0, 0 }, + { ngx_string("remote_user"), ngx_http_variable_remote_user, 0, 0, 0 }, { ngx_null_string, NULL, 0, 0, 0 } }; @@ -657,6 +658,34 @@ } +static ngx_http_variable_value_t * +ngx_http_variable_remote_user(ngx_http_request_t *r, uintptr_t data) +{ + ngx_int_t rc; + ngx_http_variable_value_t *vv; + + rc = ngx_http_auth_basic_user(r); + + if (rc == NGX_DECLINED) { + return NGX_HTTP_VAR_NOT_FOUND; + } + + if (rc == NGX_ERROR) { + return NULL; + } + + vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)); + if (vv == NULL) { + return NULL; + } + + vv->value = 0; + vv->text = r->headers_in.user; + + return vv; +} + + ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf) {