Sha256: 0aff88a44575d0b73757d5399074769a1e6cac60b23a6197422ccfc79ca7112f

Contents?: true

Size: 628 Bytes

Versions: 9

Compression:

Stored size: 628 Bytes

Contents

require 'devise'

module SimpleTokenAuthentication
  class TokenComparator

    # Compare two String instances
    #
    # Important: this method is cryptographically critical and
    # must be implemented with care when defining new token comparators.
    #
    # Returns true if String instances do match, false otherwise
    def compare(a, b)
      # Notice how we use Devise.secure_compare to compare tokens
      # while mitigating timing attacks.
      # See http://rubydoc.info/github/plataformatec/\
      #            devise/master/Devise#secure_compare-class_method
      Devise.secure_compare(a, b)
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
simple_token_authentication-1.12.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.11.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.10.1 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.10.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.9.1 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.9.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.8.0 lib/simple_token_authentication/token_comparator.rb
stn-simple_token_authentication-1.7.1 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.7.0 lib/simple_token_authentication/token_comparator.rb