This repository was archived by the owner on Mar 13, 2022. It is now read-only.
File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -273,13 +273,15 @@ def _load_oid_token(self, provider):
273
273
if len (parts ) != 3 : # Not a valid JWT
274
274
return None
275
275
276
+ padding = (4 - len (parts [1 ]) % 4 ) * '='
277
+
276
278
if PY3 :
277
279
jwt_attributes = json .loads (
278
- base64 .b64decode (parts [1 ]).decode ('utf-8' )
280
+ base64 .b64decode (parts [1 ] + padding ).decode ('utf-8' )
279
281
)
280
282
else :
281
283
jwt_attributes = json .loads (
282
- base64 .b64decode (parts [1 ] + "==" )
284
+ base64 .b64decode (parts [1 ] + padding )
283
285
)
284
286
285
287
expire = jwt_attributes .get ('exp' )
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ def _base64(string):
49
49
return base64 .standard_b64encode (string .encode ()).decode ()
50
50
51
51
52
+ def _unpadded_base64 (string ):
53
+ return base64 .b64encode (string .encode ()).decode ().rstrip ('=' )
54
+
55
+
52
56
def _format_expiry_datetime (dt ):
53
57
return dt .strftime (EXPIRY_DATETIME_FORMAT )
54
58
@@ -96,11 +100,13 @@ def _raise_exception(st):
96
100
97
101
TEST_OIDC_TOKEN = "test-oidc-token"
98
102
TEST_OIDC_INFO = "{\" name\" : \" test\" }"
99
- TEST_OIDC_BASE = _base64 (TEST_OIDC_TOKEN ) + "." + _base64 (TEST_OIDC_INFO )
103
+ TEST_OIDC_BASE = _unpadded_base64 (
104
+ TEST_OIDC_TOKEN ) + "." + _unpadded_base64 (TEST_OIDC_INFO )
100
105
TEST_OIDC_LOGIN = TEST_OIDC_BASE + "." + TEST_CLIENT_CERT_BASE64
101
106
TEST_OIDC_TOKEN = "Bearer %s" % TEST_OIDC_LOGIN
102
107
TEST_OIDC_EXP = "{\" name\" : \" test\" ,\" exp\" : 536457600}"
103
- TEST_OIDC_EXP_BASE = _base64 (TEST_OIDC_TOKEN ) + "." + _base64 (TEST_OIDC_EXP )
108
+ TEST_OIDC_EXP_BASE = _unpadded_base64 (
109
+ TEST_OIDC_TOKEN ) + "." + _unpadded_base64 (TEST_OIDC_EXP )
104
110
TEST_OIDC_EXPIRED_LOGIN = TEST_OIDC_EXP_BASE + "." + TEST_CLIENT_CERT_BASE64
105
111
TEST_OIDC_CA = _base64 (TEST_CERTIFICATE_AUTH )
106
112
You can’t perform that action at this time.
0 commit comments