Sha256: 19bce25460f08bd8faa1e903999aebf537618203c414f2ffd902941e4ed52050

Contents?: true

Size: 646 Bytes

Versions: 23

Compression:

Stored size: 646 Bytes

Contents

module Challah
  # Allows authentication with an api_key URL parameter.
  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

23 entries across 22 versions & 2 rubygems

Version Path
challah-1.0.0 lib/challah/techniques/api_key_technique.rb
challah-1.0.0.beta3 lib/challah/techniques/api_key_technique.rb
challah-1.0.0.beta2 lib/challah/techniques/api_key_technique.rb
challah-1.0.0.beta lib/challah/techniques/api_key_technique.rb
challah-0.9.1.beta.3 lib/challah/techniques/api_key_technique.rb
challah-0.9.1.beta.2 lib/challah/techniques/api_key_technique.rb
challah-0.9.1.beta lib/challah/techniques/api_key_technique.rb
challah-0.9.0 lib/challah/techniques/api_key_technique.rb
challah-0.9.0.pre lib/challah/techniques/api_key_technique.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/lib/challah/techniques/api_key_technique.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/lib/challah/techniques/api_key_technique.rb
challah-0.8.3 lib/challah/techniques/api_key_technique.rb
challah-0.8.2 lib/challah/techniques/api_key_technique.rb
challah-0.8.1 lib/challah/techniques/api_key_technique.rb
challah-0.8.0 lib/challah/techniques/api_key_technique.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/lib/challah/techniques/api_key_technique.rb
challah-0.8.0.pre lib/challah/techniques/api_key_technique.rb
challah-0.7.1 lib/challah/techniques/api_key_technique.rb
challah-0.7.0 lib/challah/techniques/api_key_technique.rb
challah-0.7.0.pre lib/challah/techniques/api_key_technique.rb