Added
Link Here
|
1 |
--- httpbin/helpers.py.orig 2023-08-28 22:56:17 UTC |
2 |
+++ httpbin/helpers.py |
3 |
@@ -13,7 +13,15 @@ from hashlib import md5, sha256, sha512 |
4 |
import time |
5 |
import os |
6 |
from hashlib import md5, sha256, sha512 |
7 |
-from werkzeug.http import parse_authorization_header |
8 |
+# Can be removed when: https://github.com/psf/httpbin/issues/36 is closed |
9 |
+# See also (version order is wrong): |
10 |
+# https://src.fedoraproject.org/rpms/python-httpbin/c/54fe8e1f94f208b16ef0588e4eb69aaa107e9867?branch=rawhide |
11 |
+from werkzeug.http import dump_header |
12 |
+try: |
13 |
+ from werkzeug.datastructures import Authorization |
14 |
+ parse_authorization_header = Authorization.from_header |
15 |
+except ImportError: # werkzeug < 2.3 |
16 |
+ from werkzeug.http import parse_authorization_header |
17 |
from werkzeug.datastructures import WWWAuthenticate |
18 |
|
19 |
from flask import request, make_response |
20 |
@@ -466,9 +474,17 @@ def digest_challenge_response(app, qop, algorithm, sta |
21 |
]), algorithm) |
22 |
opaque = H(os.urandom(10), algorithm) |
23 |
|
24 |
- auth = WWWAuthenticate("digest") |
25 |
- auth.set_digest('me@kennethreitz.com', nonce, opaque=opaque, |
26 |
- qop=('auth', 'auth-int') if qop is None else (qop,), algorithm=algorithm) |
27 |
- auth.stale = stale |
28 |
+ # Can be removed when: https://github.com/psf/httpbin/issues/36 is closed |
29 |
+ # See also: |
30 |
+ # https://src.fedoraproject.org/rpms/python-httpbin/c/54fe8e1f94f208b16ef0588e4eb69aaa107e9867?branch=rawhide |
31 |
+ values = { |
32 |
+ 'realm': 'me@kennethreitz.com', |
33 |
+ 'nonce': nonce, |
34 |
+ 'opaque': opaque, |
35 |
+ 'qop': dump_header(('auth', 'auth-int') if qop is None else (qop,)), |
36 |
+ 'algorithm': algorithm, |
37 |
+ 'stale': stale, |
38 |
+ } |
39 |
+ auth = WWWAuthenticate("digest", values=values) |
40 |
response.headers['WWW-Authenticate'] = auth.to_header() |
41 |
return response |