Sha256: 57bd57cb3bf0760df747ed4204a1023f4b52f4e5dbdd6e7f367a29457ba5d310

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 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 roles(fetch(:auth_basic_roles)) 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_target, -> { shared_path.join('.htpasswd') }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mascherano-1.1.0 lib/mascherano/tasks/auth_basic.cap
mascherano-1.0.4 lib/mascherano/tasks/auth_basic.cap