-
Notifications
You must be signed in to change notification settings - Fork 383
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
Update JsonWebToken to enable extensibility and use underlying byte stream #2535
base: dev
Are you sure you want to change the base?
Conversation
…claims as UTF8 ReadOnlyMemory<byte>.
…value indices instead of creating Memor<byte> for each claim.
{ | ||
ArrayPool<byte>.Shared.Return(output, true); | ||
} | ||
byte[] output = new byte[outputSize]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to still pool this buffer? Maybe by making JsonClaimSet
disposable (or some new type that wraps a JsonClaimSet
and a buffer), and it returns the buffer back to the pool once it has been disposed of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just simple change to make POC work. Yep, sounds like that could work.
@@ -24,15 +25,31 @@ internal class JsonClaimSet | |||
|
|||
internal object _claimsLock = new(); | |||
internal readonly Dictionary<string, object> _jsonClaims; | |||
internal readonly Dictionary<string, (int startIndex, int length)> _jsonClaimsUtf8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this / should this be in the ifdef too?
If so, could this use Range instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, all of this new UTF8 related code is only for .NET7+ so I'll refactor inside ifdef. Good idea, I'll see if Range works. Yea, the not ideal thing about this approach is that keeping track of indices is a bit less straightforward than just an object instance...
Fixes #2583.
Changes: