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

Commit 792bb5e

Browse files
committed
Ensure no incorrect padding errors occur in PY3
1 parent 1d5231c commit 792bb5e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

config/kube_config.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ def _load_oid_token(self, provider):
282282
if len(parts) != 3: # Not a valid JWT
283283
return None
284284

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

316+
# Adding == to ensure sufficient padding. Extra padding is ignored
317+
# by Python
314318
if PY3:
315319
cert = base64.b64decode(
316-
provider['config']['idp-certificate-authority-data']
320+
provider['config']['idp-certificate-authority-data'] + "=="
317321
).decode('utf-8')
318322
else:
319323
cert = base64.b64decode(

0 commit comments

Comments
 (0)