Created
February 1, 2011 13:51
-
-
Save pierot/805879 to your computer and use it in GitHub Desktop.
Capistrano snippet to secure deployment environment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :stages, %w(testing staging production) | |
set :default_stage, "testing" | |
require 'capistrano/ext/multistage' | |
task :protect do | |
# http://www.htaccesstools.com/htaccess-authentication/ | |
run "echo 'username:$apr1$gT8Ap...$3f8RadFS7xottW8AYVX5b0' >> #{File.join(current_path, '.htpasswd')}" | |
run "echo 'AuthType Basic' >> #{File.join(current_path, '.htaccess')}" | |
run "echo 'AuthName \"Restricted\"' >> #{File.join(current_path, '.htaccess')}" | |
run "echo 'AuthUserFile /absolute/path/to/.htpasswd' >> #{File.join(current_path, '.htaccess')}" | |
run "echo 'Require valid-user' >> #{File.join(current_path, '.htaccess')}" | |
end | |
task :restart, :roles => :app, :except => { :no_release => true } do | |
if [:testing, :staging].include? stage | |
deploy.protect | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment