We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello, I have noticed that when passing a claim that has a boolean false as value, the validation fails with Invalid claim error, e.g.:
registry = jwt.JWTClaimsRegistry(bool_claim={"essential": True}) registry.validate({"bool_claim": False})
Traceback (most recent call last): File "/home/schemer/test/test/main.py", line 23, in <module> registry.validate({"bool_claim": False}) File "/home/schemer/test/.venv/lib/python3.12/site-packages/joserfc/rfc7519/registry.py", line 52, in validate self.check_value(key, value) File "/home/schemer/test/.venv/lib/python3.12/site-packages/joserfc/rfc7519/registry.py", line 31, in check_value raise InvalidClaimError(claim_name) joserfc.errors.InvalidClaimError: invalid_claim: Invalid claim: "bool_claim"
But the same registry validates correctly when the claim has a boolean true:
registry = jwt.JWTClaimsRegistry(bool_claim={"essential": True}) registry.validate({"bool_claim": True})
I went through the code, and found that the issue is getting raised here:
joserfc/src/joserfc/rfc7519/registry.py
Line 30 in 18ae2e2
Passing the "allow_blank" option does fix this, but I don't want to have a blank claim and I want to always ensure that it has a value.
The text was updated successfully, but these errors were encountered:
The exception is raised on all falsy values of a claim without the "allow_blank" option. So if I were for example to pass this claim:
registry.validate({"int_claim": 0})
i will still get an exception, even though it isn't null nor is it empty.
Traceback (most recent call last): File "/home/schemer/test/test/main.py", line 28, in <module> registry.validate({"int_claim": 0}) File "/home/schemer/test/.venv/lib/python3.12/site-packages/joserfc/rfc7519/registry.py", line 52, in validate self.check_value(key, value) File "/home/schemer/test/.venv/lib/python3.12/site-packages/joserfc/rfc7519/registry.py", line 31, in check_value raise InvalidClaimError(claim_name) joserfc.errors.InvalidClaimError: invalid_claim: Invalid claim: "int_claim"
Is this behaviour intended?
Sorry, something went wrong.
fix(jwt): update claims validation logic, allow value to be False or 0
ab7d909
ref: #23
Released 0.12.0
No branches or pull requests
Hello, I have noticed that when passing a claim that has a boolean false as value, the validation fails with Invalid claim error, e.g.:
But the same registry validates correctly when the claim has a boolean true:
I went through the code, and found that the issue is getting raised here:
joserfc/src/joserfc/rfc7519/registry.py
Line 30 in 18ae2e2
Passing the "allow_blank" option does fix this, but I don't want to have a blank claim and I want to always ensure that it has a value.
The text was updated successfully, but these errors were encountered: