Sha256: 3cefaa64327c5bcc4d763ffcba6c14848b309e552a047feb244664b1c84c18f0
Contents?: true
Size: 588 Bytes
Versions: 32
Compression:
Stored size: 588 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
32 entries across 32 versions & 1 rubygems