Sha256: 5fc7c62c8ca685aa75e0ec14d6bd5226983f6e2c719b84caf6e9df8e443de961

Contents?: true

Size: 723 Bytes

Versions: 11

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true

module IronBank
  # Get a valid token or session HTTP request header for IronBank
  #
  class Authentication
    extend Forwardable

    attr_reader :session

    def_delegators :session, :header, :expired?

    def initialize(params)
      @auth_type = params.delete(:auth_type)
      @params    = params
      create_session
    end

    def create_session
      @session = adapter.new(params)
    end
    alias renew_session create_session

    private

    attr_reader :auth_type, :params

    def adapter
      @adapter ||=
        if auth_type == 'cookie'
          IronBank::Authentications::Cookie
        else
          IronBank::Authentications::Token
        end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
iron_bank-2.2.0 lib/iron_bank/authentication.rb
iron_bank-2.1.0 lib/iron_bank/authentication.rb
iron_bank-2.0.2 lib/iron_bank/authentication.rb
iron_bank-2.0.1 lib/iron_bank/authentication.rb
iron_bank-2.0.0 lib/iron_bank/authentication.rb
iron_bank-1.0.4 lib/iron_bank/authentication.rb
iron_bank-1.0.3 lib/iron_bank/authentication.rb
iron_bank-1.0.2 lib/iron_bank/authentication.rb
iron_bank-1.0.1 lib/iron_bank/authentication.rb
iron_bank-1.0.0 lib/iron_bank/authentication.rb
iron_bank-0.7.1 lib/iron_bank/authentication.rb