Sha256: 95b2cc67ded39a9aa86fc3e2f4d8f4e23f6582b4a6fa68fa0dcdfaca0f80bd12
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
require 'conjur/user' module Conjur class API class << self # Perform login by Basic authentication. def login username, password if Conjur.log Conjur.log << "Logging in #{username} via Basic authentication\n" end RestClient::Resource.new(Conjur::Authn::API.host, user: username, password: password)['users/login'].get end # Perform login by CAS authentication. def login_cas username, password, cas_api_url if Conjur.log Conjur.log << "Logging in #{username} via CAS authentication\n" end require 'cas_rest_client' client = CasRestClient.new(:username => username, :password => password, :uri => [ cas_api_url, 'v1', 'tickets' ].join('/'), :use_cookies => false) client.get("#{Conjur::Authn::API.host}/users/login").body end def authenticate username, password if Conjur.log Conjur.log << "Authenticating #{username}\n" end JSON::parse(RestClient::Resource.new(Conjur::Authn::API.host)["users/#{path_escape username}/authenticate"].post password, content_type: 'text/plain') end end # Options: # +password+ # # Response: # +login+ # +api_key+ def create_authn_user login, options = {} log do |logger| logger << "Creating authn user #{login}" end JSON.parse RestClient::Resource.new(Conjur::Authn::API.host, credentials)['users'].post(options.merge(login: login)) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
conjur-api-2.1.3 | lib/conjur/api/authn.rb |
conjur-api-2.1.2 | lib/conjur/api/authn.rb |
conjur-api-2.1.1 | lib/conjur/api/authn.rb |
conjur-api-2.1.0 | lib/conjur/api/authn.rb |