Sha256: 4be2f9f2ac07e031c7756d3d592a99ef27ad4bfa7159c245e5ed1642d8e069f1

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

require 'conjur/authn'
require 'conjur/command'

class Conjur::Command::Authn < Conjur::Command
  self.prefix = :authn
  
  desc "Logs in and caches credentials to netrc"
  long_desc <<-DESC
After successful login, subsequent commands automatically use the cached credentials. To switch users, login again using the new user credentials.
To erase credentials, use the authn:logout command.

If specified, the CAS server URL should be in the form https://<hostname>/v1.
It should be running the CAS RESTful services at the /v1 path
(or other path as specified by this argument).
DESC
  command :login do |c|
    c.arg_name 'username'
    c.flag [:u,:username]

    c.arg_name 'password'
    c.flag [:p,:password]

    c.arg_name 'CAS server'
    c.desc 'Specifies a CAS server URL to use for login'
    c.flag [:"cas-server"]
    
    c.action do |global_options,options,args|
      Conjur::Authn.login(options)
    end
  end
  
  desc "Logs out"
  command :logout do |c|
    c.action do
      Conjur::Authn.delete_credentials
    end
  end

  desc "Prints out the current logged in username"
  command :whoami do |c|
    c.action do
      if creds = Conjur::Authn.read_credentials
        puts creds[0]
      else
        exit_now! 'Not logged in.', -1
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
conjur-cli-2.1.6 lib/conjur/command/authn.rb
conjur-cli-2.1.5 lib/conjur/command/authn.rb
conjur-cli-2.1.4 lib/conjur/command/authn.rb