File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -257,13 +257,15 @@ def _load_oid_token(self, provider):
257
257
if len (parts ) != 3 : # Not a valid JWT
258
258
return None
259
259
260
+ padding = (4 - len (parts [1 ]) % 4 ) * '='
261
+
260
262
if PY3 :
261
263
jwt_attributes = json .loads (
262
- base64 .b64decode (parts [1 ]).decode ('utf-8' )
264
+ base64 .b64decode (parts [1 ] + padding ).decode ('utf-8' )
263
265
)
264
266
else :
265
267
jwt_attributes = json .loads (
266
- base64 .b64decode (parts [1 ] + "==" )
268
+ base64 .b64decode (parts [1 ] + padding )
267
269
)
268
270
269
271
expire = jwt_attributes .get ('exp' )
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ def _base64(string):
43
43
return base64 .encodestring (string .encode ()).decode ()
44
44
45
45
46
+ def _unpadded_base64 (string ):
47
+ return base64 .b64encode (string .encode ()).decode ().rstrip ('=' )
48
+
49
+
46
50
def _format_expiry_datetime (dt ):
47
51
return dt .strftime (EXPIRY_DATETIME_FORMAT )
48
52
@@ -87,11 +91,13 @@ def _raise_exception(st):
87
91
88
92
TEST_OIDC_TOKEN = "test-oidc-token"
89
93
TEST_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 )
91
96
TEST_OIDC_LOGIN = TEST_OIDC_BASE + "." + TEST_CLIENT_CERT_BASE64
92
97
TEST_OIDC_TOKEN = "Bearer %s" % TEST_OIDC_LOGIN
93
98
TEST_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 )
95
101
TEST_OIDC_EXPIRED_LOGIN = TEST_OIDC_EXP_BASE + "." + TEST_CLIENT_CERT_BASE64
96
102
TEST_OIDC_CA = _base64 (TEST_CERTIFICATE_AUTH )
97
103
You can’t perform that action at this time.
0 commit comments