Sha256: ba1ed76ce9c978ae810d663a13a9d171b74a015050d29edc7be1a5ba74153aac
Contents?: true
Size: 586 Bytes
Versions: 11
Compression:
Stored size: 586 Bytes
Contents
# frozen_string_literal: true module FinAppsCore module Middleware # Adds a custom header for basic authorization. # If the value for this header already exists, it is not overriden. class NoEncodingBasicAuthentication < Faraday::Middleware KEY = 'Authorization' unless defined? KEY def initialize(app, token) super(app) sanitized = token.to_s.strip.delete("\n") @header_value = "Basic #{sanitized}" end def call(env) env[:request_headers][KEY] ||= @header_value @app.call(env) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems