Sha256: 56011a523c476daa3011382a06f987c17e1960ee525b17c8b90480bb3d8f1ce5

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module Goma
  class << self
    attr_accessor :encryptor, :token_generator

    # Constant time comparison to prevent timing attacks
    # {https://github.com/plataformatec/devise/blob/master/lib/devise.rb#L483}
    def secure_compare(a, b)
     return false if a.blank? || b.blank? || a.bytesize != b.bytesize
     l = a.unpack "C#{a.bytesize}"

     res = 0
     b.each_byte { |byte| res |= byte ^ l.shift }
     res == 0
    end


    # @param [Symbol] scope
    # @return [Class] Class for the scope
    def incarnate(scope)
     @models ||= {}
     @models[scope] ||= scope.to_s.classify.constantize
    end
  end
  MODULES = [:validatable, :password_authenticatable, :lockable, :confirmable, :recoverable, :rememberable, :timeoutable, :trackable, :omniauthable]
  CONTROLLER_MODULES = [:password_authenticatable, :confirmable, :rememberable, :trackable, :timeoutable]

  InvalidIdOrPassword = Class.new(StandardError)
  NotActivated        = Class.new(StandardError)
  TokenExpired        = Class.new(StandardError)
end

require 'rails'

require 'goma/config'
require 'goma/token_generator'
require 'goma/controller_test_helpers' if Rails.env == 'test'

require 'goma/railtie'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
goma-0.0.1.rc3 lib/goma.rb