Skip to content

Commit ba3ecc9

Browse files
committed
oidc-exchange: fix padding
Signed-off-by: William Woodruff <william@trailofbits.com>
1 parent ade57f5 commit ba3ecc9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

oidc-exchange.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ def assert_successful_audience_call(resp: requests.Response, domain: str):
144144

145145
def render_claims(token: str) -> str:
146146
_, payload, _ = token.split(".", 2)
147+
148+
# urlsafe_b64decode needs padding; JWT payloads don't contain any.
149+
payload += "=" * (4 - (len(payload) % 4))
147150
claims = json.loads(base64.urlsafe_b64decode(payload))
148151

149152
def _get(name: str) -> str: # noqa: WPS430
@@ -207,7 +210,8 @@ def _get(name: str) -> str: # noqa: WPS430
207210

208211
die(
209212
_SERVER_REFUSED_TOKEN_EXCHANGE_MESSAGE.format(
210-
reasons=reasons, rendered_claims=rendered_claims,
213+
reasons=reasons,
214+
rendered_claims=rendered_claims,
211215
),
212216
)
213217

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy