Sha256: 55afba8b50e2599c96267ca01b96e4311d3ee898e0cd9e5fe3cb49e46973ff62

Contents?: true

Size: 634 Bytes

Versions: 21

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

require 'rack/auth/basic'

module Rswag
  module Ui
    # Extend Rack HTTP Basic Authentication, as per RFC 2617.
    # @api private
    #
    class BasicAuth < ::Rack::Auth::Basic
      def call(env)
        return @app.call(env) unless env_matching_path(env)

        super(env)
      end

      private

      def env_matching_path(env)
        path = base_path(env['PATH_INFO'])
        Rswag::Ui.config.config_object[:urls].find do |endpoint|
          base_path(endpoint[:url]) == path
        end
      end

      def base_path(url)
        url.downcase.split('/')[1]
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rswag-ui-2.16.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.15.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.14.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.13.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.12.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.11.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.10.1 lib/rswag/ui/basic_auth.rb
rswag-ui-2.10.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.9.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.8.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.7.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.6.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.5.1 lib/rswag/ui/basic_auth.rb
rswag-ui-2.5.1.rc1 lib/rswag/ui/basic_auth.rb
rswag-ui-2.5.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.5.0.rc1 lib/rswag/ui/basic_auth.rb
rswag-ui-2.4.0 lib/rswag/ui/basic_auth.rb
rswag-ui-2.3.3 lib/rswag/ui/basic_auth.rb
rswag-ui-2.3.2 lib/rswag/ui/basic_auth.rb
rswag-ui-2.3.1 lib/rswag/ui/basic_auth.rb