Skip to content

Commit

Permalink
Added x509 certificate support to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Gallo committed Jul 31, 2024
1 parent 2fd0c4d commit 0a8ca6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions SoftLayer/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ def employee_client(username=None,
access_token = settings.get('access_token')

user_id = settings.get('userid')

# Assume access_token is valid for now, user has logged in before at least.
if access_token and user_id:
if settings.get('auth_cert', False):
auth = slauth.X509Authentication(settings.get('auth_cert'), verify)
return EmployeeClient(auth=auth, transport=transport, config_file=config_file)
elif access_token and user_id:
auth = slauth.EmployeeAuthentication(user_id, access_token)
return EmployeeClient(auth=auth, transport=transport, config_file=config_file)
else:
Expand Down
6 changes: 4 additions & 2 deletions SoftLayer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def get_client_settings_config_file(**kwargs): # pylint: disable=inconsistent-r
'proxy': '',
'userid': '',
'access_token': '',
'verify': "True"
'verify': "True",
'auth_cert': ''
})
config.read(config_files)

Expand All @@ -74,7 +75,8 @@ def get_client_settings_config_file(**kwargs): # pylint: disable=inconsistent-r
'api_key': config.get('softlayer', 'api_key'),
'userid': config.get('softlayer', 'userid'),
'access_token': config.get('softlayer', 'access_token'),
'verify': config.get('softlayer', 'verify')
'verify': config.get('softlayer', 'verify'),
'auth_cert': config.get('softlayer', 'auth_cert')
}
if r_config["verify"].lower() == "true":
r_config["verify"] = True
Expand Down

0 comments on commit 0a8ca6b

Please sign in to comment.