class Gemstash::CLI::Authorize
This implements the command line authorize task to authorize users:
$ gemstash authorize authorized-key
Public Instance Methods
run()
click to toggle source
# File lib/gemstash/cli/authorize.rb, line 12 def run prepare setup_logging # Catch invalid option combinations raise Gemstash::CLI::Error.new(@cli, "--remove and --list cannot both be used") if @cli.options[:remove] && @cli.options[:list] if @cli.options[:remove] remove_authorization elsif @cli.options[:list] list_authorizations else save_authorization end end
Private Instance Methods
auth_key(allow_generate: true)
click to toggle source
# File lib/gemstash/cli/authorize.rb, line 74 def auth_key(allow_generate: true) if @cli.options[:key] @cli.options[:key] elsif allow_generate key = SecureRandom.hex(16) key = SecureRandom.hex(16) while Gemstash::Authorization[key] @cli.say "Your new key is: #{key}" key else raise Gemstash::CLI::Error.new(@cli, "The --key option is required to remove an authorization key") end end
permissions()
click to toggle source
# File lib/gemstash/cli/authorize.rb, line 87 def permissions if @args.empty? "all" else @args end end
setup_logging()
click to toggle source
# File lib/gemstash/cli/authorize.rb, line 30 def setup_logging Gemstash::Logging.setup_logger(gemstash_env.log_file) end