forked from denji/homebrew-nginx
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathauth-digest-nginx-module.rb
48 lines (41 loc) · 1.94 KB
/
auth-digest-nginx-module.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class AuthDigestNginxModule < Formula
desc "Digest Authentication for Nginx"
homepage "https://github.com/samizdatco/nginx-http-auth-digest"
url "https://github.com/samizdatco/nginx-http-auth-digest/archive/bd1c86a.tar.gz"
version "0.1"
sha256 "c950810be28e5cece5c6b30aefe96147681d4b74bace25e8dcad2a1cb75a861f"
revision 1
patch :DATA
def install
pkgshare.install Dir["*"]
end
end
__END__
diff --git a/ngx_http_auth_digest_module.c b/ngx_http_auth_digest_module.c
index 28eb587..1680a29 100644
--- a/ngx_http_auth_digest_module.c
+++ b/ngx_http_auth_digest_module.c
@@ -403,11 +403,11 @@ ngx_http_auth_digest_verify_hash(ngx_http_request_t *r, ngx_http_auth_digest_cre
if (http_method.data==NULL) return NGX_HTTP_INTERNAL_SERVER_ERROR;
p = ngx_cpymem(http_method.data, r->method_name.data, r->method_end - r->method_name.data+1);
- ha2_key.len = http_method.len + r->uri.len + 1;
+ ha2_key.len = http_method.len + fields->uri.len;
ha2_key.data = ngx_pcalloc(r->pool, ha2_key.len);
if (ha2_key.data==NULL) return NGX_HTTP_INTERNAL_SERVER_ERROR;
p = ngx_cpymem(ha2_key.data, http_method.data, http_method.len-1); *p++ = ':';
- p = ngx_cpymem(p, r->uri.data, r->uri.len);
+ p = ngx_cpymem(p, fields->uri.data, fields->uri.len-1);
HA2.len = 33;
HA2.data = ngx_pcalloc(r->pool, HA2.len);
@@ -487,11 +487,11 @@ ngx_http_auth_digest_verify_hash(ngx_http_request_t *r, ngx_http_auth_digest_cre
// recalculate the digest with a modified HA2 value (for rspauth) and emit the
// Authentication-Info header
ngx_memset(ha2_key.data, 0, ha2_key.len);
- p = ngx_sprintf(ha2_key.data, ":%s", r->uri.data);
+ p = ngx_sprintf(ha2_key.data, ":%s", fields->uri.data);
ngx_memset(HA2.data, 0, HA2.len);
ngx_md5_init(&md5);
- ngx_md5_update(&md5, ha2_key.data, r->uri.len);
+ ngx_md5_update(&md5, ha2_key.data, fields->uri.len-1);
ngx_md5_final(hash, &md5);
ngx_hex_dump(HA2.data, hash, 16);