Sha256: 626aa3d1bd06a8ca794e66effb9a5f29f4b4de3d95922ff59b5b6fe210b426a1

Contents?: true

Size: 817 Bytes

Versions: 1

Compression:

Stored size: 817 Bytes

Contents

module Roqua
  module CoreApi
    module Sessions
      class BasicAuthSession < AuthSession
        attr_reader :username
        attr_reader :password

        def initialize(username: ENV.fetch('CORE_BASICAUTH_ID'),
                       password: ENV.fetch('CORE_BASICAUTH_SECRET'),
                       **additional_arguments)
          @username = username
          @password = password
          super(**additional_arguments)
        end

        private

        # handle 401 response.
        def access_denied(response)
          if response.headers['WWW-Authenticate']
            fail 'basic auth for core invalid'
          else
            fail Unauthorized
          end
        end

        def basic_auth
          {username: username, password: password}
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roqua-core-api-0.7.0 lib/roqua/core_api/sessions/basic_auth_session.rb