/usr/share/pyshared/SoftLayer/auth.py is in python-softlayer 3.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """
SoftLayer.auth
~~~~~~~~~~~~~~
Module with the supported auth mechanisms for the SoftLayer API
:copyright: (c) 2013, SoftLayer Technologies, Inc. All rights reserved.
:license: MIT, see LICENSE for more details.
"""
__all__ = ['BasicAuthentication', 'TokenAuthentication', 'AuthenticationBase']
class AuthenticationBase(object):
def get_headers(self):
raise NotImplementedError
class TokenAuthentication(AuthenticationBase):
def __init__(self, user_id, auth_token):
self.user_id = user_id
self.auth_token = auth_token
def get_headers(self):
return {
'authenticate': {
'complexType': 'PortalLoginToken',
'userId': self.user_id,
'authToken': self.auth_token,
}
}
def __repr__(self):
return "<TokenAuthentication: %s %s>" % (self.user_id, self.auth_token)
class BasicAuthentication(AuthenticationBase):
def __init__(self, username, api_key):
self.username = username
self.api_key = api_key
def get_headers(self):
return {
'authenticate': {
'username': self.username,
'apiKey': self.api_key,
}
}
def __repr__(self):
return "<BasicAuthentication: %s>" % (self.username)
|