Sha256: 3c3a9278a0d9a6e0746cf0afde2f9b29f3612e38806b7fe1527b7d5258055cfb
Contents?: true
Size: 905 Bytes
Versions: 2
Compression:
Stored size: 905 Bytes
Contents
require 'yaml' require "base64" require 'bcrypt' # The main SmartCloud User driver module SmartCloud class User < SmartCloud::Base def initialize end def self.create_htpasswd_files htpasswd_dirpath = "#{Dir.pwd}/grids/nginx/htpasswd" # Remove existing htpasswd_dirpath FileUtils.rm_r htpasswd_dirpath if Dir.exist?(htpasswd_dirpath) # Create new htpasswd_dirpath FileUtils.mkdir htpasswd_dirpath # Add hostfiles to htpasswd_dirpath self.get_users_from_file.each do |domainname, users| next unless users file_data = "" users.each do |user, password| file_data += "#{user}:#{BCrypt::Password.create(password)}\n" end File.open("#{Dir.pwd}/grids/nginx/htpasswd/#{domainname}", "w") { |file| file.write(file_data) } end end private def self.get_users_from_file YAML.load_file("#{Dir.pwd}/config/users.yml") || Hash.new end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smartcloud-0.8.0 | lib/smart_cloud/user.rb |
smartcloud-0.7.0 | lib/smart_cloud/user.rb |