aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_auth_basic_module.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2017-09-18 11:09:41 +0300
committerRuslan Ermilov <ru@nginx.com>2017-09-18 11:09:41 +0300
commit05e87e19aff42a75a290b99f5684a73dbd38a329 (patch)
tree37f2a7ac4165cbb9b325fa3e4281107f52bd9d8f /src/http/modules/ngx_http_auth_basic_module.c
parent99cc4c72c7c2cdb802c6e6ceb0a0a1f8b115be29 (diff)
downloadnginx-05e87e19aff42a75a290b99f5684a73dbd38a329.tar.gz
nginx-05e87e19aff42a75a290b99f5684a73dbd38a329.zip
Removed more remnants of the old pthread implementation.
After e284f3ff6831, ngx_crypt() can no longer return NGX_AGAIN.
Diffstat (limited to 'src/http/modules/ngx_http_auth_basic_module.c')
-rw-r--r--src/http/modules/ngx_http_auth_basic_module.c70
1 files changed, 15 insertions, 55 deletions
diff --git a/src/http/modules/ngx_http_auth_basic_module.c b/src/http/modules/ngx_http_auth_basic_module.c
index 4aa684f8a..2f345b6d5 100644
--- a/src/http/modules/ngx_http_auth_basic_module.c
+++ b/src/http/modules/ngx_http_auth_basic_module.c
@@ -15,11 +15,6 @@
typedef struct {
- ngx_str_t passwd;
-} ngx_http_auth_basic_ctx_t;
-
-
-typedef struct {
ngx_http_complex_value_t *realm;
ngx_http_complex_value_t user_file;
} ngx_http_auth_basic_loc_conf_t;
@@ -27,7 +22,7 @@ typedef struct {
static ngx_int_t ngx_http_auth_basic_handler(ngx_http_request_t *r);
static ngx_int_t ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r,
- ngx_http_auth_basic_ctx_t *ctx, ngx_str_t *passwd, ngx_str_t *realm);
+ ngx_str_t *passwd, ngx_str_t *realm);
static ngx_int_t ngx_http_auth_basic_set_realm(ngx_http_request_t *r,
ngx_str_t *realm);
static void ngx_http_auth_basic_close(ngx_file_t *file);
@@ -103,7 +98,6 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
ngx_str_t pwd, realm, user_file;
ngx_uint_t i, level, login, left, passwd;
ngx_file_t file;
- ngx_http_auth_basic_ctx_t *ctx;
ngx_http_auth_basic_loc_conf_t *alcf;
u_char buf[NGX_HTTP_AUTH_BUF_SIZE];
enum {
@@ -126,13 +120,6 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
return NGX_DECLINED;
}
- ctx = ngx_http_get_module_ctx(r, ngx_http_auth_basic_module);
-
- if (ctx) {
- return ngx_http_auth_basic_crypt_handler(r, ctx, &ctx->passwd,
- &realm);
- }
-
rc = ngx_http_auth_basic_user(r);
if (rc == NGX_DECLINED) {
@@ -237,8 +224,7 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
pwd.len = i - passwd;
pwd.data = &buf[passwd];
- return ngx_http_auth_basic_crypt_handler(r, NULL, &pwd,
- &realm);
+ return ngx_http_auth_basic_crypt_handler(r, &pwd, &realm);
}
break;
@@ -276,7 +262,7 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
ngx_cpystrn(pwd.data, &buf[passwd], pwd.len + 1);
- return ngx_http_auth_basic_crypt_handler(r, NULL, &pwd, &realm);
+ return ngx_http_auth_basic_crypt_handler(r, &pwd, &realm);
}
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
@@ -288,8 +274,8 @@ ngx_http_auth_basic_handler(ngx_http_request_t *r)
static ngx_int_t
-ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r,
- ngx_http_auth_basic_ctx_t *ctx, ngx_str_t *passwd, ngx_str_t *realm)
+ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r, ngx_str_t *passwd,
+ ngx_str_t *realm)
{
ngx_int_t rc;
u_char *encrypted;
@@ -301,48 +287,22 @@ ngx_http_auth_basic_crypt_handler(ngx_http_request_t *r,
"rc: %i user: \"%V\" salt: \"%s\"",
rc, &r->headers_in.user, passwd->data);
- if (rc == NGX_OK) {
- if (ngx_strcmp(encrypted, passwd->data) == 0) {
- return NGX_OK;
- }
-
- ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "encrypted: \"%s\"", encrypted);
-
- ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
- "user \"%V\": password mismatch",
- &r->headers_in.user);
-
- return ngx_http_auth_basic_set_realm(r, realm);
- }
-
- if (rc == NGX_ERROR) {
+ if (rc != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- /* rc == NGX_AGAIN */
-
- if (ctx == NULL) {
- ctx = ngx_palloc(r->pool, sizeof(ngx_http_auth_basic_ctx_t));
- if (ctx == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
- }
-
- ngx_http_set_ctx(r, ctx, ngx_http_auth_basic_module);
-
- ctx->passwd.len = passwd->len;
- passwd->len++;
-
- ctx->passwd.data = ngx_pstrdup(r->pool, passwd);
- if (ctx->passwd.data == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
- }
-
+ if (ngx_strcmp(encrypted, passwd->data) == 0) {
+ return NGX_OK;
}
- /* TODO: add mutex event */
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "encrypted: \"%s\"", encrypted);
+
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "user \"%V\": password mismatch",
+ &r->headers_in.user);
- return rc;
+ return ngx_http_auth_basic_set_realm(r, realm);
}