cyberark / cyberark-conjur-cli

CyberArk Conjur command line interface written in Python
https://www.conjur.org
Apache License 2.0
17 stars 16 forks source link

Reference before assignment in login #409

Open hughsaunders opened 2 years ago

hughsaunders commented 2 years ago

Summary

When logging into conjur using a self signed cert I encountered a reference before assignment error.

Steps to Reproduce

  1. Install cyberark-conjur-cli v7.1.0 via DMG on macOS 12.3.1
  2. Initialise the cli:
    
    $ conjur init -u https://localhost -a conjur -s
    Using self-signed certificates is not recommended and could lead to exposure of sensitive data.
    Continue? yes/no (Default: no): yes

The Conjur server's certificate SHA-1 fingerprint is: 18:22:53:16:6E:6C:B4:52:B4:4F:D3:0E:5E:16:74:34:C8:AF:FF:76

To verify this certificate, we recommend running the following command on the Conjur server: openssl x509 -fingerprint -noout -in ~conjur/etc/ssl/conjur.pem

Trust this certificate? yes/no (Default: no): yes File /Users/hugh.saunders/conjur-server.pem exists. Overwrite? yes/no (Default: yes): yes Certificate written to /Users/hugh.saunders/conjur-server.pem

File /Users/hugh.saunders/.conjurrc exists. Overwrite? yes/no (Default: yes): yes Configuration written to /Users/hugh.saunders/.conjurrc

Successfully initialized the Conjur CLI To start using the Conjur CLI, log in to the Conjur server by running conjur login


3. Login:

$ conjur --debug login -i admin -p ** 2022-05-20 14:13:02,063 DEBUG: Attempting to fetch 'admin' API key from Conjur... 2022-05-20 14:13:02,063 DEBUG: Invoke endpoint. Verb: 'GET', Endpoint: 'LOGIN', Params: '{'url': 'https://localhost', 'account': 'conjur'}', Data length: '0', Check errors: 'True', SSL verification metadata: '{'mode': <SslVerificationMode.SELF_SIGN: 2>, 'ca_cert_path': '/Users/hugh.saunders/conjur-server.pem'}', Basic auth user: 'admin', using API token: 'False', Query params: 'None', Headers: 'None', Decode token: 'True' 2022-05-20 14:13:02,063 DEBUG: Using selector: KqueueSelector 2022-05-20 14:13:02,073 DEBUG: SSLContext created successfully 2022-05-20 14:13:02,084 DEBUG: API key retrieved from Conjur 2022-05-20 14:13:02,085 DEBUG: Traceback (most recent call last): File "conjur/cli.py", line 75, in run File "conjur/cli.py", line 101, in run_action File "conjur/cli.py", line 129, in _run_auth_flow File "conjur/cli_actions.py", line 81, in handle_login_logic File "conjur/controller/login_controller.py", line 51, in load File "conjur/controller/login_controller.py", line 92, in get_api_key File "conjur/logic/login_logic.py", line 60, in get_api_key UnboundLocalError: local variable 'api_key' referenced before assignment

Failed to execute command. Reason: local variable 'api_key' referenced before assignment



## Expected Results

Successful login

## Actual Results

An exception, see above. 

## Reproducible

   * [x] Always 
   * [ ] Sometimes
   * [ ] Non-Reproducible

## Version/Tag number

v1.7.0

## Environment setup
macOS 12.3.1 

## Additional Information

*Add any other context about the problem here.*
emeric-martineau commented 10 months ago

Same issue with Windows 10

feven-NIT commented 8 months ago

Get the same issue in centos 9