location: move auth_basic directives to header
Allows setting these directives on any location: * auth_basic * auth_basic_user_file
This commit is contained in:
parent
c54359f5fe
commit
3027d9f35a
4 changed files with 18 additions and 30 deletions
|
@ -148,6 +148,18 @@ describe 'nginx::resource::location' do
|
|||
:value => [],
|
||||
:notmatch => /rewrite/
|
||||
},
|
||||
{
|
||||
:title => 'should set auth_basic',
|
||||
:attr => 'auth_basic',
|
||||
:value => 'value',
|
||||
:match => ' auth_basic "value";',
|
||||
},
|
||||
{
|
||||
:title => 'should set auth_basic_user_file',
|
||||
:attr => 'auth_basic_user_file',
|
||||
:value => 'value',
|
||||
:match => ' auth_basic_user_file value;',
|
||||
},
|
||||
].each do |param|
|
||||
context "when #{param[:attr]} is #{param[:value]}" do
|
||||
let :default_params do { :location => 'location', :proxy => 'proxy_value', :vhost => 'vhost1' } end
|
||||
|
@ -318,18 +330,6 @@ describe 'nginx::resource::location' do
|
|||
:value => ['name1','name2'],
|
||||
:match => ' index name1 name2;',
|
||||
},
|
||||
{
|
||||
:title => 'should set auth_basic',
|
||||
:attr => 'auth_basic',
|
||||
:value => 'value',
|
||||
:match => ' auth_basic "value";',
|
||||
},
|
||||
{
|
||||
:title => 'should set auth_basic_user_file',
|
||||
:attr => 'auth_basic_user_file',
|
||||
:value => 'value',
|
||||
:match => ' auth_basic_user_file value;',
|
||||
},
|
||||
].each do |param|
|
||||
context "when #{param[:attr]} is #{param[:value]}" do
|
||||
let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end
|
||||
|
|
|
@ -19,6 +19,12 @@
|
|||
deny <%= deny_rule %>;
|
||||
<%- end -%>
|
||||
<% end -%>
|
||||
<% if @auth_basic -%>
|
||||
auth_basic "<%= @auth_basic %>";
|
||||
<%- end %>
|
||||
<%- if @auth_basic_user_file -%>
|
||||
auth_basic_user_file <%= @auth_basic_user_file %>;
|
||||
<% end -%>
|
||||
<% if @location_custom_cfg_prepend -%>
|
||||
<%- @location_custom_cfg_prepend.each do |key,value| -%>
|
||||
<%- if value.is_a?(Hash) -%>
|
||||
|
|
|
@ -11,12 +11,3 @@
|
|||
<% if @try_files -%>
|
||||
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
|
||||
<% end -%>
|
||||
<% if instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
|
||||
|
||||
<%- if @auth_basic -%>
|
||||
auth_basic "<%= @auth_basic %>";
|
||||
<%- end -%>
|
||||
<%- if defined? @auth_basic_user_file -%>
|
||||
auth_basic_user_file <%= @auth_basic_user_file %>;
|
||||
<%- end -%>
|
||||
<% end -%>
|
|
@ -21,12 +21,3 @@
|
|||
<% if @proxy_cache_valid -%>
|
||||
proxy_cache_valid <%= @proxy_cache_valid %>;
|
||||
<% end -%>
|
||||
<% if instance_variables.any? { |iv| iv.to_s.include? 'auth_basic' } -%>
|
||||
|
||||
<%- if @auth_basic -%>
|
||||
auth_basic "<%= @auth_basic %>";
|
||||
<%- end -%>
|
||||
<%- if defined? @auth_basic_user_file -%>
|
||||
auth_basic_user_file <%= @auth_basic_user_file %>;
|
||||
<%- end -%>
|
||||
<% end -%>
|
||||
|
|
Loading…
Reference in a new issue