Class: DuoApi::Auth

Inherits:
DuoApi show all
Defined in:
lib/duo_api/auth.rb

Overview

Duo Auth API (duo.com/docs/authapi)

Constant Summary

Constants inherited from DuoApi

BACKOFF_FACTOR, INITIAL_BACKOFF_WAIT_SECS, MAX_BACKOFF_WAIT_SECS, VERSION

Instance Attribute Summary

Attributes inherited from DuoApi

#ca_file, #default_params

Instance Method Summary collapse

Methods inherited from DuoApi

#delete, #get, #get_all, #get_image, #initialize, #post, #put, #request

Constructor Details

This class inherits a constructor from DuoApi

Instance Method Details

#auth(factor:, **optional_params) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/duo_api/auth.rb', line 47

def auth(factor:, **optional_params)
  # optional_params: user_id, username, ipaddr, hostname, async
  #
  # Note: user_id or username must be provided
  optional_params.tap do |p|
    p[:async] = stringified_binary_boolean(p[:async]) if p[:async]
  end
  params = optional_params.merge({ factor: factor })
  post('/auth/v2/auth', params)[:response]
end

#auth_status(txid:) ⇒ Object



58
59
60
61
# File 'lib/duo_api/auth.rb', line 58

def auth_status(txid:)
  params = { txid: txid }
  get('/auth/v2/auth_status', params)[:response]
end

#checkObject



15
16
17
# File 'lib/duo_api/auth.rb', line 15

def check
  get('/auth/v2/check')[:response]
end

#enroll(**optional_params) ⇒ Object



23
24
25
26
# File 'lib/duo_api/auth.rb', line 23

def enroll(**optional_params)
  # optional_params: username, valid_secs
  post('/auth/v2/enroll', optional_params)[:response]
end

#enroll_status(user_id:, activation_code:) ⇒ Object



28
29
30
31
# File 'lib/duo_api/auth.rb', line 28

def enroll_status(user_id:, activation_code:)
  params = { user_id: user_id, activation_code: activation_code }
  post('/auth/v2/enroll_status', params)[:response]
end

#logoObject



19
20
21
# File 'lib/duo_api/auth.rb', line 19

def 
  get_image('/auth/v2/logo')
end

#pingObject



11
12
13
# File 'lib/duo_api/auth.rb', line 11

def ping
  get('/auth/v2/ping')[:response]
end

#preauth(**optional_params) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/duo_api/auth.rb', line 33

def preauth(**optional_params)
  # optional_params: user_id, username, client_supports_verified_push, ipaddr, hostname,
  #                  trusted_device_token
  #
  # Note: user_id or username must be provided
  optional_params.tap do |p|
    if p[:client_supports_verified_push]
      p[:client_supports_verified_push] =
        stringified_binary_boolean(p[:client_supports_verified_push])
    end
  end
  post('/auth/v2/preauth', optional_params)[:response]
end