Skip to content

Fix application of command line arguments

Karol Krizka requested to merge kk_fixcmdline into master

The command line arguments (either as arguments or via the prompt) for the access codes are currently not picked up by itkdb. The problem is that the commandline module propagates the arguments to settings by setting environmental variables. However the settings have already been initialized at the time this happens, so setting the enviromental variable happens too late.

To reproduce the issue:

pip install itkdb==0.3.15
itkdb --accessCode1 test1 --accessCode2 test2 authenticate

The second line fails with the following. Note the empty access codes.

{"grant_type": "password", "accessCode1": "", "accessCode2": "", "scope": "openid https://itkpd-test.unicorncollege.cz"}

The following details may help:
{
  "uuAppErrorMap": {
    "uu-oidc-main/grantToken/unexpectedError": {
      "id": "1f35e77d61e942e5a953a3ba101a0c44",
      "timestamp": "2021-12-21T18:16:25.422Z",
      "type": "error",
      "message": "Grant token failed.",
      "cause": {
        "uu.app.error/UNEXPECTED_INTERNAL_EXCEPTION": {
          "id": "558b3c907342443d8e057e06e174fcba",
          "type": "error",
          "message": "Secret must be not null."
        }
      }
    }
  },
  "error_description": "Secret must be not null.",
  "error": "server_error"
}

This fixes it by doing two things:

  • All command line arguments (access codes, site/auth URL's) directly modify the attributes of _session and _session._user.
  • Add User._prefix_url attribute that corresponds to the AUTH_URL instead of hardcoded call to the settings module. The other attributes already existed.

Merge request reports