module Agilix::Buzz::Commands::Authentication
Public Instance Methods
This requires a key to exist with the given keyname, see putkey not sure what its used for yet api.compute_hmac
# 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
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
# 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
api.force_password_change userid: 57181
# 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
api.get_key entityid: 57031, name: 'secret_key_1'
# 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
api.get_password_login_attempt_history userid: 57181 api.get_password_login_attempt_history userid: 57181, earliestrecordtoreturn: '2018-01-01'
# File lib/agilix/buzz/commands/authentication.rb, line 38 def get_password_login_attempt_history(options = {}) options = argument_cleaner(required_params: %i( userid ), optional_params: %i( earliestrecordtoreturn ), options: options ) authenticated_get cmd: "getpasswordloginattempthistory", **options end
api.get_password_policy api.get_password_policy domainid: 57031
# 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
api.get_password_question username: “auto-tests/BuzzUserUp1”
# 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
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'
# File lib/agilix/buzz/commands/authentication.rb, line 8 def login2(username: , password: , domain: ) post cmd: "login2", username: "#{domain}/#{username}", password: password end
api.logout
# File lib/agilix/buzz/commands/authentication.rb, line 14 def logout response = authenticated_get cmd: "logout" @token = nil @token_expiration = nil response end
api.proxy userid: 57181
# 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
= api.proxy_api userid: 57181
# 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
# 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
ISSUE: This should be a POST method as it's storing data api.put_key entityid: 57031, name: 'secret_key_1', value: “Super Secret”
# 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
api.reset_lockout userid: 57181
# 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
# 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
proxy_api
= api.proxy_api userid: 57181 proxy_api.unproxy userid: 57181
# 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
api.update_password userid: 57181, password: “IChanged123”
# 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
ISSUE: This works with a GET call api.update_password_question_answer userid: 57181, passwordquestion: “Where is your favorite vacation place?”, passwordanswer: “Hawaii”
# 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
Private Instance Methods
# File lib/agilix/buzz/commands/authentication.rb, line 146 def set_token_expiration(minutes) Time.now + (minutes.to_i * 60 ) end