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 [multi-factor authentication (MFA) policies](auth0.com/docs/secure/multi-factor-authentication/enable-mfa) configured for your tenant.

The following policies are supported:

  • ‘all-applications` policy prompts with MFA for all logins.

  • ‘confidence-score` policy prompts with MFA only for low confidence logins.

Note: The ‘confidence-score` policy is part of the [Adaptive MFA feature](auth0.com/docs/secure/multi-factor-authentication/adaptive-mfa). Adaptive MFA requires an add-on for the Enterprise plan; review [Auth0 Pricing](auth0.com/pricing) 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:



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

def list(request_options: {}, **_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 [multi-factor authentication (MFA) policies](auth0.com/docs/secure/multi-factor-authentication/enable-mfa) for your tenant.

The following policies are supported:

  • ‘all-applications` policy prompts with MFA for all logins.

  • ‘confidence-score` policy prompts with MFA only for low confidence logins.

Note: The ‘confidence-score` policy is part of the [Adaptive MFA feature](auth0.com/docs/secure/multi-factor-authentication/adaptive-mfa). Adaptive MFA requires an add-on for the Enterprise plan; review [Auth0 Pricing](auth0.com/pricing) 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:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/auth0/guardian/policies/client.rb', line 77

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