Can't login if auth_file.json is invalid
valenting opened this issue · 1 comments
valenting commented
If an auth_file.json isn't properly formatted (such as it contains an extra ,
or misses one), the login will fail.
Open up your browser's dev tools, and look at the request to
GET services/services.py/login?username=<>&password=<>
You will see the following stack trace
{"errorMessage": "", "errorType": 2, "errorTrace": "Traceback (most recent call last):
File \"/home/vmchecker/public_html/services/services.py\", line 596, in login
user = websutil.get_user(username, password)
File \"/usr/local/lib/python2.6/dist-packages/vmchecker/websutil.py\", line 61, in get_user
r = get_user_from_auth_files(username, password)
File \"/usr/local/lib/python2.6/dist-packages/vmchecker/websutil.py\", line 76, in get_user_from_auth_files
r = get_user_from_auth_file(vmpaths, username, password)
File \"/usr/local/lib/python2.6/dist-packages/vmchecker/websutil.py\", line 92, in get_user_from_auth_file
auth_dic = json.loads(auth_file_contents)['auth']
File \"/usr/lib/pymodules/python2.6/simplejson/__init__.py\", line 384, in loads
return _default_decoder.decode(s)
File \"/usr/lib/pymodules/python2.6/simplejson/decoder.py\", line 402, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File \"/usr/lib/pymodules/python2.6/simplejson/decoder.py\", line 418, in raw_decode
obj, end = self.scan_once(s, idx)
JSONDecodeError: Expecting property name: line 6 column 5 (char 207)
"}
A try-catch should be inserted at websutil.py at line 92.
calin-iorgulescu commented
Quote from the get_user()
function in vmchecker/websutil.py
:
# allthough a misconfigured user can block access to any course,
# we preffer early LOUD errors to silently ignored ones.
# Fail fast, fail lowdly!
I believe that this was the intended behavior, so that mistakes could be spotted early on.