Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[roswww] fix basic authentication for python3 #59

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/roswww/roswww_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import base64
import functools
import socket
import sys
import tornado.ioloop # rosbridge installs tornado
import tornado.web
import yaml
Expand All @@ -64,7 +65,10 @@ def new_f(*args):
if not auth_header.startswith('Basic '):
return _request_auth(handler)

auth_decoded = base64.decodestring(auth_header.split(' ', 1)[1])
if sys.version_info.major >= 3:
auth_decoded = base64.decodestring(auth_header.split(' ', 1)[1].encode('ascii')).decode('utf-8')
else:
auth_decoded = base64.decodestring(auth_header.split(' ', 1)[1])
username, password = auth_decoded.split(':', 1)

if auth(username, password):
Expand Down