Class: Auth0::Guardian::Policies::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/auth0/guardian/policies/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



10
11
12
# File 'lib/auth0/guardian/policies/client.rb', line 10

def initialize(client:)
  @client = client
end

Instance Method Details

#list(request_options: {}, **params) ⇒ Array[Auth0::Types::MfaPolicyEnum]

Retrieve the <a href=“auth0.com/docs/secure/multi-factor-authentication/enable-mfa”>multi-factor authentication (MFA) policies</a> configured for your tenant.

The following policies are supported: <ul> <li>all-applications policy prompts with MFA for all logins.</li> <li>confidence-score policy prompts with MFA only for low confidence logins.</li> </ul>

Note: The confidence-score policy is part of the <a href=“auth0.com/docs/secure/multi-factor-authentication/adaptive-mfa”>Adaptive MFA feature</a>. Adaptive MFA requires an add-on for the Enterprise plan; review <a href=“auth0.com/pricing”>Auth0 Pricing</a> for more details.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/auth0/guardian/policies/client.rb', line 37

def list(request_options: {}, **params)
  Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "guardian/policies",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Auth0::Types::ListGuardianPoliciesResponseContent.load(response.body)
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#set(request_options: {}, **params) ⇒ Array[Auth0::Types::MfaPolicyEnum]

Set <a href=“auth0.com/docs/secure/multi-factor-authentication/enable-mfa”>multi-factor authentication (MFA) policies</a> for your tenant.

The following policies are supported: <ul> <li>all-applications policy prompts with MFA for all logins.</li> <li>confidence-score policy prompts with MFA only for low confidence logins.</li> </ul>

Note: The confidence-score policy is part of the <a href=“auth0.com/docs/secure/multi-factor-authentication/adaptive-mfa”>Adaptive MFA feature</a>. Adaptive MFA requires an add-on for the Enterprise plan; review <a href=“auth0.com/pricing”>Auth0 Pricing</a> for more details.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/auth0/guardian/policies/client.rb', line 82

def set(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PUT",
    path: "guardian/policies",
    body: params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Auth0::Types::SetGuardianPoliciesResponseContent.load(response.body)
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end