File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -257,13 +257,15 @@ def _load_oid_token(self, provider):
257257 if len (parts ) != 3 : # Not a valid JWT
258258 return None
259259
260+ padding = (4 - len (parts [1 ]) % 4 ) * '='
261+
260262 if PY3 :
261263 jwt_attributes = json .loads (
262- base64 .b64decode (parts [1 ]).decode ('utf-8' )
264+ base64 .b64decode (parts [1 ] + padding ).decode ('utf-8' )
263265 )
264266 else :
265267 jwt_attributes = json .loads (
266- base64 .b64decode (parts [1 ] + "==" )
268+ base64 .b64decode (parts [1 ] + padding )
267269 )
268270
269271 expire = jwt_attributes .get ('exp' )
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ def _base64(string):
4343 return base64 .encodestring (string .encode ()).decode ()
4444
4545
46+ def _unpadded_base64 (string ):
47+ return base64 .b64encode (string .encode ()).decode ().rstrip ('=' )
48+
49+
4650def _format_expiry_datetime (dt ):
4751 return dt .strftime (EXPIRY_DATETIME_FORMAT )
4852
@@ -87,11 +91,13 @@ def _raise_exception(st):
8791
8892TEST_OIDC_TOKEN = "test-oidc-token"
8993TEST_OIDC_INFO = "{\" name\" : \" test\" }"
90- TEST_OIDC_BASE = _base64 (TEST_OIDC_TOKEN ) + "." + _base64 (TEST_OIDC_INFO )
94+ TEST_OIDC_BASE = _unpadded_base64 (
95+ TEST_OIDC_TOKEN ) + "." + _unpadded_base64 (TEST_OIDC_INFO )
9196TEST_OIDC_LOGIN = TEST_OIDC_BASE + "." + TEST_CLIENT_CERT_BASE64
9297TEST_OIDC_TOKEN = "Bearer %s" % TEST_OIDC_LOGIN
9398TEST_OIDC_EXP = "{\" name\" : \" test\" ,\" exp\" : 536457600}"
94- TEST_OIDC_EXP_BASE = _base64 (TEST_OIDC_TOKEN ) + "." + _base64 (TEST_OIDC_EXP )
99+ TEST_OIDC_EXP_BASE = _unpadded_base64 (
100+ TEST_OIDC_TOKEN ) + "." + _unpadded_base64 (TEST_OIDC_EXP )
95101TEST_OIDC_EXPIRED_LOGIN = TEST_OIDC_EXP_BASE + "." + TEST_CLIENT_CERT_BASE64
96102TEST_OIDC_CA = _base64 (TEST_CERTIFICATE_AUTH )
97103
You can’t perform that action at this time.
0 commit comments