Add support for ruby-jwt v2.6.0 and above, bump development deps, new Ruby vers #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior versions of this code depended on the method
JWT::SecurityUtils.secure_compare
Release v2.6.0 of ruby-jwt moved the
JWT::SecurityUtils.secure_compare
method to a different namespace as part of jwt/ruby-jwt#521While we could simply change this code to instead refer to that new namespace, I believe that the intention of ruby-jwt was that
secure_compare
should not have been used outside of the internals of ruby-jwt.This is supported by the The ruby-jwt README examples where the ruby-jwt team recommend using
OpenSSL.fixed_length_secure_compare
instead ofJWT::SecurityUtils.secure_compare
The code in this change is based on the logic in
https://github.com/rails/rails/blob/cf6ff17e9a3c6c1139040b519a341f55f0be16cf/activesupport/lib/active_support/security_utils.rb#L33 so as to avoid adding a dependency on ActiveSupport for this single method.
Unlike the code in the activesupport url above we don't fall back to a custom implementation of
fixed_length_secure_compare
, sinceOpenSSL.fixed_length_secure_compare
is present in OpenSSL 2.2 and this gem already depends on Ruby 3.0 and above, which already includes that version of OpenSSLThis code also doesn't need to handle nil/empty cases, unlike the original implementation of JWT::SecurityUtils.secure_compare because these are already handled in the call to
validate_url
in one case, andvalidate_payload
itself in the other.