Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Ensure no base64 incorrect padding errors occur in PY3 #132

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
8 changes: 6 additions & 2 deletions config/kube_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,11 @@ def _load_oid_token(self, provider):
if len(parts) != 3: # Not a valid JWT
return None

# Adding == to ensure sufficient padding. Extra padding is ignored
# by Python
if PY3:
jwt_attributes = json.loads(
base64.b64decode(parts[1]).decode('utf-8')
base64.b64decode(parts[1] + "==").decode('utf-8')
)
else:
jwt_attributes = json.loads(
Expand All @@ -311,9 +313,11 @@ def _refresh_oidc(self, provider):
if 'idp-certificate-authority-data' in provider['config']:
ca_cert = tempfile.NamedTemporaryFile(delete=True)

# Adding == to ensure sufficient padding. Extra padding is ignored
# by Python
if PY3:
cert = base64.b64decode(
provider['config']['idp-certificate-authority-data']
provider['config']['idp-certificate-authority-data'] + "=="
).decode('utf-8')
else:
cert = base64.b64decode(
Expand Down