Closed rrrodzilla closed 1 month ago
This pull request closes #39 , which reported an invalid JSON payload when using CustomClaims
with types that serialize to JSON objects. The issue caused the builder to generate an invalid JSON payload due to improper handling of multiple object delimiters, resulting in successful token creation but failed validation with a JSON error.
Updated the build_payload_from_claims
function:
Added utility functions:
wrap_claims
: Recursively wraps each claim value to ensure all values are valid JSON objects.wrap_value
: Ensures proper nesting of JSON values, handling various edge cases including empty objects, arrays, and null values.Included comprehensive tests:
wrap_value
and build_payload_from_claims
functions, validating correctness and robustness.The updates ensure that the CustomClaims
builder generates valid JSON payloads, resolving the reported issue. The added tests demonstrate that the solution is robust and reliable for various practical use cases, contributing to the overall stability and reliability of the system.
Credit and thanks to @xbb for reporting the issue by opening issue #39 and for taking the time to offer a solution.
IMPORTANT: Please do not create a Pull Request without creating an issue first.
Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.
Please provide enough information so that others can review your pull request:
Explain the details for making this change. What existing problem does the pull request solve?
Test plan (required)
Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
Code formatting
Closing issues
Put
closes #XXXX
in your comment to auto-close the issue that your PR fixes (if such).