Skip to content

Commit 514ca05

Browse files
author
Ashley Penney
committed
Merge pull request #752 from Arakmar/satisfy
Add the Satisfy parameter to the directory fragment.
2 parents 3049676 + 2d58357 commit 514ca05

4 files changed

Lines changed: 105 additions & 0 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,20 @@ Sets the order of processing Allow and Deny statements as per [Apache core docum
14181418
}
14191419
```
14201420

1421+
######`satisfy`
1422+
1423+
Sets a `Satisfy` directive as per the [Apache Core documentation](http://httpd.apache.org/docs/2.2/mod/core.html#satisfy). **Deprecated:** This parameter is being deprecated due to a change in Apache. It will only work with Apache 2.2 and lower.
1424+
1425+
```puppet
1426+
apache::vhost { 'sample.example.net':
1427+
docroot => '/path/to/directory',
1428+
directories => [
1429+
{ path => '/path/to/directory',
1430+
satisfy => 'Any',
1431+
}
1432+
],
1433+
}
1434+
14211435
######`sethandler`
14221436
14231437
Sets a `SetHandler` directive as per the [Apache Core documentation](http://httpd.apache.org/docs/2.2/mod/core.html#sethandler). An example:

spec/acceptance/vhost_spec.rb

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,84 @@ class { 'apache': }
297297
expect(shell("/usr/bin/curl -sSf files.example.net:80/server-status?auto").stdout).to match(/Scoreboard: /)
298298
end
299299
end
300+
301+
describe 'Satisfy and Auth directive' do
302+
it 'should configure a vhost with Satisfy and Auth directive' do
303+
pp = <<-EOS
304+
class { 'apache': }
305+
host { 'files.example.net': ip => '127.0.0.1', }
306+
apache::vhost { 'files.example.net':
307+
docroot => '/var/www/files',
308+
directories => [
309+
{
310+
path => '/var/www/files/foo',
311+
auth_type => 'Basic',
312+
auth_name => 'Basic Auth',
313+
auth_user_file => '/var/www/htpasswd',
314+
auth_require => "valid-user",
315+
},
316+
{
317+
path => '/var/www/files/bar',
318+
auth_type => 'Basic',
319+
auth_name => 'Basic Auth',
320+
auth_user_file => '/var/www/htpasswd',
321+
auth_require => 'valid-user',
322+
satisfy => 'Any',
323+
},
324+
{
325+
path => '/var/www/files/baz',
326+
allow => 'from 10.10.10.10',
327+
auth_type => 'Basic',
328+
auth_name => 'Basic Auth',
329+
auth_user_file => '/var/www/htpasswd',
330+
auth_require => 'valid-user',
331+
satisfy => 'Any',
332+
},
333+
],
334+
}
335+
file { '/var/www/files/foo':
336+
ensure => directory,
337+
}
338+
file { '/var/www/files/bar':
339+
ensure => directory,
340+
}
341+
file { '/var/www/files/baz':
342+
ensure => directory,
343+
}
344+
file { '/var/www/files/foo/index.html':
345+
ensure => file,
346+
content => "Hello World\\n",
347+
}
348+
file { '/var/www/files/bar/index.html':
349+
ensure => file,
350+
content => "Hello World\\n",
351+
}
352+
file { '/var/www/files/baz/index.html':
353+
ensure => file,
354+
content => "Hello World\\n",
355+
}
356+
file { '/var/www/htpasswd':
357+
ensure => file,
358+
content => "login:IZ7jMcLSx0oQk", # "password" as password
359+
}
360+
EOS
361+
apply_manifest(pp, :catch_failures => true)
362+
end
363+
364+
describe service($service_name) do
365+
it { should be_enabled }
366+
it { should be_running }
367+
end
368+
369+
it 'should answer to files.example.net' do
370+
shell("/usr/bin/curl -sSf files.example.net:80/foo/index.html", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 401/)
371+
shell("/usr/bin/curl -sSf -u login:password files.example.net:80/foo/index.html").stdout.should eq("Hello World\n")
372+
shell("/usr/bin/curl -sSf files.example.net:80/bar/index.html").stdout.should eq("Hello World\n")
373+
shell("/usr/bin/curl -sSf -u login:password files.example.net:80/bar/index.html").stdout.should eq("Hello World\n")
374+
shell("/usr/bin/curl -sSf files.example.net:80/baz/index.html", {:acceptable_exit_codes => 22}).stderr.should match(/curl: \(22\) The requested URL returned error: 401/)
375+
shell("/usr/bin/curl -sSf -u login:password files.example.net:80/baz/index.html").stdout.should eq("Hello World\n")
376+
end
377+
end
300378
end
301379

302380
case fact('lsbdistcodename')

spec/defines/vhost_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,11 @@
717717
'order' => 'deny,yned',
718718
'passenger_enabled' => 'onf',
719719
'sethandler' => 'None',
720+
'auth_type' => 'Basic',
721+
'auth_name' => 'Basic Auth',
722+
'auth_user_file' => '/opt/app/htpasswd',
723+
'auth_require' => 'valid-user',
724+
'satisfy' => 'Any',
720725
},
721726
:match => [
722727
/^ <Directory "\/opt\/app">$/,
@@ -728,6 +733,11 @@
728733
/^ Order deny,yned$/,
729734
/^ SetHandler None$/,
730735
/^ PassengerEnabled onf$/,
736+
/^ AuthType Basic$/,
737+
/^ AuthName "Basic Auth"$/,
738+
/^ AuthUserFile \/opt\/app\/htpasswd$/,
739+
/^ Require valid-user$/,
740+
/^ Satisfy Any$/,
731741
/^ <\/Directory>$/,
732742
],
733743
},

templates/vhost/_directories.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@
6363
<%- else -%>
6464
Allow from all
6565
<%- end -%>
66+
<%- if directory['satisfy'] and directory['satisfy'] != '' -%>
67+
Satisfy <%= directory['satisfy'] %>
68+
<%- end -%>
6669
<%- end -%>
6770
<%- if directory['addhandlers'] and ! directory['addhandlers'].empty? -%>
6871
<%- [directory['addhandlers']].flatten.compact.each do |addhandler| -%>

0 commit comments

Comments
 (0)