Skip to content

IBMid Authentication support #1447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 6, 2021

Conversation

allmightyspiff
Copy link
Member

Allows for using an IBMid when using config setup.

Testing

  • slcli config setup --ibmid
    Will let you login with the Username/Password that you can login to cloud.ibm.com with (unless you have an @ibm.com email, then use --sso)
  • slcli config setup --sso
    Lets you login with your SSO Token, will prompt the user to open a webpage to get the token
  • slcli config setup --cloud_key
    Uses a IBM Cloud API key to login
  • slcli config setup --classic_key
    Old behavior, uses classic API keys. Can still use the old SL password as well.

The IBMid setups will still create an SL API key for the user at the end though.

Copy link
Contributor

@ATGE ATGE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing

  • ✔️ $ slcli config setup --auth=cloud_key
  • ✔️ $ slcli config setup --auth classic_key
  • ❌ $ slcli config setup --auth sso
Endpoint (public|private|custom) [https://api.softlayer.com/rest/v3.1]: 
Get a one-time code from https://identity-1.us-south.iam.cloud.ibm.com/identity/passcode to proceed.

Open the URL in the default browser? [Y/n] [Y]: n
One-time code: code-test
An unexpected error has occured:
Traceback (most recent call last):
  File "/home/.../lib/python3.6/site-packages/SoftLayer-5.9.3-py3.6.egg/SoftLayer/CLI/core.py", line 209, in main
    cli.main(**kwargs)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/.../lib/python3.6/site-packages/SoftLayer-5.9.3-py3.6.egg/SoftLayer/CLI/config/setup.py", line 83, in cli
    username, api_key = sso_login(env)
  File "/home/.../lib/python3.6/site-packages/SoftLayer-5.9.3-py3.6.egg/SoftLayer/CLI/config/setup.py", line 255, in sso_login
    client = SoftLayer.API.IAMClient(config_file=env.config_file)
  File "/home/.../lib/python3.6/site-packages/SoftLayer-5.9.3-py3.6.egg/SoftLayer/API.py", line 178, in __init__
    timeout=self.settings['softlayer'].getint('timeout'),
  File "/usr/lib/python3.6/configparser.py", line 1283, in get
    fallback=fallback, **kwargs)
  File "/usr/lib/python3.6/configparser.py", line 819, in getint
    fallback=fallback, **kwargs)
  File "/usr/lib/python3.6/configparser.py", line 809, in _get_conv
    **kwargs)
  File "/usr/lib/python3.6/configparser.py", line 803, in _get
    return conv(self.get(section, option, **kwargs))
ValueError: invalid literal for int() with base 10: '30.0'
  • ❌ $ slcli config setup --auth ibmid
Endpoint (public|private|custom) [https://api.softlayer.com/rest/v3.1]: 
Email: [email protected]
Password: 
An unexpected error has occured:
Traceback (most recent call last):
  File "/home/.../lib/python3.6/site-packages/SoftLayer-5.9.3-py3.6.egg/SoftLayer/CLI/core.py", line 209, in main
    cli.main(**kwargs)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/.../lib/python3.6/site-packages/Click-7.0-py3.6.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/.../lib/python3.6/site-packages/SoftLayer-5.9.3-py3.6.egg/SoftLayer/CLI/config/setup.py", line 74, in cli
    username, api_key = ibmid_login(env)
  File "/home/.../lib/python3.6/site-packages/SoftLayer-5.9.3-py3.6.egg/SoftLayer/CLI/config/setup.py", line 153, in ibmid_login
    client = SoftLayer.API.IAMClient(config_file=env.config_file)
  File "/home/.../lib/python3.6/site-packages/SoftLayer-5.9.3-py3.6.egg/SoftLayer/API.py", line 178, in __init__
    timeout=self.settings['softlayer'].getint('timeout'),
  File "/usr/lib/python3.6/configparser.py", line 1283, in get
    fallback=fallback, **kwargs)
  File "/usr/lib/python3.6/configparser.py", line 819, in getint
    fallback=fallback, **kwargs)
  File "/usr/lib/python3.6/configparser.py", line 809, in _get_conv
    **kwargs)
  File "/usr/lib/python3.6/configparser.py", line 803, in _get
    return conv(self.get(section, option, **kwargs))
ValueError: invalid literal for int() with base 10: '30.0'

As a workaround, changing the value in the file "~/.softlayer" from timeout = 30.0 to timeout = 30, then failed tests work as expected.

  • OS ubuntu 18

@FernandoOjeda
Copy link
Contributor

If I use the following command to authenticate with wrong credentials, I got an error.

slcli config setup --auth ibmid

image

@FernandoOjeda
Copy link
Contributor

FernandoOjeda commented Mar 29, 2021

If I enter a invalid One-time code data using slcli config setup --auth sso, I got the following error.

image

@allmightyspiff
Copy link
Member Author

Fixed the issue with floating point timeouts, and better handling of IBMid Authentication.

image

@allmightyspiff allmightyspiff linked an issue Apr 2, 2021 that may be closed by this pull request
Copy link
Contributor

@FernandoOjeda FernandoOjeda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and It is working well.

Copy link
Contributor

@caberos caberos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@allmightyspiff allmightyspiff merged commit 170418c into softlayer:master Apr 6, 2021
@allmightyspiff allmightyspiff deleted the issues1315 branch April 6, 2021 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ibmcloud authentication support
4 participants