Sha256: b14f0e5da5645d8bc54eaad9da77cf306c0cc91147c71acc6a7afcd8bc5dcc82

Contents?: true

Size: 650 Bytes

Versions: 8

Compression:

Stored size: 650 Bytes

Contents

require 'devise'

module SimpleTokenAuthentication
  class TokenComparator
    include Singleton

    # 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

8 entries across 8 versions & 1 rubygems

Version Path
simple_token_authentication-1.18.1 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.18.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.17.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.16.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.15.1 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.15.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.14.0 lib/simple_token_authentication/token_comparator.rb
simple_token_authentication-1.13.0 lib/simple_token_authentication/token_comparator.rb