Auth0Client.Management.Guardian (auth0_client v1.1.0)

Copy Markdown View Source

A module representing Guardian, Auth0's multi-factor authentication, on Auth0.

This is the tenant-wide configuration side of MFA — which factors exist, how they are delivered, and when they are required. The per-user side lives on Auth0Client.Management.User: enrollments/1 reports what a user has enrolled and delete_authenticators/1 resets it.

update versus replace

Where Auth0 offers both verbs for a provider's configuration, update_* is the PATCH and merges into what is already there, while replace_* is the PUT and overwrites the whole configuration. Where Auth0 offers only PUT — the phone settings, the selected-provider endpoints and the policies — update_* is that PUT, since there is no second verb to distinguish it from.

The /guardian/factors/sms/* endpoints are not wrapped. Auth0 documents them as deprecated and points at the phone equivalents below, which take the same payloads.

https://auth0.com/docs/api/management/v2/guardian

Summary

Functions

Gets the APNs push configuration

Creates an enrollment ticket, the out-of-band way to get a user to enrol in MFA.

Deletes an enrollment, so the user must enrol again

Gets the Duo configuration

Gets an enrollment

Lists the available factors and whether each is enabled

Gets the message types enabled for the phone factor

Gets which provider delivers the phone factor

Gets the enrollment and verification message templates for the phone factor

Gets the Twilio configuration for the phone factor

Gets the tenant's MFA policies

Gets which provider delivers push notifications

Replaces the whole APNs push configuration

Replaces the whole Duo configuration

Replaces the whole FCM push configuration. Write-only, as with update_fcm/1.

Replaces the whole FCM v1 push configuration. Write-only, as with update_fcm/1.

Replaces the whole Amazon SNS push configuration

Gets the Amazon SNS push configuration

Merges into the APNs push configuration

Merges into the Duo configuration

Enables or disables a factor for the whole tenant.

Merges into the FCM push configuration.

Merges into the FCM v1 push configuration. Write-only, as with update_fcm/1.

Sets the message types for the phone factor — sms, voice, or both

Chooses which provider delivers the phone factor — auth0, twilio or phone-message-hook

Customises the enrollment and verification messages for the phone factor

Sets the Twilio configuration for the phone factor

Sets the tenant's MFA policies.

Chooses which provider delivers push notifications — guardian, sns or direct

Merges into the Amazon SNS push configuration

Functions

apns()

Gets the APNs push configuration

iex> Auth0Client.Management.Guardian.apns()

create_enrollment_ticket(body)

Creates an enrollment ticket, the out-of-band way to get a user to enrol in MFA.

user_id is required. factor may be one of push-notification, phone, email, otp, webauthn-roaming or webauthn-platform. Set send_mail to have Auth0 email the ticket, or read ticket_url from the response and deliver it yourself.

iex> Auth0Client.Management.Guardian.create_enrollment_ticket(%{user_id: "auth0|123", send_mail: true})

delete_enrollment(id)

Deletes an enrollment, so the user must enrol again

iex> Auth0Client.Management.Guardian.delete_enrollment("dev_abc123")

duo_settings()

Gets the Duo configuration

iex> Auth0Client.Management.Guardian.duo_settings()

enrollment(id)

Gets an enrollment

iex> Auth0Client.Management.Guardian.enrollment("dev_abc123")

factors()

Lists the available factors and whether each is enabled

iex> Auth0Client.Management.Guardian.factors()

phone_message_types()

Gets the message types enabled for the phone factor

iex> Auth0Client.Management.Guardian.phone_message_types()

phone_provider()

Gets which provider delivers the phone factor

iex> Auth0Client.Management.Guardian.phone_provider()

phone_templates()

Gets the enrollment and verification message templates for the phone factor

iex> Auth0Client.Management.Guardian.phone_templates()

phone_twilio()

Gets the Twilio configuration for the phone factor

iex> Auth0Client.Management.Guardian.phone_twilio()

policies()

Gets the tenant's MFA policies

iex> Auth0Client.Management.Guardian.policies()

push_provider()

Gets which provider delivers push notifications

iex> Auth0Client.Management.Guardian.push_provider()

replace_apns(body)

Replaces the whole APNs push configuration

iex> Auth0Client.Management.Guardian.replace_apns(%{bundle_id: "com.example.app", p12: "...", sandbox: false})

replace_duo_settings(body)

Replaces the whole Duo configuration

iex> Auth0Client.Management.Guardian.replace_duo_settings(%{ikey: "...", skey: "...", hostname: "api-abc.duosecurity.com"})

replace_fcm(body)

Replaces the whole FCM push configuration. Write-only, as with update_fcm/1.

iex> Auth0Client.Management.Guardian.replace_fcm(%{server_key: "..."})

replace_fcmv1(body)

Replaces the whole FCM v1 push configuration. Write-only, as with update_fcm/1.

iex> Auth0Client.Management.Guardian.replace_fcmv1(%{server_credentials: "..."})

replace_sns(body)

Replaces the whole Amazon SNS push configuration

iex> Auth0Client.Management.Guardian.replace_sns(%{aws_access_key_id: "...", aws_region: "us-east-1"})

sns()

Gets the Amazon SNS push configuration

iex> Auth0Client.Management.Guardian.sns()

update_apns(body)

Merges into the APNs push configuration

iex> Auth0Client.Management.Guardian.update_apns(%{sandbox: true})

update_duo_settings(body)

Merges into the Duo configuration

iex> Auth0Client.Management.Guardian.update_duo_settings(%{hostname: "api-abc.duosecurity.com"})

update_factor(name, body)

Enables or disables a factor for the whole tenant.

name is the factor — sms, push-notification, otp, email, duo, webauthn-roaming, webauthn-platform or recovery-code.

iex> Auth0Client.Management.Guardian.update_factor("otp", %{enabled: true})

update_fcm(body)

Merges into the FCM push configuration.

Auth0 exposes no way to read the FCM configuration back — only PATCH and PUT. That asymmetry with APNs and SNS is Auth0's, not an omission here.

iex> Auth0Client.Management.Guardian.update_fcm(%{server_key: "..."})

update_fcmv1(body)

Merges into the FCM v1 push configuration. Write-only, as with update_fcm/1.

iex> Auth0Client.Management.Guardian.update_fcmv1(%{server_credentials: "..."})

update_phone_message_types(body)

Sets the message types for the phone factor — sms, voice, or both

iex> Auth0Client.Management.Guardian.update_phone_message_types(%{message_types: ["sms", "voice"]})

update_phone_provider(body)

Chooses which provider delivers the phone factor — auth0, twilio or phone-message-hook

iex> Auth0Client.Management.Guardian.update_phone_provider(%{provider: "twilio"})

update_phone_templates(body)

Customises the enrollment and verification messages for the phone factor

iex> Auth0Client.Management.Guardian.update_phone_templates(%{enrollment_message: "Your code is @@password@@"})

update_phone_twilio(body)

Sets the Twilio configuration for the phone factor

iex> Auth0Client.Management.Guardian.update_phone_twilio(%{sid: "AC...", auth_token: "...", from: "+15551234567"})

update_policies(policies)

Sets the tenant's MFA policies.

The body is a bare list, not an object wrapping one. ["all-applications"] always prompts; ["confidence-score"] prompts adaptively; [] disables the policy.

iex> Auth0Client.Management.Guardian.update_policies(["all-applications"])
iex> Auth0Client.Management.Guardian.update_policies([])

update_push_provider(body)

Chooses which provider delivers push notifications — guardian, sns or direct

iex> Auth0Client.Management.Guardian.update_push_provider(%{provider: "direct"})

update_sns(body)

Merges into the Amazon SNS push configuration

iex> Auth0Client.Management.Guardian.update_sns(%{aws_region: "us-east-1"})