indigo-dc / flaat

FLAsk with Access Tokens - FLAAT
MIT License
11 stars 6 forks source link

Error getting issuer_config when `self.iss` is set #42

Closed dianagudu closed 3 years ago

dianagudu commented 3 years ago

The function find_issuer_config_in_string sometimes returns a list, sometimes the JSON config directly (dict): https://github.com/indigo-dc/flaat/blob/cabe27168e8de1cc46375e653900256ccd3c28e6/flaat/issuertools.py#L81-L97

However, when called, it is assumed to be a dict, not a list: https://github.com/indigo-dc/flaat/blob/cabe27168e8de1cc46375e653900256ccd3c28e6/flaat/__init__.py#L295-L297

This leads to the following error:

Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/home/diana/workspace/ssh-oidc/venv/lib/python3.9/site-packages/flaat/__init__.py", line 363, in thread_worker_get_userinfo
    result = issuertools.get_user_info(item['access_token'], item['issuer_config'])
  File "/home/diana/workspace/ssh-oidc/venv/lib/python3.9/site-packages/flaat/issuertools.py", line 218, in get_user_info
    logger.info('Getting userinfo from %s' % issuer_config['userinfo_endpoint'])
TypeError: list indices must be integers or slices, not str

Fix: always return iss_config in find_issuer_config_in_string.