-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: dpop tests, jwt has its own folder
- Loading branch information
1 parent
24d62b3
commit d167f46
Showing
8 changed files
with
119 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import base64 | ||
import json | ||
|
||
|
||
def unpad_jwt_element(jwt: str, position: int) -> dict: | ||
b = jwt.split(".")[position] | ||
padded = f"{b}{'=' * divmod(len(b), 4)[1]}" | ||
data = json.loads(base64.urlsafe_b64decode(padded)) | ||
return data | ||
|
||
|
||
def unpad_jwt_header(jwt: str) -> dict: | ||
return unpad_jwt_element(jwt, position=0) | ||
|
||
|
||
def unpad_jwt_payload(jwt: str) -> dict: | ||
return unpad_jwt_element(jwt, position=1) | ||
|
||
|
||
def get_jwk_from_jwt(jwt: str, provider_jwks: dict) -> dict: | ||
""" | ||
docs here | ||
""" | ||
head = unpad_jwt_header(jwt) | ||
kid = head["kid"] | ||
if isinstance(provider_jwks, dict) and provider_jwks.get('keys'): | ||
provider_jwks = provider_jwks['keys'] | ||
for jwk in provider_jwks: | ||
if jwk["kid"] == kid: | ||
return jwk | ||
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters