Skip to content
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

Remove basic authentication #260

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions kr8s/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,9 @@ async def _create_session(self) -> None:
with contextlib.suppress(RuntimeError):
await self._session.aclose()
self._session = None
userauth = None
if self.auth.username and self.auth.password:
userauth = httpx.BasicAuth(self.auth.username, self.auth.password)
self._session = httpx.AsyncClient(
base_url=self.auth.server,
headers=headers,
auth=userauth,
verify=await self.auth.ssl_context(),
)

Expand Down Expand Up @@ -187,8 +183,6 @@ async def open_websocket(
if self.auth.token:
headers["Authorization"] = f"Bearer {self.auth.token}"
userauth = None
marceloFA marked this conversation as resolved.
Show resolved Hide resolved
if self.auth.username and self.auth.password:
userauth = aiohttp.BasicAuth(self.auth.username, self.auth.password)
url = self._construct_url(version, base, namespace, url)
kwargs.update(url=url, ssl=await self.auth.ssl_context())
auth_attempts = 0
Expand All @@ -197,7 +191,6 @@ async def open_websocket(
async with aiohttp.ClientSession(
base_url=self.auth.server,
headers=headers,
auth=userauth,
) as session:
async with session.ws_connect(**kwargs) as response:
yield response
Expand Down Expand Up @@ -254,8 +247,6 @@ async def _whoami(self):
) as r:
data = r.json()
return data["status"]["user"]["username"]
elif self.auth.username:
return f"kubecfg:basicauth:{self.auth.username}"
elif self.auth.client_cert_file:
with open(self.auth.client_cert_file, "rb") as f:
cert = x509.load_pem_x509_certificate(f.read())
Expand Down
6 changes: 0 additions & 6 deletions kr8s/_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def __init__(
self.client_key_file = None
self.server_ca_file = None
self.token = None
self.username = None
self.password = None
self.namespace = namespace
self.active_context = None
self._insecure_skip_tls_verify = False
Expand Down Expand Up @@ -182,10 +180,6 @@ async def _load_kubeconfig(self) -> None:
)
if "token" in self._user:
self.token = self._user["token"]
if "username" in self._user:
self.username = self._user["username"]
if "password" in self._user:
self.password = self._user["password"]
marceloFA marked this conversation as resolved.
Show resolved Hide resolved
if self.namespace is None:
self.namespace = self._context.get("namespace", "default")
if "auth-provider" in self._user:
Expand Down
Loading