Mercurial > hg > nginx
comparison src/http/modules/ngx_http_auth_basic_module.c @ 2523:7764f0fdd2a4
add auth basic failure logging
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 23 Feb 2009 15:15:42 +0000 |
parents | 2a92804f4109 |
children | fd4ee75c6eee |
comparison
equal
deleted
inserted
replaced
2522:93d83e6c198c | 2523:7764f0fdd2a4 |
---|---|
124 } | 124 } |
125 | 125 |
126 rc = ngx_http_auth_basic_user(r); | 126 rc = ngx_http_auth_basic_user(r); |
127 | 127 |
128 if (rc == NGX_DECLINED) { | 128 if (rc == NGX_DECLINED) { |
129 | |
130 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
131 "no user/password was provided for basic authentication"); | |
132 | |
129 return ngx_http_auth_basic_set_realm(r, &alcf->realm); | 133 return ngx_http_auth_basic_set_realm(r, &alcf->realm); |
130 } | 134 } |
131 | 135 |
132 if (rc == NGX_ERROR) { | 136 if (rc == NGX_ERROR) { |
133 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 137 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
240 ngx_cpystrn(pwd.data, &buf[passwd], pwd.len + 1); | 244 ngx_cpystrn(pwd.data, &buf[passwd], pwd.len + 1); |
241 | 245 |
242 return ngx_http_auth_basic_crypt_handler(r, NULL, &pwd, &alcf->realm); | 246 return ngx_http_auth_basic_crypt_handler(r, NULL, &pwd, &alcf->realm); |
243 } | 247 } |
244 | 248 |
249 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
250 "user \"%V\" was not found in \"%V\"", | |
251 &r->headers_in.user, &alcf->user_file); | |
252 | |
245 return ngx_http_auth_basic_set_realm(r, &alcf->realm); | 253 return ngx_http_auth_basic_set_realm(r, &alcf->realm); |
246 } | 254 } |
247 | 255 |
248 | 256 |
249 static ngx_int_t | 257 static ngx_int_t |
255 | 263 |
256 rc = ngx_crypt(r->pool, r->headers_in.passwd.data, passwd->data, | 264 rc = ngx_crypt(r->pool, r->headers_in.passwd.data, passwd->data, |
257 &encrypted); | 265 &encrypted); |
258 | 266 |
259 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 267 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
260 "rc: %d user: \"%V\" salt: \"%s\"", | 268 "rc: %d user: \"%V\" salt: \"%s\"", |
261 rc, &r->headers_in.user, passwd->data); | 269 rc, &r->headers_in.user, passwd->data); |
262 | 270 |
263 if (rc == NGX_OK) { | 271 if (rc == NGX_OK) { |
264 if (ngx_strcmp(encrypted, passwd->data) == 0) { | 272 if (ngx_strcmp(encrypted, passwd->data) == 0) { |
265 return NGX_OK; | 273 return NGX_OK; |
266 } | 274 } |
267 | 275 |
268 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 276 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
269 "encrypted: \"%s\"", encrypted); | 277 "encrypted: \"%s\"", encrypted); |
278 | |
279 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
280 "user \"%V\": password mismatch", | |
281 &r->headers_in.user); | |
270 | 282 |
271 return ngx_http_auth_basic_set_realm(r, realm); | 283 return ngx_http_auth_basic_set_realm(r, realm); |
272 } | 284 } |
273 | 285 |
274 if (rc == NGX_ERROR) { | 286 if (rc == NGX_ERROR) { |