From e21f786926c5261893922001bf2c7c78369675a4 Mon Sep 17 00:00:00 2001 From: Chris Miller Date: Wed, 29 Jan 2020 16:28:06 -0800 Subject: [PATCH] fix(references): update reference to Rswag::Ui::BasicAuth and env_matching_path environment accessor --- rswag-ui/lib/rswag/ui/basic_auth.rb | 13 +++++-------- rswag-ui/lib/rswag/ui/engine.rb | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/rswag-ui/lib/rswag/ui/basic_auth.rb b/rswag-ui/lib/rswag/ui/basic_auth.rb index 7bbd85d..ee42d36 100644 --- a/rswag-ui/lib/rswag/ui/basic_auth.rb +++ b/rswag-ui/lib/rswag/ui/basic_auth.rb @@ -9,23 +9,20 @@ module Rswag # class BasicAuth < ::Rack::Auth::Basic def call(env) - return @app.call(env) unless env_matching_path + return @app.call(env) unless env_matching_path(env) super(env) end private - def env_matching_path - Rswag::Ui.config.swagger_endpoints[:urls].find do |endpoint| - base_path(endpoint[:url]) == env_base_path + 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 env_base_path - base_path(env['PATH_INFO']) - end - def base_path(url) url.downcase.split('/')[1] end diff --git a/rswag-ui/lib/rswag/ui/engine.rb b/rswag-ui/lib/rswag/ui/engine.rb index c4cffae..e90b4f2 100644 --- a/rswag-ui/lib/rswag/ui/engine.rb +++ b/rswag-ui/lib/rswag/ui/engine.rb @@ -11,7 +11,7 @@ module Rswag if Rswag::Ui.config.basic_auth_enabled c = Rswag::Ui.config - app.middleware.use UiBasicAuth do |username, password| + app.middleware.use Rswag::Ui::BasicAuth do |username, password| c.config_object[:basic_auth].values == [username, password] end end