Class: Yandex360::TwoFaResource

Inherits:
Resource
  • Object
show all
Includes:
ParamBuilder
Defined in:
lib/yandex360/resources/two_fa.rb

Overview

Mandatory two-factor authentication for the whole organization.

All three operations share one path and differ only by verb, which is why there is no separate enable or disable endpoint to call.

Per-employee two-factor authentication is not here: reading it is users.get2FA and clearing the phone is users.delete_2fa_phone, both on UserService.

See https://yandex.ru/dev/api360/doc/ru/ref/Domain2FAService/

Instance Attribute Summary

Attributes inherited from Resource

#client

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Yandex360::Resource

Instance Method Details

#disable(org_id:) ⇒ Object



33
34
35
36
# File 'lib/yandex360/resources/two_fa.rb', line 33

def disable(org_id:)
  validate_required_params({org_id: org_id}, [:org_id])
  Domain2FA.new delete_request(domain_path(org_id)).body
end

#domain_status(org_id:) ⇒ Object

Deprecated: the name #status carried before this resource was corrected. Removed in 5.0.



40
41
42
43
# File 'lib/yandex360/resources/two_fa.rb', line 40

def domain_status(org_id:)
  warn "[yandex360] two_fa.domain_status is deprecated, use two_fa.status", uplevel: 1
  status(org_id: org_id)
end

#enable(org_id:, duration:, logout_users: nil, validation_method: nil) ⇒ Object

duration is how long, in seconds, an employee may postpone setting 2FA up during sign-in. validation_method is "default" or "phone".



24
25
26
27
28
29
30
31
# File 'lib/yandex360/resources/two_fa.rb', line 24

def enable(org_id:, duration:, logout_users: nil, validation_method: nil)
  validate_required_params({org_id: org_id, duration: duration}, i[org_id duration])
  body = {duration: duration}
  body[:logoutUsers] = logout_users unless logout_users.nil?
  body[:validationMethod] = validation_method unless validation_method.nil?

  Domain2FA.new post(domain_path(org_id), body: body).body
end

#status(org_id:) ⇒ Object



17
18
19
20
# File 'lib/yandex360/resources/two_fa.rb', line 17

def status(org_id:)
  validate_required_params({org_id: org_id}, [:org_id])
  Domain2FA.new get(domain_path(org_id)).body
end