Sha256: 49aefcdd84b8d1fd2cdcb582035d3c772da63a2fb103c0b376fc2e947b7ac06f
Contents?: true
Size: 587 Bytes
Versions: 8
Compression:
Stored size: 587 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 = "Bearer #{sanitized}" end def call(env) env[:request_headers][KEY] ||= @header_value @app.call(env) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems