Module: Agilix::Buzz::Commands::Authentication

Included in:
Api
Defined in:
lib/agilix/buzz/commands/authentication.rb

Instance Method Summary collapse

Instance Method Details

#compute_hmac(options = {}) ⇒ Object

This requires a key to exist with the given keyname, see putkey not sure what its used for yet api.compute_hmac



139
140
141
142
143
# File 'lib/agilix/buzz/commands/authentication.rb', line 139

def compute_hmac(options = {})
  options = argument_cleaner(required_params: %i( domainid keyname message ), optional_params: %i( algorithm format ), options: options )
  options[:message] = "$VAR_USERID#{options[:message]}$VAR_SECRETTime$VAR_TIME"
  authenticated_get cmd: "computeHMAC", **options
end

#extend_sessionObject

This is handled automatically by instantiation of a base Agilix::Buzz::Api instance and on subsequent calls to the api through the check_authentication method api.extend_session



23
24
25
26
27
28
# File 'lib/agilix/buzz/commands/authentication.rb', line 23

def extend_session
  response = authenticated_post cmd: "extendsession", bypass_authentication_check: true
  @token_expiration = set_token_expiration(response.dig("response", "session", "authenticationexpirationminutes"))
  authenticate! if response.dig("response", "code") == "NoAuthentication"
  response
end

#force_password_change(options = {}) ⇒ Object

api.force_password_change userid: 57181



31
32
33
34
# File 'lib/agilix/buzz/commands/authentication.rb', line 31

def force_password_change(options = {})
  options = argument_cleaner(required_params: %i( userid ), optional_params: %i( ), options: options )
  authenticated_post cmd: "forcepasswordchange", **options
end

#get_key(options = {}) ⇒ Object

api.get_key entityid: 57031, name: ‘secret_key_1’



131
132
133
134
# File 'lib/agilix/buzz/commands/authentication.rb', line 131

def get_key(options = {})
  options = argument_cleaner(required_params: %i( entityid name ), optional_params: %i( ), options: options )
  authenticated_get cmd: "getkey", **options
end

#get_password_login_attempt_history(options = {}) ⇒ Object

api.get_password_login_attempt_history userid: 57181 api.get_password_login_attempt_history userid: 57181, earliestrecordtoreturn: ‘2018-01-01’



38
39
40
41
# File 'lib/agilix/buzz/commands/authentication.rb', line 38

def (options = {})
  options = argument_cleaner(required_params: %i( userid ), optional_params: %i( earliestrecordtoreturn ), options: options )
  authenticated_get cmd: "getpasswordloginattempthistory", **options
end

#get_password_policy(options = {}) ⇒ Object

api.get_password_policy api.get_password_policy domainid: 57031



45
46
47
48
# File 'lib/agilix/buzz/commands/authentication.rb', line 45

def get_password_policy(options = {})
  options = argument_cleaner(required_params: %i(  ), optional_params: %i( domainid bypasscache ), options: options )
  authenticated_get cmd: "getpasswordpolicy", **options
end

#get_password_question(options = {}) ⇒ Object

api.get_password_question username: “auto-tests/BuzzUserUp1”



51
52
53
54
# File 'lib/agilix/buzz/commands/authentication.rb', line 51

def get_password_question(options = {})
  options = argument_cleaner(required_params: %i( username ), optional_params: %i( ), options: options )
  authenticated_get cmd: "getpasswordquestion", **options
end

#login2(username:, password:, domain:) ⇒ Object Also known as: login

This is handled automatically by instantiation of a base Agilix::Buzz::Api instance. It wouldn’t need to be called manually unless using for other users or making calls on their behalf api.login username: ‘my-username’, password: ‘my-password’, domain: ‘my-domain’



8
9
10
# File 'lib/agilix/buzz/commands/authentication.rb', line 8

def login2(username: , password: , domain: )
  post cmd: "login2", username: "#{domain}/#{username}", password: password
end

#logoutObject

api.logout



14
15
16
17
18
19
# File 'lib/agilix/buzz/commands/authentication.rb', line 14

def logout
  response = authenticated_get cmd: "logout"
  @token = nil
  @token_expiration = nil
  response
end

#proxy(options = {}) ⇒ Object

api.proxy userid: 57181



64
65
66
67
68
# File 'lib/agilix/buzz/commands/authentication.rb', line 64

def proxy(options = {})
  options = argument_cleaner(required_params: %i( userid ), optional_params: %i( noazt ), options: options )
  options[:noazt] ||= true
  authenticated_post cmd: "proxy", **options
end

#proxy_api(userid:) ⇒ Object

proxy_api = api.proxy_api userid: 57181



79
80
81
82
# File 'lib/agilix/buzz/commands/authentication.rb', line 79

def proxy_api(userid: )
  response = proxy userid: userid
  self.class.new username: response.dig('response', 'user', 'username'), token: response.dig('response', 'user', 'token'), domain: response.dig('response', 'user', 'userspace'), token_expiration: set_token_expiration(response.dig('response', 'user', 'authenticationexpirationminutes'))
end

api.proxy_sso_link userid: 57181



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/agilix/buzz/commands/authentication.rb', line 85

def proxy_sso_link(userid: , redirect_url: "home")
  response = proxy userid: userid
  # sso =  {
  #    "customization": {
  #       "authentication": {
  #          "provider": {
  #             "server": "https://www.google.com"
  #          }
  #       }
  #    }
  # }
  # self.update_domains [ {domainid: response.dig('response', 'user', 'domainid'), data: sso}]
  userspace = response.dig('response', 'user', 'userspace')
  token = response.dig('response', 'user', 'token')
  # "https://api.leaderinme.net/SSOLogin?domainid=#{response.dig('response', 'user', 'domainid')}&url=/home&token=#{response.dig('response', 'user', 'token')}"
  if token && userspace
    "https://#{userspace}.leaderinme.net/login?token=#{token}&url=/#{redirect_url}"
  end
end

#put_key(options = {}) ⇒ Object

ISSUE: This should be a POST method as it’s storing data api.put_key entityid: 57031, name: ‘secret_key_1’, value: “Super Secret”



125
126
127
128
# File 'lib/agilix/buzz/commands/authentication.rb', line 125

def put_key(options = {})
  options = argument_cleaner(required_params: %i( entityid name value ), optional_params: %i( ), options: options )
  authenticated_get cmd: "putkey", **options
end

#reset_lockout(options = {}) ⇒ Object

api.reset_lockout userid: 57181



106
107
108
109
# File 'lib/agilix/buzz/commands/authentication.rb', line 106

def reset_lockout(options = {})
  options = argument_cleaner(required_params: %i( userid ), optional_params: %i( ), options: options )
  authenticated_post cmd: "resetlockout", **options
end

#reset_password(options = {}) ⇒ Object



112
113
114
115
# File 'lib/agilix/buzz/commands/authentication.rb', line 112

def reset_password(options = {})
  options = argument_cleaner(required_params: %i( username ), optional_params: %i( answer ), options: options )
  authenticated_get cmd: "resetpassword", **options
end

#unproxy(options = {}) ⇒ Object

proxy_api = api.proxy_api userid: 57181 proxy_api.unproxy userid: 57181



72
73
74
75
# File 'lib/agilix/buzz/commands/authentication.rb', line 72

def unproxy(options = {})
  options = argument_cleaner(required_params: %i( userid ), optional_params: %i( noazt ), options: options )
  authenticated_post cmd: "unproxy", **options
end

#update_password(options = {}) ⇒ Object

api.update_password userid: 57181, password: “IChanged123”



118
119
120
121
# File 'lib/agilix/buzz/commands/authentication.rb', line 118

def update_password(options = {})
  options = argument_cleaner(required_params: %i( userid password ), optional_params: %i( token oldpassword ), options: options )
  authenticated_get cmd: "updatepassword", **options
end

#update_password_question_answer(options = {}) ⇒ Object

ISSUE: This works with a GET call api.update_password_question_answer userid: 57181, passwordquestion: “Where is your favorite vacation place?”, passwordanswer: “Hawaii”



58
59
60
61
# File 'lib/agilix/buzz/commands/authentication.rb', line 58

def update_password_question_answer(options = {})
  options = argument_cleaner(required_params: %i( userid passwordquestion passwordanswer ), optional_params: %i( oldpassword ), options: options )
  authenticated_post cmd: "updatepasswordquestionanswer", **options
end