Class: Qualys::Auth

Inherits:
Api
  • Object
show all
Defined in:
lib/qualys/auth.rb

Defined Under Namespace

Classes: InvalidLogin

Constant Summary

Constants inherited from Api

Qualys::Api::PRODUCTION_ENDPOINT

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Api

api_get, api_post, base_uri=

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/qualys/auth.rb', line 5

def name
  @name
end

Class Method Details

.loginObject

Do Login



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/qualys/auth.rb', line 8

def self.
  # Request a login
  response = api_post('/session/', body: {
                        action: 'login',
                        username: Qualys::Config.username,
                        password: Qualys::Config.password
                      })

  # set the session key
  Qualys::Config.session_key = response.header['Set-Cookie']
  true
end

.logoutObject

Set Logout



22
23
24
25
26
27
28
29
30
31
# File 'lib/qualys/auth.rb', line 22

def self.logout
  # Request a login
  api_post('/session/', body: {
             action: 'logout'
           })

  # set the session key
  Qualys::Config.session_key = nil
  true
end