steiza / docstore

For any civics-minded organization that needs a simple place to host documents publicly
http://a2docs.org/
7 stars 4 forks source link

Auth Broken in Python 3 #31

Closed eby closed 3 years ago

eby commented 3 years ago

Haven't had time to dig but guessing maybe a python 3+ issue? Could also be nginx needs specific config for that path but looking at some other posts it sounds like behaviour changed in 3.x and things have to be encoded manually.

Traceback (most recent call last):
  File "/usr/lib/python3.8/base64.py", line 510, in _input_type_check
    m = memoryview(s)
TypeError: memoryview: a bytes-like object is required, not 'str'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/tornado/web.py", line 1702, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "/var/www/a2docs/docstore", line 490, in get
    auth_decoded = base64.decodestring(auth_header[6:])
  File "/usr/lib/python3.8/base64.py", line 554, in decodestring
    return decodebytes(s)
  File "/usr/lib/python3.8/base64.py", line 545, in decodebytes
    _input_type_check(s)
  File "/usr/lib/python3.8/base64.py", line 513, in _input_type_check
    raise TypeError(msg) from err
TypeError: expected bytes-like object, not str
steiza commented 3 years ago

Oops! This was definitely missed in the Python 3 conversion.

This should be fixed (along with XSRF handling in the delete flow) in https://github.com/steiza/docstore/commit/cc6d80286b53f012be9cad3a554b67bc24fc508b