Sha256: 5843b313873644a9a8838e19ab94cb7026d84afb643f7788b49a4d5be7244f21

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

namespace :auth_basic do
  desc 'Generate HTTP basic authentication'
  task :generate do
    puts "Please type the password for HTTP basic authentication, press ENTER when you're finished:"
    passwd   = $stdin.gets.chomp
    htpasswd = nil

    run_locally do
      htpasswd = capture(:htpasswd, '-nb', fetch(:auth_basic_user), passwd)
      htpasswd.chomp!
    end

    on fetch(:auth_basic_servers) do
      upload! StringIO.new(htpasswd), fetch(:auth_basic_target)
      execute :chmod, 'o+r', fetch(:auth_basic_target)
    end
  end
end

namespace :load do
  task :defaults do
    set :auth_basic_user,     'root'
    set :auth_basic_roles,    :all
    set :auth_basic_servers,  -> { release_roles(fetch(:auth_basic_roles)) }
    set :auth_basic_target,   -> { shared_path.join('.htpasswd') }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mascherano-1.2.0 lib/mascherano/tasks/auth_basic.cap