Skip to content

Commit

Permalink
Merge pull request #283 from ThomasWaldmann/fix-auth-decode
Browse files Browse the repository at this point in the history
api basic auth - ignore non-utf8 chars, fixes #282
  • Loading branch information
ThomasWaldmann committed Sep 5, 2016
2 parents fbb781d + 2533910 commit 8b594c8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nsupdate/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ def basic_authenticate(auth):
authmeth, auth = auth.split(' ', 1)
if authmeth.lower() != 'basic':
return
auth = base64.b64decode(auth.strip()).decode('utf-8')
# we ignore bytes that do not decode. username (hostname) and password
# (update secret) both have to be ascii, everything else is a configuration
# error on user side.
auth = base64.b64decode(auth.strip()).decode('utf-8', errors='ignore')
username, password = auth.split(':', 1)
return username, password

Expand Down

0 comments on commit 8b594c8

Please sign in to comment.