Skip to content

Commit b6717c6

Browse files
1 parent 0df6534 commit b6717c6

File tree

5 files changed

+66
-0
lines changed

5 files changed

+66
-0
lines changed

ngx_http_auth_digest_module.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ ngx_http_auth_digest_verify_hash(ngx_http_request_t *r, ngx_http_auth_digest_cre
769769
info_header->key = hkey;
770770
info_header->value = hval;
771771
info_header->hash = 1;
772+
773+
r->headers_in.user = fields->username;
774+
772775
return NGX_OK;
773776
}else{
774777
invalid:

readme.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,15 @@ auth_digest_shm_size
173173
.. _Digest Authentication: http://en.wikipedia.org/wiki/Digest_access_authentication
174174
.. _Issue Tracker: https://github.com/samizdatco/nginx-http-auth-digest/issues
175175
.. _MitM: http://en.wikipedia.org/wiki/Man-in-the-middle_attack
176+
177+
Testing
178+
==========
179+
Make sure to compile nginx with the ngx_echo module: https://github.com/openresty/echo-nginx-module::
180+
181+
$ ./configure --add-module=../samizdatco-nginx-http-auth-digest-xxxxxxx --add-module=../echo-nginx-module [other configure options]
182+
183+
After that you can run the test against the nginx binary::
184+
185+
$ cd test
186+
$ NGINX=/home/erik/nginx-1.9.1/objs/nginx ./test.sh
187+

test/.htdigest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test:test:aeeebbfd75d1499d24388f5b9b10e0ef

test/server.conf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
3+
worker_processes 8;
4+
worker_rlimit_nofile 512;
5+
6+
pid test.pid;
7+
daemon off;
8+
9+
error_log /dev/stdout crit;
10+
11+
events {
12+
worker_connections 512;
13+
multi_accept on;
14+
use epoll;
15+
}
16+
17+
http {
18+
include /etc/nginx/mime.types;
19+
default_type application/octet-stream;
20+
21+
access_log /dev/stdout;
22+
access_log off;
23+
24+
server {
25+
listen 127.0.0.1:9090;
26+
server_name example.com;
27+
28+
auth_digest_user_file .htdigest;
29+
30+
location /remote_user_set {
31+
auth_digest 'test';
32+
echo "remote_user: $remote_user";
33+
}
34+
location /remote_user_unset {
35+
echo "remote_user: $remote_user";
36+
}
37+
}
38+
}
39+

test/test.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
$NGINX -p $PWD -c server.conf &
4+
sleep 1
5+
6+
curl -s -S -H "Host: example.com" --digest -u "test:test" "http://127.0.0.1:9090/remote_user_set"
7+
curl -s -S -H "Host: example.com" --digest -u "test:test" "http://127.0.0.1:9090/remote_user_unset"
8+
curl -s -S -H "Host: example.com" "http://127.0.0.1:9090/remote_user_unset"
9+
10+
kill `cat test.pid`
11+
sleep 1

0 commit comments

Comments
 (0)