Skip to content

Commit 2f98a27

Browse files
Updated env var
1 parent 652a15f commit 2f98a27

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docs/authentication.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ auth.login()
1717
# log out with auth.logout()
1818
```
1919
Setting `skip_tls=True` allows interaction with an HTTPS server bypassing the server certificate checks although this is not secure.<br>
20-
You can pass a custom certificate to `TokenAuthentication` by using `ca_cert_path="/path/to/cert"` when authenticating provided `skip_tls=False`.
20+
You can pass a custom certificate to `TokenAuthentication` by using `ca_cert_path="/path/to/cert"` when authenticating provided `skip_tls=False`. Alternatively you can set the environment variable `CF_SDK_CA_CERT_PATH` to the path of your custom certificate.
2121

2222
## Method 2 Kubernetes Config File Authentication (Default location)
2323
If a user has authenticated to their cluster by alternate means e.g. run a login command like `oc login --token=<token> --server=<server>` their kubernetes config file should have updated.<br>

src/codeflare_sdk/cluster/auth.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ def login(self) -> str:
106106
configuration.api_key_prefix["authorization"] = "Bearer"
107107
configuration.host = self.server
108108
configuration.api_key["authorization"] = self.token
109-
ca_path_env = os.environ.get("CA_CERT_PATH")
109+
ca_path_env = os.environ.get("CF_SDK_CA_CERT_PATH", self.ca_cert_path)
110110

111111
if self.skip_tls == False:
112-
if ca_path_env != None:
112+
if ca_path_env != self.ca_cert_path:
113113
self.ca_cert_path = ca_path_env
114114

115115
if self.ca_cert_path == None:

tests/unit_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def test_token_auth_login_tls(mocker):
181181
)
182182
assert token_auth.login() == ("Logged into testserver:6443")
183183

184-
os.environ["CA_CERT_PATH"] = f"{parent}/tests/auth-test.crt"
184+
os.environ["CF_SDK_CA_CERT_PATH"] = f"{parent}/tests/auth-test.crt"
185185
token_auth = TokenAuthentication(
186186
token="testtoken",
187187
server="testserver:6443",

0 commit comments

Comments
 (0)