Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-09-06 20:09:32 +0400
committerIgor Sysoev <igor@sysoev.ru>2005-09-06 20:09:32 +0400
commitceb992921cee6f76d1752af2d388ee6a1d71e078 (patch)
tree2b4916a12d02210134939b7fb388a270e76002fa /src/http/ngx_http_core_module.c
parent5650106a09de8e8d876ed38fbff57b2161d910c4 (diff)
nginx-0.1.44-RELEASE importrelease-0.1.44
*) 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.
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r--src/http/ngx_http_core_module.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 852a9bbc0..0b483e0c8 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -931,6 +931,76 @@ ngx_http_set_exten(ngx_http_request_t *r)
ngx_int_t
+ngx_http_auth_basic_user(ngx_http_request_t *r)
+{
+ ngx_str_t auth, encoded;
+ ngx_uint_t len;
+
+ if (r->headers_in.user.len == 0 && r->headers_in.user.data != NULL) {
+ return NGX_DECLINED;
+ }
+
+ if (r->headers_in.authorization == NULL) {
+ r->headers_in.user.data = (u_char *) "";
+ return NGX_DECLINED;
+ }
+
+ encoded = r->headers_in.authorization->value;
+
+ if (encoded.len < sizeof("Basic ") - 1
+ || ngx_strncasecmp(encoded.data, "Basic ", sizeof("Basic ") - 1) != 0)
+ {
+ r->headers_in.user.data = (u_char *) "";
+ return NGX_DECLINED;
+ }
+
+ encoded.len -= sizeof("Basic ") - 1;
+ encoded.data += sizeof("Basic ") - 1;
+
+ while (encoded.len && encoded.data[0] == ' ') {
+ encoded.len--;
+ encoded.data++;
+ }
+
+ if (encoded.len == 0) {
+ r->headers_in.user.data = (u_char *) "";
+ return NGX_DECLINED;
+ }
+
+ auth.len = ngx_base64_decoded_length(encoded.len);
+ auth.data = ngx_palloc(r->pool, auth.len + 1);
+ if (auth.data == NULL) {
+ return NGX_ERROR;
+ }
+
+ if (ngx_decode_base64(&auth, &encoded) != NGX_OK) {
+ r->headers_in.user.data = (u_char *) "";
+ return NGX_DECLINED;
+ }
+
+ auth.data[auth.len] = '\0';
+
+ for (len = 0; len < auth.len; len++) {
+ if (auth.data[len] == ':') {
+ break;
+ }
+ }
+
+ if (len == auth.len) {
+ r->headers_in.user.data = (u_char *) "";
+ return NGX_DECLINED;
+ }
+
+ r->headers_in.user.len = len;
+ r->headers_in.user.data = auth.data;
+ r->headers_in.passwd.len = auth.len - len - 1;
+ r->headers_in.passwd.data = &auth.data[len + 1];
+
+ return NGX_OK;
+}
+
+
+ngx_int_t
ngx_http_subrequest(ngx_http_request_t *r,
ngx_str_t *uri, ngx_str_t *args)
{