Skip to content

Commit

Permalink
Merge pull request #985 from faker-/MODULES-1622-allow-multiple-deny-…
Browse files Browse the repository at this point in the history
…directives

MODULES-1622: Allow multiple Deny directives in a directory
  • Loading branch information
Morgan Haskel committed Feb 18, 2015
2 parents ae0301d + c89bb3e commit 19802cb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ Pass a string of custom configuration directives to be placed at the end of the

######`deny`

Sets a [Deny](http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#deny) directive, specifying which hosts are denied access to the server. **Deprecated:** This parameter is being deprecated due to a change in Apache. It only works with Apache 2.2 and lower.
Sets a [Deny](http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#deny) directive, specifying which hosts are denied access to the server. **Deprecated:** This parameter is being deprecated due to a change in Apache. It only works with Apache 2.2 and lower. You can use it as a single string for one rule or as an array for more than one.

```puppet
apache::vhost { 'sample.example.net':
Expand Down
28 changes: 27 additions & 1 deletion spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
'directories' => {
'path' => '/var/www/files',
'provider' => 'files',
'deny' => 'from all'
},
'error_log' => false,
'error_log_file' => 'httpd_error_log',
Expand Down Expand Up @@ -349,6 +348,21 @@
'manage_docroot' => true,
'logroot' => '/tmp/logroot',
'logroot_ensure' => 'absent',
'directories' => [
{
'path' => '/var/www/files',
'provider' => 'files',
'allow' => [ 'from 127.0.0.1', 'from 127.0.0.2', ],
'deny' => [ 'from 127.0.0.3', 'from 127.0.0.4', ],
},
{
'path' => '/var/www/foo',
'provider' => 'files',
'allow' => 'from 127.0.0.5',
'deny' => 'from all',
},
],

}
end
let :facts do
Expand Down Expand Up @@ -393,6 +407,18 @@
it { is_expected.to_not contain_concat__fragment('rspec.example.com-itk') }
it { is_expected.to_not contain_concat__fragment('rspec.example.com-fallbackresource') }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories') }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Allow from 127\.0\.0\.1$/ ) }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Allow from 127\.0\.0\.2$/ ) }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Allow from 127\.0\.0\.5$/ ) }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Deny from 127\.0\.0\.3$/ ) }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Deny from 127\.0\.0\.4$/ ) }
it { is_expected.to contain_concat__fragment('rspec.example.com-directories').with(
:content => /^\s+Deny from all$/ ) }
it { is_expected.to_not contain_concat__fragment('rspec.example.com-additional_includes') }
it { is_expected.to contain_concat__fragment('rspec.example.com-logging') }
it { is_expected.to contain_concat__fragment('rspec.example.com-serversignature') }
Expand Down
8 changes: 7 additions & 1 deletion templates/vhost/_directories.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@
<%- else -%>
Order allow,deny
<%- end -%>
<%- if directory['deny'] and directory['deny'] != '' -%>
<%- if directory['deny'] and ! [ false, 'false', '' ].include?(directory['deny']) -%>
<%- if directory['deny'].kind_of?(Array) -%>
<%- Array(directory['deny']).each do |restrict| -%>
Deny <%= restrict %>
<%- end -%>
<%- else -%>
Deny <%= directory['deny'] %>
<%- end -%>
<%- end -%>
<%- if directory['allow'] and ! [ false, 'false', '' ].include?(directory['allow']) -%>
<%- if directory['allow'].kind_of?(Array) -%>
Expand Down

0 comments on commit 19802cb

Please sign in to comment.