Sha256: d096ff58d9b26113e8d2df49bb568611c449edeeec3f885dfcdba45872945843

Contents?: true

Size: 620 Bytes

Versions: 7

Compression:

Stored size: 620 Bytes

Contents

module Challah
  class ApiKeyTechnique
    def initialize(session)
      @key = session.key? ? session.key : nil   
    end
    
    def authenticate
      # Api key functionality is only enabled with the :api_key_enabled option. This is turned
      # off by default and must be manually enabled for security reasons.
      return nil unless Challah.options[:api_key_enabled]
      
      unless @key.to_s.blank?
        user = ::User.find_by_api_key(@key)
        
        if user and user.active?
          return user
        end
      end
      
      nil
    end
    
    def persist?
      false
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
challah-0.5.4 lib/challah/techniques/api_key_technique.rb
challah-0.5.3 lib/challah/techniques/api_key_technique.rb
challah-0.5.2 lib/challah/techniques/api_key_technique.rb
challah-0.5.1 lib/challah/techniques/api_key_technique.rb
challah-0.5.0 lib/challah/techniques/api_key_technique.rb
challah-0.4.1 lib/challah/techniques/api_key_technique.rb
challah-0.4.0 lib/challah/techniques/api_key_technique.rb