Sha256: 8f802b5d8516c32b0f03835d29a49092a0e2812442a889684fceec9da426f66e

Contents?: true

Size: 725 Bytes

Versions: 12

Compression:

Stored size: 725 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

12 entries across 12 versions & 1 rubygems

Version Path
iron_bank-5.4.1 lib/iron_bank/authentication.rb
iron_bank-5.4.0 lib/iron_bank/authentication.rb
iron_bank-5.3.2 lib/iron_bank/authentication.rb
iron_bank-5.3.0 lib/iron_bank/authentication.rb
iron_bank-5.2.6 lib/iron_bank/authentication.rb
iron_bank-5.2.4 lib/iron_bank/authentication.rb
iron_bank-5.2.3 lib/iron_bank/authentication.rb
iron_bank-5.2.0 lib/iron_bank/authentication.rb
iron_bank-5.1.1 lib/iron_bank/authentication.rb
iron_bank-5.1.0 lib/iron_bank/authentication.rb
iron_bank-5.0.1 lib/iron_bank/authentication.rb
iron_bank-5.0.0 lib/iron_bank/authentication.rb