Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SignedJwt.unprotect() method to remove a JWT signature. #26

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions jwskate/jwt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,18 @@ def unprotected(
cls,
claims: Mapping[str, Any],
*,
alg: str = "none",
typ: str | None = "JWT",
extra_headers: Mapping[str, Any] | None = None,
) -> SignedJwt:
"""Generate a JWT that is not signed and not encrypted (with alg=none).
"""Generate a JWT that is not signed and not encrypted.

Those unprotected Jwt should contain a `alg` header with value `"none"`, but you can change that value
by passing an `alg` parameter if you know what you are doing.

Args:
claims: the claims to set in the token.
alg: the `alg` value to set as header.
typ: typ (token type) header to include. If `None`, do not include this header.
extra_headers: additional headers to insert in the token.

Expand All @@ -149,7 +154,7 @@ def unprotected(
"""
from .signed import SignedJwt

headers = dict(extra_headers or {}, alg="none")
headers = dict(extra_headers or {}, alg=alg)
if typ:
headers["typ"] = typ

Expand Down
Loading
Loading