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

[Feature Request] Replace JsonWebToken ReadPayloadValue with a delegate #2982

Open
pmaytak opened this issue Nov 6, 2024 · 0 comments
Open
Assignees
Labels
Enhancement The issue is a new feature

Comments

@pmaytak
Copy link
Contributor

pmaytak commented Nov 6, 2024

Is your feature request related to a problem? Please describe.
JsonWebToken has a virtual ReadPayloadValue which is called when parsing a string token into the claims collection. A user can create a derived class from JsonWebToken and override this method to provide custom logic in reading a claim from the reader. The signature has a parameter IDictionary<string, object> claims which exposes the internal claims collection which is not ideal because this doesn't allow us to change it in the future, if we desire.

private protected virtual void ReadPayloadValue(ref Utf8JsonReader reader, IDictionary<string, object> claims)

Describe the solution you'd like
Replace the virtual method with delegate which will be called when reading the claim value. The delegate can be added to the TokenValidationParameters and is maybe easier to set than creating a custom token type.
public delegate object ReadTokenPayloadValueDelegate(ref Utf8JsonReader reader, string claimName);

Need to run perf benchmarks.

Describe alternatives you've considered
Change the virtual method signature:
private protected virtual void ReadPayloadValue(ref Utf8JsonReader reader, string claimName)

@pmaytak pmaytak added the Enhancement The issue is a new feature label Nov 6, 2024
@pmaytak pmaytak added this to the 8.2.1 milestone Nov 6, 2024
@pmaytak pmaytak self-assigned this Nov 6, 2024
@pmaytak pmaytak removed this from the 8.2.1 milestone Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement The issue is a new feature
Projects
None yet
Development

No branches or pull requests

1 participant