Skip to content

Commit

Permalink
fix: DPoP ath
Browse files Browse the repository at this point in the history
  • Loading branch information
peppelinux committed Aug 25, 2023
1 parent 64f5fb6 commit cc2aaf1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pyeudiw/oauth2/dpop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def proof(self):
"htm": "GET",
"htu": self.htu,
"iat": iat_now(),
"ath": base64.urlsafe_b64encode(hashlib.sha256(self.token.encode()).digest()).decode()
"ath": base64.urlsafe_b64encode(hashlib.sha256(self.token.encode()).digest()).rstrip(b'=').decode()
}
jwt = self.signer.sign(
data,
Expand Down Expand Up @@ -109,6 +109,6 @@ def validate(self) -> bool:
DPoPTokenPayloadSchema(**payload)

_ath = hashlib.sha256(self.dpop_token.encode())
_ath_b64 = base64.urlsafe_b64encode(_ath.digest()).decode()
_ath_b64 = base64.urlsafe_b64encode(_ath.digest()).rstrip(b'=').decode()
proof_valid = _ath_b64 == payload['ath']
return dpop_valid and proof_valid
2 changes: 1 addition & 1 deletion pyeudiw/tests/oauth2/test_dpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_create_validate_dpop_http_headers(wia_jws, private_jwk=PRIVATE_JWK):
payload = unpad_jwt_payload(proof)
assert payload["ath"] == base64.urlsafe_b64encode(
hashlib.sha256(wia_jws.encode()
).digest()).decode()
).digest()).rstrip(b'=').decode()
assert payload["htm"] in ["GET", "POST", "get", "post"]
assert payload["htu"] == "https://example.org/redirect"
assert payload["jti"]
Expand Down

0 comments on commit cc2aaf1

Please sign in to comment.