Sha256: 26b131bceaf125dd26db77146eacebb7bf6e09251ec4a238a2120047b7dc4d06
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
require 'donjon/commands/base' require 'donjon/user' module Donjon module Commands Base.class_eval do desc 'user:add NAME [PATH]', 'Adds user and their public key to the vault. Reads from standard input if no path is given.' decl 'user:add' private def user_add(name, path = nil) if path == nil say "Please paste #{name}'s public key in PEM format.", :green say "They can obtain it by running e.g.:" say "$ openssl rsa -in ~/.ssh/id_rsa -pubout -outform pem" $stderr.write('> ') key_data = '' while line = $stdin.gets break if line.strip.empty? key_data << line end else key_data = Pathname.new(key_path).expand_path.read end key = OpenSSL::PKey::RSA.new(key_data, '').public_key say "Saving #{name}'s public key..." User.new(name: name, key: key, repo: actor.repo).save say "Making the database readable by #{name}..." database.update say "Success! #{name} has been added to the vault.", [:green, :bold] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
donjon-0.0.2 | lib/donjon/commands/user.rb |
donjon-0.0.1 | lib/donjon/commands/user.rb |