Skip to content

Commit b63a7a1

Browse files
Adding SSL authentication support for internal users
1 parent f796629 commit b63a7a1

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

SoftLayer/auth.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
'TokenAuthentication',
1313
'BasicHTTPAuthentication',
1414
'AuthenticationBase',
15+
'X509Authentication'
1516
]
1617

1718

@@ -137,3 +138,23 @@ def get_request(self, request):
137138

138139
def __repr__(self):
139140
return f"BearerAuthentication(username={self.username}, token={self.api_key})"
141+
142+
class X509Authentication(AuthenticationBase):
143+
"""X509Authentication authentication class.
144+
145+
:param certificate str: Path to a users SSL certificate for authentication
146+
:param CA Cert str: Path to the CA bundle for softlayer hostnames.
147+
"""
148+
149+
def __init__(self, cert, ca_cert):
150+
self.cert = cert
151+
self.ca_cert = ca_cert
152+
153+
def get_request(self, request):
154+
"""Sets token-based auth headers."""
155+
request.cert = self.cert
156+
request.ca_cert = self.ca_cert
157+
return request
158+
159+
def __repr__(self):
160+
return f"X509Authentication(cert={cert}, ca_cert={ca_cert})"

SoftLayer/transports/transport.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ def __init__(self):
5959
#: Boolean specifying if the server certificate should be verified.
6060
self.verify = None
6161

62-
#: Client certificate file path.
62+
#: Client certificate file path. (Used by X509Authentication)
6363
self.cert = None
6464

65+
#: CA certificate for softlayer domains (Used by X509Authentication)
66+
self.ca_cert = None
67+
6568
#: InitParameter/identifier of an object.
6669
self.identifier = None
6770

0 commit comments

Comments
 (0)