-
Notifications
You must be signed in to change notification settings - Fork 304
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
fix: RequestValidator thread-safety #598
Conversation
Relates to #466 Turns out this may just be for correctness, as these algos may not hold onto any unmanaged resources. dotnet/aspnetcore#32871
Disclaimer: I don't have any of the older target frameworks installed and don't really want to go and install them. I'm hoping CI will tell me if the test passes, but I wasn't even able to target net6.0 and run it, as the build kept complaining about multiple entry points. If someone with all the right frameworks installed can validate the test reproduced the issue, that'd be good. |
I'm trying to make the validator more efficient and stumbled on the related issue and your PR. PS: To avoid confusion, I work for Twilio but not on this library, so I am contributing this code from my personal free time too. |
Quick question, would the validator still be thread safe if it implements |
Hey @Swimburger , thanks for pushing this along. Happy for you to merge this into your own PR (or re-make the commits on yours if that's easier, as long as you can add me via a co-author commit footer). Re: singleton + disposable, if the validator itself instantiates instances of the algos and holds on to them, it wouldn't be thread-safe as multiple threads could use the same instance at once and hit the issue we all hit. With my current PR here, singleton would be fine, and no need for disposable as the algo instances are new'd up and disposed of every time validation is attempted. The alternative was to The most performant solution would be a combination of my current solution here + some Hope that helps. |
Thank you for the clarification! |
Superseded by #660 |
Fixes #466
Fixes
Makes
RequestValidator
thread-safe by not holding on to instances of the crypto algos used and instead new'ing them up and disposing of them per validation.Checklist
If you have questions, please file a support ticket, or create a GitHub Issue in this repository.