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 @@ -264,13 +264,15 @@ def _load_oid_token(self, provider):
264
264
if len (parts ) != 3 : # Not a valid JWT
265
265
return None
266
266
267
+ padding = (4 - len (parts [1 ]) % 4 ) * '='
268
+
267
269
if PY3 :
268
270
jwt_attributes = json .loads (
269
- base64 .b64decode (parts [1 ]).decode ('utf-8' )
271
+ base64 .b64decode (parts [1 ] + padding ).decode ('utf-8' )
270
272
)
271
273
else :
272
274
jwt_attributes = json .loads (
273
- base64 .b64decode (parts [1 ] + "==" )
275
+ base64 .b64decode (parts [1 ] + padding )
274
276
)
275
277
276
278
expire = jwt_attributes .get ('exp' )
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ def _base64(string):
47
47
return base64 .standard_b64encode (string .encode ()).decode ()
48
48
49
49
50
+ def _unpadded_base64 (string ):
51
+ return base64 .b64encode (string .encode ()).decode ().rstrip ('=' )
52
+
53
+
50
54
def _format_expiry_datetime (dt ):
51
55
return dt .strftime (EXPIRY_DATETIME_FORMAT )
52
56
@@ -94,11 +98,13 @@ def _raise_exception(st):
94
98
95
99
TEST_OIDC_TOKEN = "test-oidc-token"
96
100
TEST_OIDC_INFO = "{\" name\" : \" test\" }"
97
- TEST_OIDC_BASE = _base64 (TEST_OIDC_TOKEN ) + "." + _base64 (TEST_OIDC_INFO )
101
+ TEST_OIDC_BASE = _unpadded_base64 (
102
+ TEST_OIDC_TOKEN ) + "." + _unpadded_base64 (TEST_OIDC_INFO )
98
103
TEST_OIDC_LOGIN = TEST_OIDC_BASE + "." + TEST_CLIENT_CERT_BASE64
99
104
TEST_OIDC_TOKEN = "Bearer %s" % TEST_OIDC_LOGIN
100
105
TEST_OIDC_EXP = "{\" name\" : \" test\" ,\" exp\" : 536457600}"
101
- TEST_OIDC_EXP_BASE = _base64 (TEST_OIDC_TOKEN ) + "." + _base64 (TEST_OIDC_EXP )
106
+ TEST_OIDC_EXP_BASE = _unpadded_base64 (
107
+ TEST_OIDC_TOKEN ) + "." + _unpadded_base64 (TEST_OIDC_EXP )
102
108
TEST_OIDC_EXPIRED_LOGIN = TEST_OIDC_EXP_BASE + "." + TEST_CLIENT_CERT_BASE64
103
109
TEST_OIDC_CA = _base64 (TEST_CERTIFICATE_AUTH )
104
110
You can’t perform that action at this time.
0 commit comments