Skip to content

Commit

Permalink
Add simultaneous support for Werkzeug 2 and 3
Browse files Browse the repository at this point in the history
This is the follow-up for PR #1356.

(cherry picked from commit 860c82b)
  • Loading branch information
dbalagansky authored and mergify[bot] committed Mar 15, 2024
1 parent 75a87ea commit 74934e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion gnocchi/rest/auth_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ def get_current_user(request):
hdr = request.headers.get("Authorization")
auth_hdr = (hdr.decode('utf-8') if isinstance(hdr, bytes)
else hdr)
auth = werkzeug.http.parse_authorization_header(auth_hdr)

try:
auth = werkzeug.http.parse_authorization_header(auth_hdr)
except AttributeError:
auth = werkzeug.datastructures.Authorization.from_header(auth_hdr)

if auth is None:
api.abort(401)
return auth.username
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ install_requires =
stevedore
ujson
voluptuous>=0.8.10
werkzeug<3.0.0
werkzeug
trollius; python_version < '3.4'
tenacity>=5.0.0
WebOb>=1.4.1
Expand Down

0 comments on commit 74934e6

Please sign in to comment.