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

[1.4.0rc*] PY3: login using http basic auth is broken #3384

Closed
foosel opened this issue Dec 11, 2019 · 2 comments
Closed

[1.4.0rc*] PY3: login using http basic auth is broken #3384

foosel opened this issue Dec 11, 2019 · 2 comments

Comments

@foosel
Copy link
Owner

@foosel foosel commented Dec 11, 2019

login using http basic auth is broken

Traceback (most recent call last):
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/tornado/web.py", line 1489, in _execute
    result = self.prepare()
  File "/home/bzed/tools/OctoPrint/src/octoprint/server/util/tornado.py", line 257, in prepare
    self._fallback(self.request, b"")
  File "/home/bzed/tools/OctoPrint/src/octoprint/server/util/tornado.py", line 619, in __call__
    WsgiInputContainer.environ(request, body), start_response)
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/app.py", line 1610, in full_dispatch_request
    rv = self.preprocess_request()
  File "/home/bzed/tools/OctoPrint/venv/lib/python3.7/site-packages/flask/app.py", line 1831, in preprocess_request
    rv = func()
  File "/home/bzed/tools/OctoPrint/src/octoprint/server/util/__init__.py", line 55, in loginFromAuthorizationHeaderRequestHandler
    if loginUserFromAuthorizationHeader():
  File "/home/bzed/tools/OctoPrint/src/octoprint/server/util/__init__.py", line 83, in loginUserFromAuthorizationHeader
    user = get_user_for_authorization_header(authorization_header)
  File "/home/bzed/tools/OctoPrint/src/octoprint/server/util/__init__.py", line 240, in get_user_for_authorization_header
    name, password = header.split(':', 1)
TypeError: a bytes-like object is required, not 'str'

I think the fix is

diff --git a/src/octoprint/server/util/__init__.py
b/src/octoprint/server/util/__init__.py
index 3e9a8c124..7b2dac664 100644
--- a/src/octoprint/server/util/__init__.py
+++ b/src/octoprint/server/util/__init__.py
@@ -237,7 +237,7 @@ def get_user_for_authorization_header(header):
        except TypeError:
                return None

-       name, password = header.split(':', 1)
+       name, password = str(header).split(':', 1)
        if not octoprint.server.userManager.enabled:
                return None
diff --git a/src/octoprint/server/util/__init__.py
b/src/octoprint/server/util/__init__.py
index 3e9a8c124..7b2dac664 100644
--- a/src/octoprint/server/util/__init__.py
+++ b/src/octoprint/server/util/__init__.py
@@ -237,7 +237,7 @@ def get_user_for_authorization_header(header):
        except TypeError:
                return None

-       name, password = header.split(':', 1)
+       name, password = str(header).split(':', 1)
        if not octoprint.server.userManager.enabled:
                return None

unfortunately something else fscked up the login, so I did not test it properly.

Originally posted by @bzed in #3382 (comment)

@foosel foosel added this to the 1.4.0 milestone Dec 11, 2019
@foosel

This comment has been minimized.

Copy link
Owner Author

@foosel foosel commented Dec 11, 2019

Fixed in 9f85b54

@foosel

This comment has been minimized.

Copy link
Owner Author

@foosel foosel commented Dec 12, 2019

1.4.0rc3 has just been released

@foosel foosel closed this Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.