mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
fix(references): update reference to Rswag::Ui::BasicAuth and env_matching_path environment accessor
This commit is contained in:
parent
a43e6f6546
commit
e21f786926
@ -9,23 +9,20 @@ module Rswag
|
|||||||
#
|
#
|
||||||
class BasicAuth < ::Rack::Auth::Basic
|
class BasicAuth < ::Rack::Auth::Basic
|
||||||
def call(env)
|
def call(env)
|
||||||
return @app.call(env) unless env_matching_path
|
return @app.call(env) unless env_matching_path(env)
|
||||||
|
|
||||||
super(env)
|
super(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def env_matching_path
|
def env_matching_path(env)
|
||||||
Rswag::Ui.config.swagger_endpoints[:urls].find do |endpoint|
|
path = base_path(env['PATH_INFO'])
|
||||||
base_path(endpoint[:url]) == env_base_path
|
Rswag::Ui.config.config_object[:urls].find do |endpoint|
|
||||||
|
base_path(endpoint[:url]) == path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def env_base_path
|
|
||||||
base_path(env['PATH_INFO'])
|
|
||||||
end
|
|
||||||
|
|
||||||
def base_path(url)
|
def base_path(url)
|
||||||
url.downcase.split('/')[1]
|
url.downcase.split('/')[1]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -11,7 +11,7 @@ module Rswag
|
|||||||
|
|
||||||
if Rswag::Ui.config.basic_auth_enabled
|
if Rswag::Ui.config.basic_auth_enabled
|
||||||
c = Rswag::Ui.config
|
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]
|
c.config_object[:basic_auth].values == [username, password]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user