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

Commit

Permalink
Ensure no incorrect padding errors occur in PY3
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphje committed Apr 30, 2019
1 parent 1d5231c commit 792bb5e
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 792bb5e

Please sign in to comment.