From db119da6e41b9261d0f7c223784a08d73666d170 Mon Sep 17 00:00:00 2001 From: Kunal Dawar Date: Tue, 8 Sep 2026 11:01:39 +0530 Subject: [PATCH 1/5] feat: add guardian (MFA) command group Add a top-level `auth0 guardian` command group for managing Auth0 multi-factor authentication, built on the go-auth0/v3 SDK. Covers MFA policies, user enrollments, factor enable/disable, and provider configuration for phone, SMS, push (APNs, FCM, FCM v1, SNS) and Duo. The legacy phone/SMS provider, template and Twilio endpoints are marked (legacy) and return actionable guidance on tenants moved to the unified phone experience, where those endpoints are no longer reachable via Management API tokens. Bumps go-auth0/v3 to v3.4.0 and adds the required Guardian scopes to the device-code login flow. --- README.md | 1 + docs/auth0_guardian.md | 14 + docs/auth0_guardian_enrollments.md | 15 + ...uth0_guardian_enrollments_create-ticket.md | 58 ++ docs/auth0_guardian_enrollments_delete.md | 53 ++ docs/auth0_guardian_enrollments_show.md | 48 ++ docs/auth0_guardian_factors.md | 18 + docs/auth0_guardian_factors_duo.md | 12 + docs/auth0_guardian_factors_duo_settings.md | 15 + ...auth0_guardian_factors_duo_settings_set.md | 50 ++ ...uth0_guardian_factors_duo_settings_show.md | 47 ++ ...h0_guardian_factors_duo_settings_update.md | 50 ++ docs/auth0_guardian_factors_list.md | 52 ++ docs/auth0_guardian_factors_phone.md | 20 + ...uardian_factors_phone_set-message-types.md | 54 ++ ...th0_guardian_factors_phone_set-provider.md | 56 ++ ...h0_guardian_factors_phone_set-templates.md | 58 ++ ...auth0_guardian_factors_phone_set-twilio.md | 59 ++ ...ardian_factors_phone_show-message-types.md | 52 ++ ...h0_guardian_factors_phone_show-provider.md | 55 ++ ...0_guardian_factors_phone_show-templates.md | 54 ++ ...uth0_guardian_factors_phone_show-twilio.md | 54 ++ docs/auth0_guardian_factors_push.md | 24 + docs/auth0_guardian_factors_push_set-apns.md | 59 ++ docs/auth0_guardian_factors_push_set-fcm.md | 57 ++ docs/auth0_guardian_factors_push_set-fcmv1.md | 57 ++ ...uth0_guardian_factors_push_set-provider.md | 58 ++ docs/auth0_guardian_factors_push_set-sns.md | 63 ++ docs/auth0_guardian_factors_push_show-apns.md | 56 ++ ...th0_guardian_factors_push_show-provider.md | 56 ++ docs/auth0_guardian_factors_push_show-sns.md | 56 ++ ...auth0_guardian_factors_push_update-apns.md | 59 ++ .../auth0_guardian_factors_push_update-fcm.md | 57 ++ ...uth0_guardian_factors_push_update-fcmv1.md | 57 ++ .../auth0_guardian_factors_push_update-sns.md | 61 ++ docs/auth0_guardian_factors_set.md | 53 ++ docs/auth0_guardian_factors_sms.md | 20 + ...auth0_guardian_factors_sms_set-provider.md | 54 ++ ...uth0_guardian_factors_sms_set-templates.md | 56 ++ docs/auth0_guardian_factors_sms_set-twilio.md | 57 ++ ...uth0_guardian_factors_sms_show-provider.md | 52 ++ ...th0_guardian_factors_sms_show-templates.md | 52 ++ .../auth0_guardian_factors_sms_show-twilio.md | 52 ++ docs/auth0_guardian_policies.md | 14 + docs/auth0_guardian_policies_set.md | 54 ++ docs/auth0_guardian_policies_show.md | 47 ++ docs/index.md | 1 + go.mod | 2 +- go.sum | 4 +- internal/auth/auth.go | 3 + internal/auth/scopes_test.go | 3 + internal/auth0/auth0.go | 14 + internal/auth0/guardian_enrollment.go | 30 + internal/auth0/guardian_factor.go | 24 + internal/auth0/guardian_factor_duo.go | 26 + internal/auth0/guardian_factor_phone.go | 41 ++ internal/auth0/guardian_factor_push.go | 54 ++ internal/auth0/guardian_factor_sms.go | 35 + internal/auth0/guardian_policy.go | 24 + internal/auth0/mock/flow_v3_mock.go | 201 ++++++ .../auth0/mock/guardian_enrollment_mock.go | 96 +++ .../auth0/mock/guardian_factor_duo_mock.go | 97 +++ internal/auth0/mock/guardian_factor_mock.go | 77 ++ .../auth0/mock/guardian_factor_phone_mock.go | 197 +++++ .../auth0/mock/guardian_factor_push_mock.go | 277 +++++++ .../auth0/mock/guardian_factor_sms_mock.go | 157 ++++ internal/auth0/mock/guardian_policy_mock.go | 77 ++ internal/cli/guardian.go | 50 ++ internal/cli/guardian_enrollments.go | 231 ++++++ internal/cli/guardian_factor_duo.go | 211 ++++++ internal/cli/guardian_factor_phone.go | 373 ++++++++++ internal/cli/guardian_factor_push.go | 676 ++++++++++++++++++ internal/cli/guardian_factor_sms.go | 287 ++++++++ internal/cli/guardian_factors.go | 142 ++++ internal/cli/guardian_factors_providers.go | 183 +++++ internal/cli/guardian_policies.go | 141 ++++ internal/cli/root.go | 1 + internal/display/guardian.go | 231 ++++++ internal/display/guardian_test.go | 53 ++ test/integration/guardian-test-cases.yaml | 495 +++++++++++++ 80 files changed, 6637 insertions(+), 3 deletions(-) create mode 100644 docs/auth0_guardian.md create mode 100644 docs/auth0_guardian_enrollments.md create mode 100644 docs/auth0_guardian_enrollments_create-ticket.md create mode 100644 docs/auth0_guardian_enrollments_delete.md create mode 100644 docs/auth0_guardian_enrollments_show.md create mode 100644 docs/auth0_guardian_factors.md create mode 100644 docs/auth0_guardian_factors_duo.md create mode 100644 docs/auth0_guardian_factors_duo_settings.md create mode 100644 docs/auth0_guardian_factors_duo_settings_set.md create mode 100644 docs/auth0_guardian_factors_duo_settings_show.md create mode 100644 docs/auth0_guardian_factors_duo_settings_update.md create mode 100644 docs/auth0_guardian_factors_list.md create mode 100644 docs/auth0_guardian_factors_phone.md create mode 100644 docs/auth0_guardian_factors_phone_set-message-types.md create mode 100644 docs/auth0_guardian_factors_phone_set-provider.md create mode 100644 docs/auth0_guardian_factors_phone_set-templates.md create mode 100644 docs/auth0_guardian_factors_phone_set-twilio.md create mode 100644 docs/auth0_guardian_factors_phone_show-message-types.md create mode 100644 docs/auth0_guardian_factors_phone_show-provider.md create mode 100644 docs/auth0_guardian_factors_phone_show-templates.md create mode 100644 docs/auth0_guardian_factors_phone_show-twilio.md create mode 100644 docs/auth0_guardian_factors_push.md create mode 100644 docs/auth0_guardian_factors_push_set-apns.md create mode 100644 docs/auth0_guardian_factors_push_set-fcm.md create mode 100644 docs/auth0_guardian_factors_push_set-fcmv1.md create mode 100644 docs/auth0_guardian_factors_push_set-provider.md create mode 100644 docs/auth0_guardian_factors_push_set-sns.md create mode 100644 docs/auth0_guardian_factors_push_show-apns.md create mode 100644 docs/auth0_guardian_factors_push_show-provider.md create mode 100644 docs/auth0_guardian_factors_push_show-sns.md create mode 100644 docs/auth0_guardian_factors_push_update-apns.md create mode 100644 docs/auth0_guardian_factors_push_update-fcm.md create mode 100644 docs/auth0_guardian_factors_push_update-fcmv1.md create mode 100644 docs/auth0_guardian_factors_push_update-sns.md create mode 100644 docs/auth0_guardian_factors_set.md create mode 100644 docs/auth0_guardian_factors_sms.md create mode 100644 docs/auth0_guardian_factors_sms_set-provider.md create mode 100644 docs/auth0_guardian_factors_sms_set-templates.md create mode 100644 docs/auth0_guardian_factors_sms_set-twilio.md create mode 100644 docs/auth0_guardian_factors_sms_show-provider.md create mode 100644 docs/auth0_guardian_factors_sms_show-templates.md create mode 100644 docs/auth0_guardian_factors_sms_show-twilio.md create mode 100644 docs/auth0_guardian_policies.md create mode 100644 docs/auth0_guardian_policies_set.md create mode 100644 docs/auth0_guardian_policies_show.md create mode 100644 internal/auth0/guardian_enrollment.go create mode 100644 internal/auth0/guardian_factor.go create mode 100644 internal/auth0/guardian_factor_duo.go create mode 100644 internal/auth0/guardian_factor_phone.go create mode 100644 internal/auth0/guardian_factor_push.go create mode 100644 internal/auth0/guardian_factor_sms.go create mode 100644 internal/auth0/guardian_policy.go create mode 100644 internal/auth0/mock/flow_v3_mock.go create mode 100644 internal/auth0/mock/guardian_enrollment_mock.go create mode 100644 internal/auth0/mock/guardian_factor_duo_mock.go create mode 100644 internal/auth0/mock/guardian_factor_mock.go create mode 100644 internal/auth0/mock/guardian_factor_phone_mock.go create mode 100644 internal/auth0/mock/guardian_factor_push_mock.go create mode 100644 internal/auth0/mock/guardian_factor_sms_mock.go create mode 100644 internal/auth0/mock/guardian_policy_mock.go create mode 100644 internal/cli/guardian.go create mode 100644 internal/cli/guardian_enrollments.go create mode 100644 internal/cli/guardian_factor_duo.go create mode 100644 internal/cli/guardian_factor_phone.go create mode 100644 internal/cli/guardian_factor_push.go create mode 100644 internal/cli/guardian_factor_sms.go create mode 100644 internal/cli/guardian_factors.go create mode 100644 internal/cli/guardian_factors_providers.go create mode 100644 internal/cli/guardian_policies.go create mode 100644 internal/display/guardian.go create mode 100644 internal/display/guardian_test.go create mode 100644 test/integration/guardian-test-cases.yaml diff --git a/README.md b/README.md index 823d5b8c3..8a26e4d69 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,7 @@ Select **y** to proceed with your default tenant, or **N** to choose a different - [auth0 domains](https://auth0.github.io/auth0-cli/auth0_domains.html) - Manage custom domains - [auth0 email](https://auth0.github.io/auth0-cli/auth0_email.html) - Manage email settings - [auth0 flows](https://auth0.github.io/auth0-cli/auth0_flows.html) - Manage Flows +- [auth0 guardian](https://auth0.github.io/auth0-cli/auth0_guardian.html) - Manage multi-factor authentication (Guardian) - [auth0 login](https://auth0.github.io/auth0-cli/auth0_login.html) - Authenticate the Auth0 CLI - [auth0 logout](https://auth0.github.io/auth0-cli/auth0_logout.html) - Log out of a tenant's session - [auth0 logs](https://auth0.github.io/auth0-cli/auth0_logs.html) - View tenant logs diff --git a/docs/auth0_guardian.md b/docs/auth0_guardian.md new file mode 100644 index 000000000..732546bbf --- /dev/null +++ b/docs/auth0_guardian.md @@ -0,0 +1,14 @@ +--- +layout: default +has_toc: false +--- +# auth0 guardian + +Manage Auth0 multi-factor authentication (MFA), also known as Guardian. Configure MFA policies, factors and their providers, and manage user enrollments. + +## Commands + +- [auth0 guardian enrollments](auth0_guardian_enrollments.md) - Manage multi-factor authentication enrollments +- [auth0 guardian factors](auth0_guardian_factors.md) - Manage multi-factor authentication factors +- [auth0 guardian policies](auth0_guardian_policies.md) - Manage multi-factor authentication policies + diff --git a/docs/auth0_guardian_enrollments.md b/docs/auth0_guardian_enrollments.md new file mode 100644 index 000000000..04f757179 --- /dev/null +++ b/docs/auth0_guardian_enrollments.md @@ -0,0 +1,15 @@ +--- +layout: default +has_toc: false +has_children: true +--- +# auth0 guardian enrollments + +Manage user multi-factor authentication (MFA) enrollments and enrollment tickets. + +## Commands + +- [auth0 guardian enrollments create-ticket](auth0_guardian_enrollments_create-ticket.md) - Create a multi-factor authentication enrollment ticket +- [auth0 guardian enrollments delete](auth0_guardian_enrollments_delete.md) - Delete a multi-factor authentication enrollment +- [auth0 guardian enrollments show](auth0_guardian_enrollments_show.md) - Show a multi-factor authentication enrollment + diff --git a/docs/auth0_guardian_enrollments_create-ticket.md b/docs/auth0_guardian_enrollments_create-ticket.md new file mode 100644 index 000000000..182d5a326 --- /dev/null +++ b/docs/auth0_guardian_enrollments_create-ticket.md @@ -0,0 +1,58 @@ +--- +layout: default +parent: auth0 guardian enrollments +has_toc: false +--- +# auth0 guardian enrollments create-ticket + +Create an MFA enrollment ticket for a user and, optionally, email it to them. + +The returned ticket URL is the link the user follows to enroll. + +## Usage +``` +auth0 guardian enrollments create-ticket [flags] +``` + +## Examples + +``` + auth0 guardian enrollments create-ticket --user-id "auth0|123" + auth0 guardian enrollments create-ticket --user-id "auth0|123" --factor push-notification + auth0 guardian enrollments create-ticket --user-id "auth0|123" --send-email --email me@example.com + auth0 guardian enrollments create-ticket --user-id "auth0|123" --allow-multiple --json +``` + + +## Flags + +``` + --allow-multiple Allow a user who has previously enrolled in MFA to enroll with additional factors. Universal Login only. + --email string Alternate email address to send the enrollment email to. Defaults to the user's email. + --email-locale string Locale of the enrollment email. Used with --send-email. + -f, --factor string Factor the user must enroll with, e.g. push-notification, sms, email, otp, webauthn-roaming, webauthn-platform, recovery-code, duo. + --json Output in json format. + --json-compact Output in compact json format. + --send-email Send an email to the user to start the enrollment. + -u, --user-id string User ID to create the enrollment ticket for. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian enrollments create-ticket](auth0_guardian_enrollments_create-ticket.md) - Create a multi-factor authentication enrollment ticket +- [auth0 guardian enrollments delete](auth0_guardian_enrollments_delete.md) - Delete a multi-factor authentication enrollment +- [auth0 guardian enrollments show](auth0_guardian_enrollments_show.md) - Show a multi-factor authentication enrollment + + diff --git a/docs/auth0_guardian_enrollments_delete.md b/docs/auth0_guardian_enrollments_delete.md new file mode 100644 index 000000000..85a35957d --- /dev/null +++ b/docs/auth0_guardian_enrollments_delete.md @@ -0,0 +1,53 @@ +--- +layout: default +parent: auth0 guardian enrollments +has_toc: false +--- +# auth0 guardian enrollments delete + +Delete an MFA enrollment, allowing the user to re-enroll. + +To delete interactively, use `auth0 guardian enrollments delete` with no arguments. + +To delete non-interactively, supply the enrollment id and the `--force` flag to skip confirmation. + +## Usage +``` +auth0 guardian enrollments delete [flags] +``` + +## Examples + +``` + auth0 guardian enrollments delete + auth0 guardian enrollments rm + auth0 guardian enrollments delete + auth0 guardian enrollments delete --force +``` + + +## Flags + +``` + --force Skip confirmation. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian enrollments create-ticket](auth0_guardian_enrollments_create-ticket.md) - Create a multi-factor authentication enrollment ticket +- [auth0 guardian enrollments delete](auth0_guardian_enrollments_delete.md) - Delete a multi-factor authentication enrollment +- [auth0 guardian enrollments show](auth0_guardian_enrollments_show.md) - Show a multi-factor authentication enrollment + + diff --git a/docs/auth0_guardian_enrollments_show.md b/docs/auth0_guardian_enrollments_show.md new file mode 100644 index 000000000..771d4eb96 --- /dev/null +++ b/docs/auth0_guardian_enrollments_show.md @@ -0,0 +1,48 @@ +--- +layout: default +parent: auth0 guardian enrollments +has_toc: false +--- +# auth0 guardian enrollments show + +Display the status, type and details of an MFA enrollment. + +## Usage +``` +auth0 guardian enrollments show [flags] +``` + +## Examples + +``` + auth0 guardian enrollments show + auth0 guardian enrollments show --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian enrollments create-ticket](auth0_guardian_enrollments_create-ticket.md) - Create a multi-factor authentication enrollment ticket +- [auth0 guardian enrollments delete](auth0_guardian_enrollments_delete.md) - Delete a multi-factor authentication enrollment +- [auth0 guardian enrollments show](auth0_guardian_enrollments_show.md) - Show a multi-factor authentication enrollment + + diff --git a/docs/auth0_guardian_factors.md b/docs/auth0_guardian_factors.md new file mode 100644 index 000000000..581074156 --- /dev/null +++ b/docs/auth0_guardian_factors.md @@ -0,0 +1,18 @@ +--- +layout: default +has_toc: false +has_children: true +--- +# auth0 guardian factors + +Manage multi-factor authentication (MFA) factors and their providers. + +## Commands + +- [auth0 guardian factors duo](auth0_guardian_factors_duo.md) - Manage the Duo multi-factor authentication factor +- [auth0 guardian factors list](auth0_guardian_factors_list.md) - List multi-factor authentication factors +- [auth0 guardian factors phone](auth0_guardian_factors_phone.md) - Manage the phone multi-factor authentication factor +- [auth0 guardian factors push](auth0_guardian_factors_push.md) - Manage the push-notification multi-factor authentication factor +- [auth0 guardian factors set](auth0_guardian_factors_set.md) - Enable or disable a multi-factor authentication factor +- [auth0 guardian factors sms](auth0_guardian_factors_sms.md) - Manage the SMS multi-factor authentication factor (legacy) + diff --git a/docs/auth0_guardian_factors_duo.md b/docs/auth0_guardian_factors_duo.md new file mode 100644 index 000000000..c9c64aa98 --- /dev/null +++ b/docs/auth0_guardian_factors_duo.md @@ -0,0 +1,12 @@ +--- +layout: default +has_toc: false +--- +# auth0 guardian factors duo + +Manage the Duo MFA factor settings. + +## Commands + +- [auth0 guardian factors duo settings](auth0_guardian_factors_duo_settings.md) - Manage the Duo settings + diff --git a/docs/auth0_guardian_factors_duo_settings.md b/docs/auth0_guardian_factors_duo_settings.md new file mode 100644 index 000000000..79ba778eb --- /dev/null +++ b/docs/auth0_guardian_factors_duo_settings.md @@ -0,0 +1,15 @@ +--- +layout: default +has_toc: false +has_children: true +--- +# auth0 guardian factors duo settings + +Manage the Duo MFA factor settings. + +## Commands + +- [auth0 guardian factors duo settings set](auth0_guardian_factors_duo_settings_set.md) - Set the Duo settings +- [auth0 guardian factors duo settings show](auth0_guardian_factors_duo_settings_show.md) - Show the Duo settings +- [auth0 guardian factors duo settings update](auth0_guardian_factors_duo_settings_update.md) - Update the Duo settings + diff --git a/docs/auth0_guardian_factors_duo_settings_set.md b/docs/auth0_guardian_factors_duo_settings_set.md new file mode 100644 index 000000000..ab99e99fc --- /dev/null +++ b/docs/auth0_guardian_factors_duo_settings_set.md @@ -0,0 +1,50 @@ +--- +layout: default +parent: auth0 guardian factors duo settings +has_toc: false +--- +# auth0 guardian factors duo settings set + +Replace the Duo MFA factor settings. This overwrites all Duo settings, so the host, integration key and secret key are all required. To change a single field without clearing the others, use `auth0 guardian factors duo settings update` instead. + +## Usage +``` +auth0 guardian factors duo settings set [flags] +``` + +## Examples + +``` + auth0 guardian factors duo settings set --ikey --skey --host api-xxxx.duosecurity.com +``` + + +## Flags + +``` + --host string Duo API hostname. + --ikey string Duo integration key. + --json Output in json format. + --json-compact Output in compact json format. + --skey string Duo secret key. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors duo settings set](auth0_guardian_factors_duo_settings_set.md) - Set the Duo settings +- [auth0 guardian factors duo settings show](auth0_guardian_factors_duo_settings_show.md) - Show the Duo settings +- [auth0 guardian factors duo settings update](auth0_guardian_factors_duo_settings_update.md) - Update the Duo settings + + diff --git a/docs/auth0_guardian_factors_duo_settings_show.md b/docs/auth0_guardian_factors_duo_settings_show.md new file mode 100644 index 000000000..2e8d1c423 --- /dev/null +++ b/docs/auth0_guardian_factors_duo_settings_show.md @@ -0,0 +1,47 @@ +--- +layout: default +parent: auth0 guardian factors duo settings +has_toc: false +--- +# auth0 guardian factors duo settings show + +Display the Duo MFA factor settings. + +## Usage +``` +auth0 guardian factors duo settings show [flags] +``` + +## Examples + +``` + auth0 guardian factors duo settings show --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors duo settings set](auth0_guardian_factors_duo_settings_set.md) - Set the Duo settings +- [auth0 guardian factors duo settings show](auth0_guardian_factors_duo_settings_show.md) - Show the Duo settings +- [auth0 guardian factors duo settings update](auth0_guardian_factors_duo_settings_update.md) - Update the Duo settings + + diff --git a/docs/auth0_guardian_factors_duo_settings_update.md b/docs/auth0_guardian_factors_duo_settings_update.md new file mode 100644 index 000000000..9e77643b4 --- /dev/null +++ b/docs/auth0_guardian_factors_duo_settings_update.md @@ -0,0 +1,50 @@ +--- +layout: default +parent: auth0 guardian factors duo settings +has_toc: false +--- +# auth0 guardian factors duo settings update + +Partially update the Duo MFA factor settings. Only the fields you provide are changed; the rest keep their current values. Run without flags to be prompted for each field, pre-filled with the current value (leave the secret key blank to keep it unchanged). + +## Usage +``` +auth0 guardian factors duo settings update [flags] +``` + +## Examples + +``` + auth0 guardian factors duo settings update --host api-xxxx.duosecurity.com +``` + + +## Flags + +``` + --host string Duo API hostname. + --ikey string Duo integration key. + --json Output in json format. + --json-compact Output in compact json format. + --skey string Duo secret key. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors duo settings set](auth0_guardian_factors_duo_settings_set.md) - Set the Duo settings +- [auth0 guardian factors duo settings show](auth0_guardian_factors_duo_settings_show.md) - Show the Duo settings +- [auth0 guardian factors duo settings update](auth0_guardian_factors_duo_settings_update.md) - Update the Duo settings + + diff --git a/docs/auth0_guardian_factors_list.md b/docs/auth0_guardian_factors_list.md new file mode 100644 index 000000000..b6c768d9f --- /dev/null +++ b/docs/auth0_guardian_factors_list.md @@ -0,0 +1,52 @@ +--- +layout: default +parent: auth0 guardian factors +has_toc: false +--- +# auth0 guardian factors list + +List all MFA factors and their enabled/disabled status. + +## Usage +``` +auth0 guardian factors list [flags] +``` + +## Examples + +``` + auth0 guardian factors list + auth0 guardian factors ls + auth0 guardian factors list --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors duo](auth0_guardian_factors_duo.md) - Manage the Duo multi-factor authentication factor +- [auth0 guardian factors list](auth0_guardian_factors_list.md) - List multi-factor authentication factors +- [auth0 guardian factors phone](auth0_guardian_factors_phone.md) - Manage the phone multi-factor authentication factor +- [auth0 guardian factors push](auth0_guardian_factors_push.md) - Manage the push-notification multi-factor authentication factor +- [auth0 guardian factors set](auth0_guardian_factors_set.md) - Enable or disable a multi-factor authentication factor +- [auth0 guardian factors sms](auth0_guardian_factors_sms.md) - Manage the SMS multi-factor authentication factor (legacy) + + diff --git a/docs/auth0_guardian_factors_phone.md b/docs/auth0_guardian_factors_phone.md new file mode 100644 index 000000000..bf1eb9050 --- /dev/null +++ b/docs/auth0_guardian_factors_phone.md @@ -0,0 +1,20 @@ +--- +layout: default +has_toc: false +has_children: true +--- +# auth0 guardian factors phone + +Manage the phone MFA factor provider, message types and templates. + +## Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + diff --git a/docs/auth0_guardian_factors_phone_set-message-types.md b/docs/auth0_guardian_factors_phone_set-message-types.md new file mode 100644 index 000000000..d868fd766 --- /dev/null +++ b/docs/auth0_guardian_factors_phone_set-message-types.md @@ -0,0 +1,54 @@ +--- +layout: default +parent: auth0 guardian factors phone +has_toc: false +--- +# auth0 guardian factors phone set-message-types + +Set the enabled phone message types. Supported values: sms, voice. + +## Usage +``` +auth0 guardian factors phone set-message-types [flags] +``` + +## Examples + +``` + auth0 guardian factors phone set-message-types --message-type sms --message-type voice + auth0 guardian factors phone set-message-types --message-type sms --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + --message-type strings Message type to enable. Repeat the flag for multiple types. Supported values: sms, voice. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_phone_set-provider.md b/docs/auth0_guardian_factors_phone_set-provider.md new file mode 100644 index 000000000..48af6d655 --- /dev/null +++ b/docs/auth0_guardian_factors_phone_set-provider.md @@ -0,0 +1,56 @@ +--- +layout: default +parent: auth0 guardian factors phone +has_toc: false +--- +# auth0 guardian factors phone set-provider + +Set the phone MFA provider. One of: auth0, twilio, phone-message-hook. + +This is a legacy endpoint. Tenants on the unified phone experience must manage phone delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors phone set-provider [flags] +``` + +## Examples + +``` + auth0 guardian factors phone set-provider --provider twilio + auth0 guardian factors phone set-provider --provider auth0 --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + -p, --provider string Provider to use for the factor. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_phone_set-templates.md b/docs/auth0_guardian_factors_phone_set-templates.md new file mode 100644 index 000000000..59f129e81 --- /dev/null +++ b/docs/auth0_guardian_factors_phone_set-templates.md @@ -0,0 +1,58 @@ +--- +layout: default +parent: auth0 guardian factors phone +has_toc: false +--- +# auth0 guardian factors phone set-templates + +Set the phone enrollment and verification message templates. + +This is a legacy endpoint. Tenants on the unified phone experience must manage phone templates from the Dashboard (Branding > Phone Templates); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors phone set-templates [flags] +``` + +## Examples + +``` + auth0 guardian factors phone set-templates \ + --enrollment-message "Your verification code is {{code}}" \ + --verification-message "Your verification code is {{code}}" +``` + + +## Flags + +``` + --enrollment-message string Message sent to the user when they enroll. + --json Output in json format. + --json-compact Output in compact json format. + --verification-message string Message sent to the user when they verify. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_phone_set-twilio.md b/docs/auth0_guardian_factors_phone_set-twilio.md new file mode 100644 index 000000000..29836bb86 --- /dev/null +++ b/docs/auth0_guardian_factors_phone_set-twilio.md @@ -0,0 +1,59 @@ +--- +layout: default +parent: auth0 guardian factors phone +has_toc: false +--- +# auth0 guardian factors phone set-twilio + +Set the Twilio configuration for the phone MFA factor. + +This is a legacy endpoint. Tenants on the unified phone experience must manage phone delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors phone set-twilio [flags] +``` + +## Examples + +``` + auth0 guardian factors phone set-twilio --sid AC... --auth-token --from "+14155550100" + auth0 guardian factors phone set-twilio --sid AC... --auth-token --messaging-service-sid MG... +``` + + +## Flags + +``` + --auth-token string Twilio authentication token. + --from string Twilio 'from' phone number. + --json Output in json format. + --json-compact Output in compact json format. + --messaging-service-sid string Twilio messaging service SID. + --sid string Twilio account SID. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_phone_show-message-types.md b/docs/auth0_guardian_factors_phone_show-message-types.md new file mode 100644 index 000000000..1420b7275 --- /dev/null +++ b/docs/auth0_guardian_factors_phone_show-message-types.md @@ -0,0 +1,52 @@ +--- +layout: default +parent: auth0 guardian factors phone +has_toc: false +--- +# auth0 guardian factors phone show-message-types + +Display the enabled phone message types (sms, voice). + +## Usage +``` +auth0 guardian factors phone show-message-types [flags] +``` + +## Examples + +``` + auth0 guardian factors phone show-message-types --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_phone_show-provider.md b/docs/auth0_guardian_factors_phone_show-provider.md new file mode 100644 index 000000000..d93a93a40 --- /dev/null +++ b/docs/auth0_guardian_factors_phone_show-provider.md @@ -0,0 +1,55 @@ +--- +layout: default +parent: auth0 guardian factors phone +has_toc: false +--- +# auth0 guardian factors phone show-provider + +Display the configured phone MFA provider. + +This is a legacy endpoint. Tenants on the unified phone experience must manage phone delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors phone show-provider [flags] +``` + +## Examples + +``` + auth0 guardian factors phone show-provider + auth0 guardian factors phone show-provider --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_phone_show-templates.md b/docs/auth0_guardian_factors_phone_show-templates.md new file mode 100644 index 000000000..03554d47a --- /dev/null +++ b/docs/auth0_guardian_factors_phone_show-templates.md @@ -0,0 +1,54 @@ +--- +layout: default +parent: auth0 guardian factors phone +has_toc: false +--- +# auth0 guardian factors phone show-templates + +Display the phone enrollment and verification message templates. + +This is a legacy endpoint. Tenants on the unified phone experience must manage phone templates from the Dashboard (Branding > Phone Templates); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors phone show-templates [flags] +``` + +## Examples + +``` + auth0 guardian factors phone show-templates --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_phone_show-twilio.md b/docs/auth0_guardian_factors_phone_show-twilio.md new file mode 100644 index 000000000..7575a666f --- /dev/null +++ b/docs/auth0_guardian_factors_phone_show-twilio.md @@ -0,0 +1,54 @@ +--- +layout: default +parent: auth0 guardian factors phone +has_toc: false +--- +# auth0 guardian factors phone show-twilio + +Display the Twilio configuration for the phone MFA factor. + +This is a legacy endpoint. Tenants on the unified phone experience must manage phone delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors phone show-twilio [flags] +``` + +## Examples + +``` + auth0 guardian factors phone show-twilio --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors phone set-message-types](auth0_guardian_factors_phone_set-message-types.md) - Set the phone message types +- [auth0 guardian factors phone set-provider](auth0_guardian_factors_phone_set-provider.md) - Set the phone provider (legacy) +- [auth0 guardian factors phone set-templates](auth0_guardian_factors_phone_set-templates.md) - Set the phone templates (legacy) +- [auth0 guardian factors phone set-twilio](auth0_guardian_factors_phone_set-twilio.md) - Set the phone Twilio configuration (legacy) +- [auth0 guardian factors phone show-message-types](auth0_guardian_factors_phone_show-message-types.md) - Show the phone message types +- [auth0 guardian factors phone show-provider](auth0_guardian_factors_phone_show-provider.md) - Show the phone provider (legacy) +- [auth0 guardian factors phone show-templates](auth0_guardian_factors_phone_show-templates.md) - Show the phone templates (legacy) +- [auth0 guardian factors phone show-twilio](auth0_guardian_factors_phone_show-twilio.md) - Show the phone Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_push.md b/docs/auth0_guardian_factors_push.md new file mode 100644 index 000000000..f64843845 --- /dev/null +++ b/docs/auth0_guardian_factors_push.md @@ -0,0 +1,24 @@ +--- +layout: default +has_toc: false +has_children: true +--- +# auth0 guardian factors push + +Manage the push-notification MFA factor provider and its APNs, FCM, FCM v1 and SNS configuration. + +## Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + diff --git a/docs/auth0_guardian_factors_push_set-apns.md b/docs/auth0_guardian_factors_push_set-apns.md new file mode 100644 index 000000000..884f8a797 --- /dev/null +++ b/docs/auth0_guardian_factors_push_set-apns.md @@ -0,0 +1,59 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push set-apns + +Replace the Apple Push Notification service (APNs) configuration. + +## Usage +``` +auth0 guardian factors push set-apns [flags] +``` + +## Examples + +``` + auth0 guardian factors push set-apns --bundle-id com.example.app --sandbox --p12 +``` + + +## Flags + +``` + --bundle-id string Apple app bundle identifier. + --json Output in json format. + --json-compact Output in compact json format. + --p12 string Base64-encoded .p12 certificate for APNs. + --sandbox Whether to use the APNs sandbox environment. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_set-fcm.md b/docs/auth0_guardian_factors_push_set-fcm.md new file mode 100644 index 000000000..5b519411b --- /dev/null +++ b/docs/auth0_guardian_factors_push_set-fcm.md @@ -0,0 +1,57 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push set-fcm + +Replace the Google FCM (legacy) push-notification configuration. + +## Usage +``` +auth0 guardian factors push set-fcm [flags] +``` + +## Examples + +``` + auth0 guardian factors push set-fcm --server-key +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + --server-key string Google FCM (legacy) server key. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_set-fcmv1.md b/docs/auth0_guardian_factors_push_set-fcmv1.md new file mode 100644 index 000000000..f52b4b339 --- /dev/null +++ b/docs/auth0_guardian_factors_push_set-fcmv1.md @@ -0,0 +1,57 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push set-fcmv1 + +Replace the Google FCM v1 push-notification configuration. + +## Usage +``` +auth0 guardian factors push set-fcmv1 [flags] +``` + +## Examples + +``` + auth0 guardian factors push set-fcmv1 --server-credentials "$(cat service-account.json)" +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + --server-credentials string Google FCM v1 service account credentials (JSON). +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_set-provider.md b/docs/auth0_guardian_factors_push_set-provider.md new file mode 100644 index 000000000..7a294ecd0 --- /dev/null +++ b/docs/auth0_guardian_factors_push_set-provider.md @@ -0,0 +1,58 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push set-provider + +Set the push-notification MFA provider. One of: guardian, sns, direct. + +## Usage +``` +auth0 guardian factors push set-provider [flags] +``` + +## Examples + +``` + auth0 guardian factors push set-provider --provider guardian + auth0 guardian factors push set-provider --provider sns --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + -p, --provider string Provider to use for the factor. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_set-sns.md b/docs/auth0_guardian_factors_push_set-sns.md new file mode 100644 index 000000000..87bc1504a --- /dev/null +++ b/docs/auth0_guardian_factors_push_set-sns.md @@ -0,0 +1,63 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push set-sns + +Replace the Amazon SNS push-notification configuration. + +## Usage +``` +auth0 guardian factors push set-sns [flags] +``` + +## Examples + +``` + auth0 guardian factors push set-sns \ + --aws-access-key-id --aws-secret-access-key --aws-region us-east-1 \ + --apns-platform-arn --gcm-platform-arn +``` + + +## Flags + +``` + --apns-platform-arn string SNS APNs platform application ARN. + --aws-access-key-id string AWS access key ID for SNS. + --aws-region string AWS region for SNS. + --aws-secret-access-key string AWS secret access key for SNS. + --gcm-platform-arn string SNS GCM platform application ARN. + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_show-apns.md b/docs/auth0_guardian_factors_push_show-apns.md new file mode 100644 index 000000000..b0f7e3524 --- /dev/null +++ b/docs/auth0_guardian_factors_push_show-apns.md @@ -0,0 +1,56 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push show-apns + +Display the Apple Push Notification service (APNs) configuration. + +## Usage +``` +auth0 guardian factors push show-apns [flags] +``` + +## Examples + +``` + auth0 guardian factors push show-apns --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_show-provider.md b/docs/auth0_guardian_factors_push_show-provider.md new file mode 100644 index 000000000..1808ae64b --- /dev/null +++ b/docs/auth0_guardian_factors_push_show-provider.md @@ -0,0 +1,56 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push show-provider + +Display the configured push-notification MFA provider. + +## Usage +``` +auth0 guardian factors push show-provider [flags] +``` + +## Examples + +``` + auth0 guardian factors push show-provider --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_show-sns.md b/docs/auth0_guardian_factors_push_show-sns.md new file mode 100644 index 000000000..64742cec1 --- /dev/null +++ b/docs/auth0_guardian_factors_push_show-sns.md @@ -0,0 +1,56 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push show-sns + +Display the Amazon SNS push-notification configuration. + +## Usage +``` +auth0 guardian factors push show-sns [flags] +``` + +## Examples + +``` + auth0 guardian factors push show-sns --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_update-apns.md b/docs/auth0_guardian_factors_push_update-apns.md new file mode 100644 index 000000000..759cbdf4c --- /dev/null +++ b/docs/auth0_guardian_factors_push_update-apns.md @@ -0,0 +1,59 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push update-apns + +Partially update the Apple Push Notification service (APNs) configuration. Only the fields you provide are changed; the rest keep their current values. Run without flags to be prompted for each field, pre-filled with the current value (leave the .p12 blank to keep it unchanged). + +## Usage +``` +auth0 guardian factors push update-apns [flags] +``` + +## Examples + +``` + auth0 guardian factors push update-apns --sandbox +``` + + +## Flags + +``` + --bundle-id string Apple app bundle identifier. + --json Output in json format. + --json-compact Output in compact json format. + --p12 string Base64-encoded .p12 certificate for APNs. + --sandbox Whether to use the APNs sandbox environment. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_update-fcm.md b/docs/auth0_guardian_factors_push_update-fcm.md new file mode 100644 index 000000000..12d38ddf5 --- /dev/null +++ b/docs/auth0_guardian_factors_push_update-fcm.md @@ -0,0 +1,57 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push update-fcm + +Partially update the Google FCM (legacy) push-notification configuration. + +## Usage +``` +auth0 guardian factors push update-fcm [flags] +``` + +## Examples + +``` + auth0 guardian factors push update-fcm --server-key +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + --server-key string Google FCM (legacy) server key. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_update-fcmv1.md b/docs/auth0_guardian_factors_push_update-fcmv1.md new file mode 100644 index 000000000..a6fe671f4 --- /dev/null +++ b/docs/auth0_guardian_factors_push_update-fcmv1.md @@ -0,0 +1,57 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push update-fcmv1 + +Partially update the Google FCM v1 push-notification configuration. + +## Usage +``` +auth0 guardian factors push update-fcmv1 [flags] +``` + +## Examples + +``` + auth0 guardian factors push update-fcmv1 --server-credentials "$(cat service-account.json)" +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + --server-credentials string Google FCM v1 service account credentials (JSON). +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_push_update-sns.md b/docs/auth0_guardian_factors_push_update-sns.md new file mode 100644 index 000000000..5aab68b0d --- /dev/null +++ b/docs/auth0_guardian_factors_push_update-sns.md @@ -0,0 +1,61 @@ +--- +layout: default +parent: auth0 guardian factors push +has_toc: false +--- +# auth0 guardian factors push update-sns + +Partially update the Amazon SNS push-notification configuration. Only the fields you provide are changed; the rest keep their current values. Run without flags to be prompted for each field, pre-filled with the current value (leave the secret access key blank to keep it unchanged). + +## Usage +``` +auth0 guardian factors push update-sns [flags] +``` + +## Examples + +``` + auth0 guardian factors push update-sns --aws-region us-west-2 +``` + + +## Flags + +``` + --apns-platform-arn string SNS APNs platform application ARN. + --aws-access-key-id string AWS access key ID for SNS. + --aws-region string AWS region for SNS. + --aws-secret-access-key string AWS secret access key for SNS. + --gcm-platform-arn string SNS GCM platform application ARN. + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors push set-apns](auth0_guardian_factors_push_set-apns.md) - Set the APNs configuration +- [auth0 guardian factors push set-fcm](auth0_guardian_factors_push_set-fcm.md) - Set the FCM (legacy) configuration +- [auth0 guardian factors push set-fcmv1](auth0_guardian_factors_push_set-fcmv1.md) - Set the FCM v1 configuration +- [auth0 guardian factors push set-provider](auth0_guardian_factors_push_set-provider.md) - Set the push-notification provider +- [auth0 guardian factors push set-sns](auth0_guardian_factors_push_set-sns.md) - Set the SNS configuration +- [auth0 guardian factors push show-apns](auth0_guardian_factors_push_show-apns.md) - Show the APNs configuration +- [auth0 guardian factors push show-provider](auth0_guardian_factors_push_show-provider.md) - Show the push-notification provider +- [auth0 guardian factors push show-sns](auth0_guardian_factors_push_show-sns.md) - Show the SNS configuration +- [auth0 guardian factors push update-apns](auth0_guardian_factors_push_update-apns.md) - Update the APNs configuration +- [auth0 guardian factors push update-fcm](auth0_guardian_factors_push_update-fcm.md) - Update the FCM (legacy) configuration +- [auth0 guardian factors push update-fcmv1](auth0_guardian_factors_push_update-fcmv1.md) - Update the FCM v1 configuration +- [auth0 guardian factors push update-sns](auth0_guardian_factors_push_update-sns.md) - Update the SNS configuration + + diff --git a/docs/auth0_guardian_factors_set.md b/docs/auth0_guardian_factors_set.md new file mode 100644 index 000000000..be4ad3ad5 --- /dev/null +++ b/docs/auth0_guardian_factors_set.md @@ -0,0 +1,53 @@ +--- +layout: default +parent: auth0 guardian factors +has_toc: false +--- +# auth0 guardian factors set + +Enable or disable a single MFA factor. + +## Usage +``` +auth0 guardian factors set [flags] +``` + +## Examples + +``` + auth0 guardian factors set sms --enabled + auth0 guardian factors set email --enabled=false + auth0 guardian factors set push-notification --enabled --json +``` + + +## Flags + +``` + --enabled Whether the factor is enabled. + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors duo](auth0_guardian_factors_duo.md) - Manage the Duo multi-factor authentication factor +- [auth0 guardian factors list](auth0_guardian_factors_list.md) - List multi-factor authentication factors +- [auth0 guardian factors phone](auth0_guardian_factors_phone.md) - Manage the phone multi-factor authentication factor +- [auth0 guardian factors push](auth0_guardian_factors_push.md) - Manage the push-notification multi-factor authentication factor +- [auth0 guardian factors set](auth0_guardian_factors_set.md) - Enable or disable a multi-factor authentication factor +- [auth0 guardian factors sms](auth0_guardian_factors_sms.md) - Manage the SMS multi-factor authentication factor (legacy) + + diff --git a/docs/auth0_guardian_factors_sms.md b/docs/auth0_guardian_factors_sms.md new file mode 100644 index 000000000..bb74ded9d --- /dev/null +++ b/docs/auth0_guardian_factors_sms.md @@ -0,0 +1,20 @@ +--- +layout: default +has_toc: false +has_children: true +--- +# auth0 guardian factors sms + +Manage the SMS MFA factor provider, templates and Twilio configuration. + +These are legacy endpoints. Tenants on the unified phone experience must manage SMS delivery from the Dashboard (Branding > Phone Provider); they are not available to Management API tokens. + +## Commands + +- [auth0 guardian factors sms set-provider](auth0_guardian_factors_sms_set-provider.md) - Set the SMS provider (legacy) +- [auth0 guardian factors sms set-templates](auth0_guardian_factors_sms_set-templates.md) - Set the SMS templates (legacy) +- [auth0 guardian factors sms set-twilio](auth0_guardian_factors_sms_set-twilio.md) - Set the SMS Twilio configuration (legacy) +- [auth0 guardian factors sms show-provider](auth0_guardian_factors_sms_show-provider.md) - Show the SMS provider (legacy) +- [auth0 guardian factors sms show-templates](auth0_guardian_factors_sms_show-templates.md) - Show the SMS templates (legacy) +- [auth0 guardian factors sms show-twilio](auth0_guardian_factors_sms_show-twilio.md) - Show the SMS Twilio configuration (legacy) + diff --git a/docs/auth0_guardian_factors_sms_set-provider.md b/docs/auth0_guardian_factors_sms_set-provider.md new file mode 100644 index 000000000..c5a48208f --- /dev/null +++ b/docs/auth0_guardian_factors_sms_set-provider.md @@ -0,0 +1,54 @@ +--- +layout: default +parent: auth0 guardian factors sms +has_toc: false +--- +# auth0 guardian factors sms set-provider + +Set the SMS MFA provider. One of: auth0, twilio, phone-message-hook. + +This is a legacy endpoint. Tenants on the unified phone experience must manage SMS delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors sms set-provider [flags] +``` + +## Examples + +``` + auth0 guardian factors sms set-provider --provider twilio + auth0 guardian factors sms set-provider --provider auth0 --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + -p, --provider string Provider to use for the factor. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors sms set-provider](auth0_guardian_factors_sms_set-provider.md) - Set the SMS provider (legacy) +- [auth0 guardian factors sms set-templates](auth0_guardian_factors_sms_set-templates.md) - Set the SMS templates (legacy) +- [auth0 guardian factors sms set-twilio](auth0_guardian_factors_sms_set-twilio.md) - Set the SMS Twilio configuration (legacy) +- [auth0 guardian factors sms show-provider](auth0_guardian_factors_sms_show-provider.md) - Show the SMS provider (legacy) +- [auth0 guardian factors sms show-templates](auth0_guardian_factors_sms_show-templates.md) - Show the SMS templates (legacy) +- [auth0 guardian factors sms show-twilio](auth0_guardian_factors_sms_show-twilio.md) - Show the SMS Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_sms_set-templates.md b/docs/auth0_guardian_factors_sms_set-templates.md new file mode 100644 index 000000000..e160b3f46 --- /dev/null +++ b/docs/auth0_guardian_factors_sms_set-templates.md @@ -0,0 +1,56 @@ +--- +layout: default +parent: auth0 guardian factors sms +has_toc: false +--- +# auth0 guardian factors sms set-templates + +Set the SMS enrollment and verification message templates. + +This is a legacy endpoint. Tenants on the unified phone experience must manage SMS templates from the Dashboard (Branding > Phone Templates); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors sms set-templates [flags] +``` + +## Examples + +``` + auth0 guardian factors sms set-templates \ + --enrollment-message "Your verification code is {{code}}" \ + --verification-message "Your verification code is {{code}}" +``` + + +## Flags + +``` + --enrollment-message string Message sent to the user when they enroll. + --json Output in json format. + --json-compact Output in compact json format. + --verification-message string Message sent to the user when they verify. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors sms set-provider](auth0_guardian_factors_sms_set-provider.md) - Set the SMS provider (legacy) +- [auth0 guardian factors sms set-templates](auth0_guardian_factors_sms_set-templates.md) - Set the SMS templates (legacy) +- [auth0 guardian factors sms set-twilio](auth0_guardian_factors_sms_set-twilio.md) - Set the SMS Twilio configuration (legacy) +- [auth0 guardian factors sms show-provider](auth0_guardian_factors_sms_show-provider.md) - Show the SMS provider (legacy) +- [auth0 guardian factors sms show-templates](auth0_guardian_factors_sms_show-templates.md) - Show the SMS templates (legacy) +- [auth0 guardian factors sms show-twilio](auth0_guardian_factors_sms_show-twilio.md) - Show the SMS Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_sms_set-twilio.md b/docs/auth0_guardian_factors_sms_set-twilio.md new file mode 100644 index 000000000..b0e9e7fd0 --- /dev/null +++ b/docs/auth0_guardian_factors_sms_set-twilio.md @@ -0,0 +1,57 @@ +--- +layout: default +parent: auth0 guardian factors sms +has_toc: false +--- +# auth0 guardian factors sms set-twilio + +Set the Twilio configuration for the SMS MFA factor. + +This is a legacy endpoint. Tenants on the unified phone experience must manage SMS delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors sms set-twilio [flags] +``` + +## Examples + +``` + auth0 guardian factors sms set-twilio --sid AC... --auth-token --from "+14155550100" + auth0 guardian factors sms set-twilio --sid AC... --auth-token --messaging-service-sid MG... +``` + + +## Flags + +``` + --auth-token string Twilio authentication token. + --from string Twilio 'from' phone number. + --json Output in json format. + --json-compact Output in compact json format. + --messaging-service-sid string Twilio messaging service SID. + --sid string Twilio account SID. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors sms set-provider](auth0_guardian_factors_sms_set-provider.md) - Set the SMS provider (legacy) +- [auth0 guardian factors sms set-templates](auth0_guardian_factors_sms_set-templates.md) - Set the SMS templates (legacy) +- [auth0 guardian factors sms set-twilio](auth0_guardian_factors_sms_set-twilio.md) - Set the SMS Twilio configuration (legacy) +- [auth0 guardian factors sms show-provider](auth0_guardian_factors_sms_show-provider.md) - Show the SMS provider (legacy) +- [auth0 guardian factors sms show-templates](auth0_guardian_factors_sms_show-templates.md) - Show the SMS templates (legacy) +- [auth0 guardian factors sms show-twilio](auth0_guardian_factors_sms_show-twilio.md) - Show the SMS Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_sms_show-provider.md b/docs/auth0_guardian_factors_sms_show-provider.md new file mode 100644 index 000000000..1c20828bf --- /dev/null +++ b/docs/auth0_guardian_factors_sms_show-provider.md @@ -0,0 +1,52 @@ +--- +layout: default +parent: auth0 guardian factors sms +has_toc: false +--- +# auth0 guardian factors sms show-provider + +Display the configured SMS MFA provider. + +This is a legacy endpoint. Tenants on the unified phone experience must manage SMS delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors sms show-provider [flags] +``` + +## Examples + +``` + auth0 guardian factors sms show-provider --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors sms set-provider](auth0_guardian_factors_sms_set-provider.md) - Set the SMS provider (legacy) +- [auth0 guardian factors sms set-templates](auth0_guardian_factors_sms_set-templates.md) - Set the SMS templates (legacy) +- [auth0 guardian factors sms set-twilio](auth0_guardian_factors_sms_set-twilio.md) - Set the SMS Twilio configuration (legacy) +- [auth0 guardian factors sms show-provider](auth0_guardian_factors_sms_show-provider.md) - Show the SMS provider (legacy) +- [auth0 guardian factors sms show-templates](auth0_guardian_factors_sms_show-templates.md) - Show the SMS templates (legacy) +- [auth0 guardian factors sms show-twilio](auth0_guardian_factors_sms_show-twilio.md) - Show the SMS Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_sms_show-templates.md b/docs/auth0_guardian_factors_sms_show-templates.md new file mode 100644 index 000000000..83689cd03 --- /dev/null +++ b/docs/auth0_guardian_factors_sms_show-templates.md @@ -0,0 +1,52 @@ +--- +layout: default +parent: auth0 guardian factors sms +has_toc: false +--- +# auth0 guardian factors sms show-templates + +Display the SMS enrollment and verification message templates. + +This is a legacy endpoint. Tenants on the unified phone experience must manage SMS templates from the Dashboard (Branding > Phone Templates); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors sms show-templates [flags] +``` + +## Examples + +``` + auth0 guardian factors sms show-templates --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors sms set-provider](auth0_guardian_factors_sms_set-provider.md) - Set the SMS provider (legacy) +- [auth0 guardian factors sms set-templates](auth0_guardian_factors_sms_set-templates.md) - Set the SMS templates (legacy) +- [auth0 guardian factors sms set-twilio](auth0_guardian_factors_sms_set-twilio.md) - Set the SMS Twilio configuration (legacy) +- [auth0 guardian factors sms show-provider](auth0_guardian_factors_sms_show-provider.md) - Show the SMS provider (legacy) +- [auth0 guardian factors sms show-templates](auth0_guardian_factors_sms_show-templates.md) - Show the SMS templates (legacy) +- [auth0 guardian factors sms show-twilio](auth0_guardian_factors_sms_show-twilio.md) - Show the SMS Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_factors_sms_show-twilio.md b/docs/auth0_guardian_factors_sms_show-twilio.md new file mode 100644 index 000000000..aae5f99f2 --- /dev/null +++ b/docs/auth0_guardian_factors_sms_show-twilio.md @@ -0,0 +1,52 @@ +--- +layout: default +parent: auth0 guardian factors sms +has_toc: false +--- +# auth0 guardian factors sms show-twilio + +Display the Twilio configuration for the SMS MFA factor. + +This is a legacy endpoint. Tenants on the unified phone experience must manage SMS delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens. + +## Usage +``` +auth0 guardian factors sms show-twilio [flags] +``` + +## Examples + +``` + auth0 guardian factors sms show-twilio --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian factors sms set-provider](auth0_guardian_factors_sms_set-provider.md) - Set the SMS provider (legacy) +- [auth0 guardian factors sms set-templates](auth0_guardian_factors_sms_set-templates.md) - Set the SMS templates (legacy) +- [auth0 guardian factors sms set-twilio](auth0_guardian_factors_sms_set-twilio.md) - Set the SMS Twilio configuration (legacy) +- [auth0 guardian factors sms show-provider](auth0_guardian_factors_sms_show-provider.md) - Show the SMS provider (legacy) +- [auth0 guardian factors sms show-templates](auth0_guardian_factors_sms_show-templates.md) - Show the SMS templates (legacy) +- [auth0 guardian factors sms show-twilio](auth0_guardian_factors_sms_show-twilio.md) - Show the SMS Twilio configuration (legacy) + + diff --git a/docs/auth0_guardian_policies.md b/docs/auth0_guardian_policies.md new file mode 100644 index 000000000..ee6062bf4 --- /dev/null +++ b/docs/auth0_guardian_policies.md @@ -0,0 +1,14 @@ +--- +layout: default +has_toc: false +has_children: true +--- +# auth0 guardian policies + +Manage the tenant-wide multi-factor authentication (MFA) policies. + +## Commands + +- [auth0 guardian policies set](auth0_guardian_policies_set.md) - Set the multi-factor authentication policy +- [auth0 guardian policies show](auth0_guardian_policies_show.md) - Show the multi-factor authentication policies + diff --git a/docs/auth0_guardian_policies_set.md b/docs/auth0_guardian_policies_set.md new file mode 100644 index 000000000..d0adb7178 --- /dev/null +++ b/docs/auth0_guardian_policies_set.md @@ -0,0 +1,54 @@ +--- +layout: default +parent: auth0 guardian policies +has_toc: false +--- +# auth0 guardian policies set + +Set the tenant-wide multi-factor authentication (MFA) policy. + +The policies are mutually exclusive, so this sets a single policy and replaces the existing one. Pass `--policy none` or `--none` (or select none interactively) to clear the policy. + +## Usage +``` +auth0 guardian policies set [flags] +``` + +## Examples + +``` + auth0 guardian policies set + auth0 guardian policies set --policy all-applications + auth0 guardian policies set --policy confidence-score + auth0 guardian policies set --none + auth0 guardian policies set --policy all-applications --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. + --none Clear all MFA policies. + -p, --policy string MFA policy to enable. Supported values: all-applications, confidence-score. The policies are mutually exclusive; pass none (or --none) to clear all policies. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian policies set](auth0_guardian_policies_set.md) - Set the multi-factor authentication policy +- [auth0 guardian policies show](auth0_guardian_policies_show.md) - Show the multi-factor authentication policies + + diff --git a/docs/auth0_guardian_policies_show.md b/docs/auth0_guardian_policies_show.md new file mode 100644 index 000000000..e2700aa46 --- /dev/null +++ b/docs/auth0_guardian_policies_show.md @@ -0,0 +1,47 @@ +--- +layout: default +parent: auth0 guardian policies +has_toc: false +--- +# auth0 guardian policies show + +Display the tenant-wide multi-factor authentication (MFA) policies. + +## Usage +``` +auth0 guardian policies show [flags] +``` + +## Examples + +``` + auth0 guardian policies show + auth0 guardian policies show --json +``` + + +## Flags + +``` + --json Output in json format. + --json-compact Output in compact json format. +``` + + +## Inherited Flags + +``` + --agent-mode Output JSON, disable prompts and colors. Auto-enabled for AI agents; set AUTH0_AGENT_MODE=false to disable. + --debug Enable debug mode. + --no-color Disable colors. + --no-input Disable interactivity. + --tenant string Specific tenant to use. +``` + + +## Related Commands + +- [auth0 guardian policies set](auth0_guardian_policies_set.md) - Set the multi-factor authentication policy +- [auth0 guardian policies show](auth0_guardian_policies_show.md) - Show the multi-factor authentication policies + + diff --git a/docs/index.md b/docs/index.md index c08e6ed14..c043fc40e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -98,6 +98,7 @@ The help for any command can also be emitted as JSON by combining `--help` with - [auth0 email](auth0_email.md) - Manage email settings and configure email providers - [auth0 event-streams](auth0_event-streams.md) - Manage Event Stream - [auth0 flows](auth0_flows.md) - Manage Flows +- [auth0 guardian](auth0_guardian.md) - Manage multi-factor authentication (Guardian) - [auth0 login](auth0_login.md) - Authenticate the Auth0 CLI - [auth0 logout](auth0_logout.md) - Log out of a tenant's session - [auth0 logs](auth0_logs.md) - View tenant logs diff --git a/go.mod b/go.mod index 4f4547e3d..23aa338d9 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/PuerkitoBio/rehttp v1.4.0 github.com/atotto/clipboard v0.1.4 github.com/auth0/go-auth0 v1.48.0 - github.com/auth0/go-auth0/v3 v3.3.0 + github.com/auth0/go-auth0/v3 v3.4.0 github.com/briandowns/spinner v1.23.2 github.com/charmbracelet/glamour v1.0.0 github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e diff --git a/go.sum b/go.sum index 4bb856a6c..de7743e3b 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/auth0/go-auth0 v1.48.0 h1:INqEEZbDEkXVI0xUZluS1zzoB4YbYzvCysHH2CNEGzc= github.com/auth0/go-auth0 v1.48.0/go.mod h1:32sQB1uAn+99fJo6N819EniKq8h785p0ag0lMWhiTaE= -github.com/auth0/go-auth0/v3 v3.3.0 h1:p/OxyycZNUtFekO6uXGBqrVXtnJ92gO7ikXtVDuT0ZA= -github.com/auth0/go-auth0/v3 v3.3.0/go.mod h1:wb20iE6T4wCGWtMXAZTWTTxx1/T1aHfVK+dOWleQvlg= +github.com/auth0/go-auth0/v3 v3.4.0 h1:CjdnuuDUcVG19BIT7bloEYtyQHpIYr6rwQI2d1Wz7Fk= +github.com/auth0/go-auth0/v3 v3.4.0/go.mod h1:MGifkH9wfgGbWsgFPrz2QbM2wLmScH1kGgIvAtd65Xw= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0 h1:0NmehRCgyk5rljDQLKUO+cRJCnduDyn11+zGZIc9Z48= github.com/aybabtme/iocontrol v0.0.0-20150809002002-ad15bcfc95a0/go.mod h1:6L7zgvqo0idzI7IO8de6ZC051AfXb5ipkIJ7bIA2tGA= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 87c24ce7d..20b4d53e8 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -152,6 +152,9 @@ var RequiredScopes = []string{ "read:organization_discovery_domains", "read:self_service_profiles", "read:user_attribute_profiles", "read:sessions", "update:sessions", "delete:sessions", "read:refresh_tokens", "update:refresh_tokens", "delete:refresh_tokens", + "read:guardian_factors", "update:guardian_factors", + "read:guardian_enrollments", "delete:guardian_enrollments", "create:guardian_enrollment_tickets", + "read:mfa_policies", "update:mfa_policies", } // GetDeviceCode kicks-off the device authentication flow by requesting diff --git a/internal/auth/scopes_test.go b/internal/auth/scopes_test.go index b35e0bd39..eec2494f5 100644 --- a/internal/auth/scopes_test.go +++ b/internal/auth/scopes_test.go @@ -45,6 +45,9 @@ func TestRequiredScopes(t *testing.T) { "read:attack_protection", "update:attack_protection", "read:sessions", "update:sessions", "delete:sessions", "read:refresh_tokens", "update:refresh_tokens", "delete:refresh_tokens", + "read:guardian_factors", "update:guardian_factors", + "read:guardian_enrollments", "delete:guardian_enrollments", "create:guardian_enrollment_tickets", + "read:mfa_policies", "update:mfa_policies", } for _, v := range list { diff --git a/internal/auth0/auth0.go b/internal/auth0/auth0.go index de30fc442..2c87d077e 100644 --- a/internal/auth0/auth0.go +++ b/internal/auth0/auth0.go @@ -90,6 +90,13 @@ type APIV3 struct { UserRefreshToken UserRefreshTokenAPIV3 ActionModule ActionModuleAPIV3 ActionModuleVersion ActionModuleVersionAPIV3 + GuardianPolicy GuardianPolicyAPIV3 + GuardianEnrollment GuardianEnrollmentAPIV3 + GuardianFactor GuardianFactorAPIV3 + GuardianFactorPhone GuardianFactorPhoneAPIV3 + GuardianFactorSms GuardianFactorSmsAPIV3 + GuardianFactorPush GuardianFactorPushAPIV3 + GuardianFactorDuo GuardianFactorDuoAPIV3 } func NewAPIV3(m *managementv3.Management) *APIV3 { @@ -108,6 +115,13 @@ func NewAPIV3(m *managementv3.Management) *APIV3 { UserRefreshToken: m.Users.RefreshToken, ActionModule: m.Actions.Modules, ActionModuleVersion: m.Actions.Modules.Versions, + GuardianPolicy: m.Guardian.Policies, + GuardianEnrollment: m.Guardian.Enrollments, + GuardianFactor: m.Guardian.Factors, + GuardianFactorPhone: m.Guardian.Factors.Phone, + GuardianFactorSms: m.Guardian.Factors.Sms, + GuardianFactorPush: m.Guardian.Factors.PushNotification, + GuardianFactorDuo: m.Guardian.Factors.Duo.Settings, } } diff --git a/internal/auth0/guardian_enrollment.go b/internal/auth0/guardian_enrollment.go new file mode 100644 index 000000000..c5dcd3d6f --- /dev/null +++ b/internal/auth0/guardian_enrollment.go @@ -0,0 +1,30 @@ +//go:generate mockgen -source=guardian_enrollment.go -destination=mock/guardian_enrollment_mock.go -package=mock + +package auth0 + +import ( + "context" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/auth0/go-auth0/v3/management/option" +) + +// GuardianEnrollmentAPIV3 is the V3 SDK interface for multi-factor +// authentication (MFA) enrollments (/guardian/enrollments). +type GuardianEnrollmentAPIV3 interface { + // CreateTicket creates an MFA enrollment ticket for a user and, optionally, + // emails it to them. + // + // Required scope: `create:guardian_enrollment_tickets`. + CreateTicket(ctx context.Context, request *managementv3.CreateGuardianEnrollmentTicketRequestContent, opts ...option.RequestOption) (*managementv3.CreateGuardianEnrollmentTicketResponseContent, error) + + // Get retrieves details for a single MFA enrollment by ID. + // + // Required scope: `read:guardian_enrollments`. + Get(ctx context.Context, id string, opts ...option.RequestOption) (*managementv3.GetGuardianEnrollmentResponseContent, error) + + // Delete removes a single MFA enrollment, allowing the user to re-enroll. + // + // Required scope: `delete:guardian_enrollments`. + Delete(ctx context.Context, id string, opts ...option.RequestOption) error +} diff --git a/internal/auth0/guardian_factor.go b/internal/auth0/guardian_factor.go new file mode 100644 index 000000000..3352fcb3b --- /dev/null +++ b/internal/auth0/guardian_factor.go @@ -0,0 +1,24 @@ +//go:generate mockgen -source=guardian_factor.go -destination=mock/guardian_factor_mock.go -package=mock + +package auth0 + +import ( + "context" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/auth0/go-auth0/v3/management/option" +) + +// GuardianFactorAPIV3 is the V3 SDK interface for enabling and disabling +// multi-factor authentication (MFA) factors (/guardian/factors). +type GuardianFactorAPIV3 interface { + // List retrieves all MFA factors and their enabled/disabled status. + // + // Required scope: `read:guardian_factors`. + List(ctx context.Context, opts ...option.RequestOption) ([]*managementv3.GuardianFactor, error) + + // Set enables or disables a single MFA factor. + // + // Required scope: `update:guardian_factors`. + Set(ctx context.Context, name *managementv3.GuardianFactorNameEnum, request *managementv3.SetGuardianFactorRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorResponseContent, error) +} diff --git a/internal/auth0/guardian_factor_duo.go b/internal/auth0/guardian_factor_duo.go new file mode 100644 index 000000000..71a15382a --- /dev/null +++ b/internal/auth0/guardian_factor_duo.go @@ -0,0 +1,26 @@ +//go:generate mockgen -source=guardian_factor_duo.go -destination=mock/guardian_factor_duo_mock.go -package=mock + +package auth0 + +import ( + "context" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/auth0/go-auth0/v3/management/option" +) + +// GuardianFactorDuoAPIV3 is the V3 SDK interface for the Duo MFA factor +// settings (/guardian/factors/duo/settings). +// +// Required scopes: `read:guardian_factors` for reads, `update:guardian_factors` +// for writes. +type GuardianFactorDuoAPIV3 interface { + // Get retrieves the Duo settings. + Get(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorDuoSettingsResponseContent, error) + + // Set replaces the Duo settings. + Set(ctx context.Context, request *managementv3.SetGuardianFactorDuoSettingsRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorDuoSettingsResponseContent, error) + + // Update partially updates the Duo settings. + Update(ctx context.Context, request *managementv3.UpdateGuardianFactorDuoSettingsRequestContent, opts ...option.RequestOption) (*managementv3.UpdateGuardianFactorDuoSettingsResponseContent, error) +} diff --git a/internal/auth0/guardian_factor_phone.go b/internal/auth0/guardian_factor_phone.go new file mode 100644 index 000000000..aa2e67bdc --- /dev/null +++ b/internal/auth0/guardian_factor_phone.go @@ -0,0 +1,41 @@ +//go:generate mockgen -source=guardian_factor_phone.go -destination=mock/guardian_factor_phone_mock.go -package=mock + +package auth0 + +import ( + "context" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/auth0/go-auth0/v3/management/option" +) + +// GuardianFactorPhoneAPIV3 is the V3 SDK interface for the phone MFA factor +// configuration (/guardian/factors/phone). +// +// Required scopes: `read:guardian_factors` for reads, `update:guardian_factors` +// for writes. +type GuardianFactorPhoneAPIV3 interface { + // GetSelectedProvider retrieves the configured phone provider. + GetSelectedProvider(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorsProviderPhoneResponseContent, error) + + // SetProvider sets the phone provider. + SetProvider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderPhoneRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorsProviderPhoneResponseContent, error) + + // GetMessageTypes retrieves the enabled phone message types (sms/voice). + GetMessageTypes(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorPhoneMessageTypesResponseContent, error) + + // SetMessageTypes sets the enabled phone message types (sms/voice). + SetMessageTypes(ctx context.Context, request *managementv3.SetGuardianFactorPhoneMessageTypesRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorPhoneMessageTypesResponseContent, error) + + // GetTemplates retrieves the phone enrollment and verification templates. + GetTemplates(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorPhoneTemplatesResponseContent, error) + + // SetTemplates sets the phone enrollment and verification templates. + SetTemplates(ctx context.Context, request *managementv3.SetGuardianFactorPhoneTemplatesRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorPhoneTemplatesResponseContent, error) + + // GetTwilioProvider retrieves the Twilio configuration for the phone factor. + GetTwilioProvider(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorsProviderPhoneTwilioResponseContent, error) + + // SetTwilioProvider sets the Twilio configuration for the phone factor. + SetTwilioProvider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderPhoneTwilioRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorsProviderPhoneTwilioResponseContent, error) +} diff --git a/internal/auth0/guardian_factor_push.go b/internal/auth0/guardian_factor_push.go new file mode 100644 index 000000000..9cfe5dcfe --- /dev/null +++ b/internal/auth0/guardian_factor_push.go @@ -0,0 +1,54 @@ +//go:generate mockgen -source=guardian_factor_push.go -destination=mock/guardian_factor_push_mock.go -package=mock + +package auth0 + +import ( + "context" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/auth0/go-auth0/v3/management/option" +) + +// GuardianFactorPushAPIV3 is the V3 SDK interface for the push-notification MFA +// factor configuration (/guardian/factors/push-notification), including its +// APNs, FCM, FCM v1 and SNS providers. +// +// Required scopes: `read:guardian_factors` for reads, `update:guardian_factors` +// for writes. +type GuardianFactorPushAPIV3 interface { + // GetSelectedProvider retrieves the configured push-notification provider. + GetSelectedProvider(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorsProviderPushNotificationResponseContent, error) + + // SetProvider sets the push-notification provider. + SetProvider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderPushNotificationRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorsProviderPushNotificationResponseContent, error) + + // GetApnsProvider retrieves the Apple APNs configuration. + GetApnsProvider(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorsProviderApnsResponseContent, error) + + // SetApnsProvider replaces the Apple APNs configuration. + SetApnsProvider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderPushNotificationApnsRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorsProviderPushNotificationApnsResponseContent, error) + + // UpdateApnsProvider partially updates the Apple APNs configuration. + UpdateApnsProvider(ctx context.Context, request *managementv3.UpdateGuardianFactorsProviderPushNotificationApnsRequestContent, opts ...option.RequestOption) (*managementv3.UpdateGuardianFactorsProviderPushNotificationApnsResponseContent, error) + + // SetFcmProvider replaces the Google FCM (legacy) configuration. + SetFcmProvider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderPushNotificationFcmRequestContent, opts ...option.RequestOption) (managementv3.SetGuardianFactorsProviderPushNotificationFcmResponseContent, error) + + // UpdateFcmProvider partially updates the Google FCM (legacy) configuration. + UpdateFcmProvider(ctx context.Context, request *managementv3.UpdateGuardianFactorsProviderPushNotificationFcmRequestContent, opts ...option.RequestOption) (managementv3.UpdateGuardianFactorsProviderPushNotificationFcmResponseContent, error) + + // SetFcmv1Provider replaces the Google FCM v1 configuration. + SetFcmv1Provider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderPushNotificationFcmv1RequestContent, opts ...option.RequestOption) (managementv3.SetGuardianFactorsProviderPushNotificationFcmv1ResponseContent, error) + + // UpdateFcmv1Provider partially updates the Google FCM v1 configuration. + UpdateFcmv1Provider(ctx context.Context, request *managementv3.UpdateGuardianFactorsProviderPushNotificationFcmv1RequestContent, opts ...option.RequestOption) (managementv3.UpdateGuardianFactorsProviderPushNotificationFcmv1ResponseContent, error) + + // GetSnsProvider retrieves the Amazon SNS configuration. + GetSnsProvider(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorsProviderSnsResponseContent, error) + + // SetSnsProvider replaces the Amazon SNS configuration. + SetSnsProvider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderPushNotificationSnsRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorsProviderPushNotificationSnsResponseContent, error) + + // UpdateSnsProvider partially updates the Amazon SNS configuration. + UpdateSnsProvider(ctx context.Context, request *managementv3.UpdateGuardianFactorsProviderPushNotificationSnsRequestContent, opts ...option.RequestOption) (*managementv3.UpdateGuardianFactorsProviderPushNotificationSnsResponseContent, error) +} diff --git a/internal/auth0/guardian_factor_sms.go b/internal/auth0/guardian_factor_sms.go new file mode 100644 index 000000000..139369e57 --- /dev/null +++ b/internal/auth0/guardian_factor_sms.go @@ -0,0 +1,35 @@ +//go:generate mockgen -source=guardian_factor_sms.go -destination=mock/guardian_factor_sms_mock.go -package=mock + +package auth0 + +import ( + "context" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/auth0/go-auth0/v3/management/option" +) + +// GuardianFactorSmsAPIV3 is the V3 SDK interface for the SMS MFA factor +// configuration (/guardian/factors/sms). +// +// Required scopes: `read:guardian_factors` for reads, `update:guardian_factors` +// for writes. +type GuardianFactorSmsAPIV3 interface { + // GetSelectedProvider retrieves the configured SMS provider. + GetSelectedProvider(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorsProviderSmsResponseContent, error) + + // SetProvider sets the SMS provider. + SetProvider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderSmsRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorsProviderSmsResponseContent, error) + + // GetTemplates retrieves the SMS enrollment and verification templates. + GetTemplates(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorSmsTemplatesResponseContent, error) + + // SetTemplates sets the SMS enrollment and verification templates. + SetTemplates(ctx context.Context, request *managementv3.SetGuardianFactorSmsTemplatesRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorSmsTemplatesResponseContent, error) + + // GetTwilioProvider retrieves the Twilio configuration for the SMS factor. + GetTwilioProvider(ctx context.Context, opts ...option.RequestOption) (*managementv3.GetGuardianFactorsProviderSmsTwilioResponseContent, error) + + // SetTwilioProvider sets the Twilio configuration for the SMS factor. + SetTwilioProvider(ctx context.Context, request *managementv3.SetGuardianFactorsProviderSmsTwilioRequestContent, opts ...option.RequestOption) (*managementv3.SetGuardianFactorsProviderSmsTwilioResponseContent, error) +} diff --git a/internal/auth0/guardian_policy.go b/internal/auth0/guardian_policy.go new file mode 100644 index 000000000..de12fa3ba --- /dev/null +++ b/internal/auth0/guardian_policy.go @@ -0,0 +1,24 @@ +//go:generate mockgen -source=guardian_policy.go -destination=mock/guardian_policy_mock.go -package=mock + +package auth0 + +import ( + "context" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/auth0/go-auth0/v3/management/option" +) + +// GuardianPolicyAPIV3 is the V3 SDK interface for the tenant-wide multi-factor +// authentication (MFA) policies endpoint (/guardian/policies). +type GuardianPolicyAPIV3 interface { + // List retrieves the MFA policies configured for the tenant. + // + // Required scope: `read:mfa_policies`. + List(ctx context.Context, opts ...option.RequestOption) (managementv3.ListGuardianPoliciesResponseContent, error) + + // Set replaces the MFA policies configured for the tenant. + // + // Required scope: `update:mfa_policies`. + Set(ctx context.Context, request managementv3.SetGuardianPoliciesRequestContent, opts ...option.RequestOption) (managementv3.SetGuardianPoliciesResponseContent, error) +} diff --git a/internal/auth0/mock/flow_v3_mock.go b/internal/auth0/mock/flow_v3_mock.go new file mode 100644 index 000000000..13751f05c --- /dev/null +++ b/internal/auth0/mock/flow_v3_mock.go @@ -0,0 +1,201 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: flow_v3.go + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + reflect "reflect" + + auth0 "github.com/auth0/auth0-cli/internal/auth0" + management "github.com/auth0/go-auth0/v3/management" + option "github.com/auth0/go-auth0/v3/management/option" + gomock "github.com/golang/mock/gomock" +) + +// MockFlowAPIV3 is a mock of FlowAPIV3 interface. +type MockFlowAPIV3 struct { + ctrl *gomock.Controller + recorder *MockFlowAPIV3MockRecorder +} + +// MockFlowAPIV3MockRecorder is the mock recorder for MockFlowAPIV3. +type MockFlowAPIV3MockRecorder struct { + mock *MockFlowAPIV3 +} + +// NewMockFlowAPIV3 creates a new mock instance. +func NewMockFlowAPIV3(ctrl *gomock.Controller) *MockFlowAPIV3 { + mock := &MockFlowAPIV3{ctrl: ctrl} + mock.recorder = &MockFlowAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockFlowAPIV3) EXPECT() *MockFlowAPIV3MockRecorder { + return m.recorder +} + +// Delete mocks base method. +func (m *MockFlowAPIV3) Delete(ctx context.Context, id string, opts ...option.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockFlowAPIV3MockRecorder) Delete(ctx, id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockFlowAPIV3)(nil).Delete), varargs...) +} + +// List mocks base method. +func (m *MockFlowAPIV3) List(ctx context.Context, request *management.ListFlowsRequestParameters, opts ...option.RequestOption) (*auth0.FlowSummaryPage, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].(*auth0.FlowSummaryPage) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockFlowAPIV3MockRecorder) List(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockFlowAPIV3)(nil).List), varargs...) +} + +// MockFlowExecutionAPIV3 is a mock of FlowExecutionAPIV3 interface. +type MockFlowExecutionAPIV3 struct { + ctrl *gomock.Controller + recorder *MockFlowExecutionAPIV3MockRecorder +} + +// MockFlowExecutionAPIV3MockRecorder is the mock recorder for MockFlowExecutionAPIV3. +type MockFlowExecutionAPIV3MockRecorder struct { + mock *MockFlowExecutionAPIV3 +} + +// NewMockFlowExecutionAPIV3 creates a new mock instance. +func NewMockFlowExecutionAPIV3(ctrl *gomock.Controller) *MockFlowExecutionAPIV3 { + mock := &MockFlowExecutionAPIV3{ctrl: ctrl} + mock.recorder = &MockFlowExecutionAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockFlowExecutionAPIV3) EXPECT() *MockFlowExecutionAPIV3MockRecorder { + return m.recorder +} + +// Delete mocks base method. +func (m *MockFlowExecutionAPIV3) Delete(ctx context.Context, flowID, executionID string, opts ...option.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, flowID, executionID} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockFlowExecutionAPIV3MockRecorder) Delete(ctx, flowID, executionID interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, flowID, executionID}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockFlowExecutionAPIV3)(nil).Delete), varargs...) +} + +// List mocks base method. +func (m *MockFlowExecutionAPIV3) List(ctx context.Context, flowID string, request *management.ListFlowExecutionsRequestParameters, opts ...option.RequestOption) (*auth0.FlowExecutionSummaryPage, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, flowID, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].(*auth0.FlowExecutionSummaryPage) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockFlowExecutionAPIV3MockRecorder) List(ctx, flowID, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, flowID, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockFlowExecutionAPIV3)(nil).List), varargs...) +} + +// MockFlowVaultConnectionAPIV3 is a mock of FlowVaultConnectionAPIV3 interface. +type MockFlowVaultConnectionAPIV3 struct { + ctrl *gomock.Controller + recorder *MockFlowVaultConnectionAPIV3MockRecorder +} + +// MockFlowVaultConnectionAPIV3MockRecorder is the mock recorder for MockFlowVaultConnectionAPIV3. +type MockFlowVaultConnectionAPIV3MockRecorder struct { + mock *MockFlowVaultConnectionAPIV3 +} + +// NewMockFlowVaultConnectionAPIV3 creates a new mock instance. +func NewMockFlowVaultConnectionAPIV3(ctrl *gomock.Controller) *MockFlowVaultConnectionAPIV3 { + mock := &MockFlowVaultConnectionAPIV3{ctrl: ctrl} + mock.recorder = &MockFlowVaultConnectionAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockFlowVaultConnectionAPIV3) EXPECT() *MockFlowVaultConnectionAPIV3MockRecorder { + return m.recorder +} + +// Delete mocks base method. +func (m *MockFlowVaultConnectionAPIV3) Delete(ctx context.Context, id string, opts ...option.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockFlowVaultConnectionAPIV3MockRecorder) Delete(ctx, id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockFlowVaultConnectionAPIV3)(nil).Delete), varargs...) +} + +// List mocks base method. +func (m *MockFlowVaultConnectionAPIV3) List(ctx context.Context, request *management.ListFlowsVaultConnectionsRequestParameters, opts ...option.RequestOption) (*auth0.FlowsVaultConnectionSummaryPage, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].(*auth0.FlowsVaultConnectionSummaryPage) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockFlowVaultConnectionAPIV3MockRecorder) List(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockFlowVaultConnectionAPIV3)(nil).List), varargs...) +} diff --git a/internal/auth0/mock/guardian_enrollment_mock.go b/internal/auth0/mock/guardian_enrollment_mock.go new file mode 100644 index 000000000..32fb38c75 --- /dev/null +++ b/internal/auth0/mock/guardian_enrollment_mock.go @@ -0,0 +1,96 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: guardian_enrollment.go + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + reflect "reflect" + + management "github.com/auth0/go-auth0/v3/management" + option "github.com/auth0/go-auth0/v3/management/option" + gomock "github.com/golang/mock/gomock" +) + +// MockGuardianEnrollmentAPIV3 is a mock of GuardianEnrollmentAPIV3 interface. +type MockGuardianEnrollmentAPIV3 struct { + ctrl *gomock.Controller + recorder *MockGuardianEnrollmentAPIV3MockRecorder +} + +// MockGuardianEnrollmentAPIV3MockRecorder is the mock recorder for MockGuardianEnrollmentAPIV3. +type MockGuardianEnrollmentAPIV3MockRecorder struct { + mock *MockGuardianEnrollmentAPIV3 +} + +// NewMockGuardianEnrollmentAPIV3 creates a new mock instance. +func NewMockGuardianEnrollmentAPIV3(ctrl *gomock.Controller) *MockGuardianEnrollmentAPIV3 { + mock := &MockGuardianEnrollmentAPIV3{ctrl: ctrl} + mock.recorder = &MockGuardianEnrollmentAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGuardianEnrollmentAPIV3) EXPECT() *MockGuardianEnrollmentAPIV3MockRecorder { + return m.recorder +} + +// CreateTicket mocks base method. +func (m *MockGuardianEnrollmentAPIV3) CreateTicket(ctx context.Context, request *management.CreateGuardianEnrollmentTicketRequestContent, opts ...option.RequestOption) (*management.CreateGuardianEnrollmentTicketResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CreateTicket", varargs...) + ret0, _ := ret[0].(*management.CreateGuardianEnrollmentTicketResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateTicket indicates an expected call of CreateTicket. +func (mr *MockGuardianEnrollmentAPIV3MockRecorder) CreateTicket(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTicket", reflect.TypeOf((*MockGuardianEnrollmentAPIV3)(nil).CreateTicket), varargs...) +} + +// Delete mocks base method. +func (m *MockGuardianEnrollmentAPIV3) Delete(ctx context.Context, id string, opts ...option.RequestOption) error { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Delete", varargs...) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockGuardianEnrollmentAPIV3MockRecorder) Delete(ctx, id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockGuardianEnrollmentAPIV3)(nil).Delete), varargs...) +} + +// Get mocks base method. +func (m *MockGuardianEnrollmentAPIV3) Get(ctx context.Context, id string, opts ...option.RequestOption) (*management.GetGuardianEnrollmentResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, id} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Get", varargs...) + ret0, _ := ret[0].(*management.GetGuardianEnrollmentResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get. +func (mr *MockGuardianEnrollmentAPIV3MockRecorder) Get(ctx, id interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, id}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockGuardianEnrollmentAPIV3)(nil).Get), varargs...) +} diff --git a/internal/auth0/mock/guardian_factor_duo_mock.go b/internal/auth0/mock/guardian_factor_duo_mock.go new file mode 100644 index 000000000..78b6c6fa2 --- /dev/null +++ b/internal/auth0/mock/guardian_factor_duo_mock.go @@ -0,0 +1,97 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: guardian_factor_duo.go + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + reflect "reflect" + + management "github.com/auth0/go-auth0/v3/management" + option "github.com/auth0/go-auth0/v3/management/option" + gomock "github.com/golang/mock/gomock" +) + +// MockGuardianFactorDuoAPIV3 is a mock of GuardianFactorDuoAPIV3 interface. +type MockGuardianFactorDuoAPIV3 struct { + ctrl *gomock.Controller + recorder *MockGuardianFactorDuoAPIV3MockRecorder +} + +// MockGuardianFactorDuoAPIV3MockRecorder is the mock recorder for MockGuardianFactorDuoAPIV3. +type MockGuardianFactorDuoAPIV3MockRecorder struct { + mock *MockGuardianFactorDuoAPIV3 +} + +// NewMockGuardianFactorDuoAPIV3 creates a new mock instance. +func NewMockGuardianFactorDuoAPIV3(ctrl *gomock.Controller) *MockGuardianFactorDuoAPIV3 { + mock := &MockGuardianFactorDuoAPIV3{ctrl: ctrl} + mock.recorder = &MockGuardianFactorDuoAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGuardianFactorDuoAPIV3) EXPECT() *MockGuardianFactorDuoAPIV3MockRecorder { + return m.recorder +} + +// Get mocks base method. +func (m *MockGuardianFactorDuoAPIV3) Get(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorDuoSettingsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Get", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorDuoSettingsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get. +func (mr *MockGuardianFactorDuoAPIV3MockRecorder) Get(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockGuardianFactorDuoAPIV3)(nil).Get), varargs...) +} + +// Set mocks base method. +func (m *MockGuardianFactorDuoAPIV3) Set(ctx context.Context, request *management.SetGuardianFactorDuoSettingsRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorDuoSettingsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Set", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorDuoSettingsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Set indicates an expected call of Set. +func (mr *MockGuardianFactorDuoAPIV3MockRecorder) Set(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockGuardianFactorDuoAPIV3)(nil).Set), varargs...) +} + +// Update mocks base method. +func (m *MockGuardianFactorDuoAPIV3) Update(ctx context.Context, request *management.UpdateGuardianFactorDuoSettingsRequestContent, opts ...option.RequestOption) (*management.UpdateGuardianFactorDuoSettingsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Update", varargs...) + ret0, _ := ret[0].(*management.UpdateGuardianFactorDuoSettingsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Update indicates an expected call of Update. +func (mr *MockGuardianFactorDuoAPIV3MockRecorder) Update(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockGuardianFactorDuoAPIV3)(nil).Update), varargs...) +} diff --git a/internal/auth0/mock/guardian_factor_mock.go b/internal/auth0/mock/guardian_factor_mock.go new file mode 100644 index 000000000..a37fb5cb2 --- /dev/null +++ b/internal/auth0/mock/guardian_factor_mock.go @@ -0,0 +1,77 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: guardian_factor.go + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + reflect "reflect" + + management "github.com/auth0/go-auth0/v3/management" + option "github.com/auth0/go-auth0/v3/management/option" + gomock "github.com/golang/mock/gomock" +) + +// MockGuardianFactorAPIV3 is a mock of GuardianFactorAPIV3 interface. +type MockGuardianFactorAPIV3 struct { + ctrl *gomock.Controller + recorder *MockGuardianFactorAPIV3MockRecorder +} + +// MockGuardianFactorAPIV3MockRecorder is the mock recorder for MockGuardianFactorAPIV3. +type MockGuardianFactorAPIV3MockRecorder struct { + mock *MockGuardianFactorAPIV3 +} + +// NewMockGuardianFactorAPIV3 creates a new mock instance. +func NewMockGuardianFactorAPIV3(ctrl *gomock.Controller) *MockGuardianFactorAPIV3 { + mock := &MockGuardianFactorAPIV3{ctrl: ctrl} + mock.recorder = &MockGuardianFactorAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGuardianFactorAPIV3) EXPECT() *MockGuardianFactorAPIV3MockRecorder { + return m.recorder +} + +// List mocks base method. +func (m *MockGuardianFactorAPIV3) List(ctx context.Context, opts ...option.RequestOption) ([]*management.GuardianFactor, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].([]*management.GuardianFactor) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockGuardianFactorAPIV3MockRecorder) List(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockGuardianFactorAPIV3)(nil).List), varargs...) +} + +// Set mocks base method. +func (m *MockGuardianFactorAPIV3) Set(ctx context.Context, name *management.GuardianFactorNameEnum, request *management.SetGuardianFactorRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, name, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Set", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Set indicates an expected call of Set. +func (mr *MockGuardianFactorAPIV3MockRecorder) Set(ctx, name, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, name, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockGuardianFactorAPIV3)(nil).Set), varargs...) +} diff --git a/internal/auth0/mock/guardian_factor_phone_mock.go b/internal/auth0/mock/guardian_factor_phone_mock.go new file mode 100644 index 000000000..e7c479e71 --- /dev/null +++ b/internal/auth0/mock/guardian_factor_phone_mock.go @@ -0,0 +1,197 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: guardian_factor_phone.go + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + reflect "reflect" + + management "github.com/auth0/go-auth0/v3/management" + option "github.com/auth0/go-auth0/v3/management/option" + gomock "github.com/golang/mock/gomock" +) + +// MockGuardianFactorPhoneAPIV3 is a mock of GuardianFactorPhoneAPIV3 interface. +type MockGuardianFactorPhoneAPIV3 struct { + ctrl *gomock.Controller + recorder *MockGuardianFactorPhoneAPIV3MockRecorder +} + +// MockGuardianFactorPhoneAPIV3MockRecorder is the mock recorder for MockGuardianFactorPhoneAPIV3. +type MockGuardianFactorPhoneAPIV3MockRecorder struct { + mock *MockGuardianFactorPhoneAPIV3 +} + +// NewMockGuardianFactorPhoneAPIV3 creates a new mock instance. +func NewMockGuardianFactorPhoneAPIV3(ctrl *gomock.Controller) *MockGuardianFactorPhoneAPIV3 { + mock := &MockGuardianFactorPhoneAPIV3{ctrl: ctrl} + mock.recorder = &MockGuardianFactorPhoneAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGuardianFactorPhoneAPIV3) EXPECT() *MockGuardianFactorPhoneAPIV3MockRecorder { + return m.recorder +} + +// GetMessageTypes mocks base method. +func (m *MockGuardianFactorPhoneAPIV3) GetMessageTypes(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorPhoneMessageTypesResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetMessageTypes", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorPhoneMessageTypesResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetMessageTypes indicates an expected call of GetMessageTypes. +func (mr *MockGuardianFactorPhoneAPIV3MockRecorder) GetMessageTypes(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMessageTypes", reflect.TypeOf((*MockGuardianFactorPhoneAPIV3)(nil).GetMessageTypes), varargs...) +} + +// GetSelectedProvider mocks base method. +func (m *MockGuardianFactorPhoneAPIV3) GetSelectedProvider(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorsProviderPhoneResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetSelectedProvider", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorsProviderPhoneResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetSelectedProvider indicates an expected call of GetSelectedProvider. +func (mr *MockGuardianFactorPhoneAPIV3MockRecorder) GetSelectedProvider(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSelectedProvider", reflect.TypeOf((*MockGuardianFactorPhoneAPIV3)(nil).GetSelectedProvider), varargs...) +} + +// GetTemplates mocks base method. +func (m *MockGuardianFactorPhoneAPIV3) GetTemplates(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorPhoneTemplatesResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetTemplates", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorPhoneTemplatesResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTemplates indicates an expected call of GetTemplates. +func (mr *MockGuardianFactorPhoneAPIV3MockRecorder) GetTemplates(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTemplates", reflect.TypeOf((*MockGuardianFactorPhoneAPIV3)(nil).GetTemplates), varargs...) +} + +// GetTwilioProvider mocks base method. +func (m *MockGuardianFactorPhoneAPIV3) GetTwilioProvider(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorsProviderPhoneTwilioResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetTwilioProvider", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorsProviderPhoneTwilioResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTwilioProvider indicates an expected call of GetTwilioProvider. +func (mr *MockGuardianFactorPhoneAPIV3MockRecorder) GetTwilioProvider(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTwilioProvider", reflect.TypeOf((*MockGuardianFactorPhoneAPIV3)(nil).GetTwilioProvider), varargs...) +} + +// SetMessageTypes mocks base method. +func (m *MockGuardianFactorPhoneAPIV3) SetMessageTypes(ctx context.Context, request *management.SetGuardianFactorPhoneMessageTypesRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorPhoneMessageTypesResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetMessageTypes", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorPhoneMessageTypesResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetMessageTypes indicates an expected call of SetMessageTypes. +func (mr *MockGuardianFactorPhoneAPIV3MockRecorder) SetMessageTypes(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetMessageTypes", reflect.TypeOf((*MockGuardianFactorPhoneAPIV3)(nil).SetMessageTypes), varargs...) +} + +// SetProvider mocks base method. +func (m *MockGuardianFactorPhoneAPIV3) SetProvider(ctx context.Context, request *management.SetGuardianFactorsProviderPhoneRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorsProviderPhoneResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetProvider", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorsProviderPhoneResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetProvider indicates an expected call of SetProvider. +func (mr *MockGuardianFactorPhoneAPIV3MockRecorder) SetProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetProvider", reflect.TypeOf((*MockGuardianFactorPhoneAPIV3)(nil).SetProvider), varargs...) +} + +// SetTemplates mocks base method. +func (m *MockGuardianFactorPhoneAPIV3) SetTemplates(ctx context.Context, request *management.SetGuardianFactorPhoneTemplatesRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorPhoneTemplatesResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetTemplates", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorPhoneTemplatesResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetTemplates indicates an expected call of SetTemplates. +func (mr *MockGuardianFactorPhoneAPIV3MockRecorder) SetTemplates(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTemplates", reflect.TypeOf((*MockGuardianFactorPhoneAPIV3)(nil).SetTemplates), varargs...) +} + +// SetTwilioProvider mocks base method. +func (m *MockGuardianFactorPhoneAPIV3) SetTwilioProvider(ctx context.Context, request *management.SetGuardianFactorsProviderPhoneTwilioRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorsProviderPhoneTwilioResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetTwilioProvider", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorsProviderPhoneTwilioResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetTwilioProvider indicates an expected call of SetTwilioProvider. +func (mr *MockGuardianFactorPhoneAPIV3MockRecorder) SetTwilioProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTwilioProvider", reflect.TypeOf((*MockGuardianFactorPhoneAPIV3)(nil).SetTwilioProvider), varargs...) +} diff --git a/internal/auth0/mock/guardian_factor_push_mock.go b/internal/auth0/mock/guardian_factor_push_mock.go new file mode 100644 index 000000000..5bde84c3f --- /dev/null +++ b/internal/auth0/mock/guardian_factor_push_mock.go @@ -0,0 +1,277 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: guardian_factor_push.go + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + reflect "reflect" + + management "github.com/auth0/go-auth0/v3/management" + option "github.com/auth0/go-auth0/v3/management/option" + gomock "github.com/golang/mock/gomock" +) + +// MockGuardianFactorPushAPIV3 is a mock of GuardianFactorPushAPIV3 interface. +type MockGuardianFactorPushAPIV3 struct { + ctrl *gomock.Controller + recorder *MockGuardianFactorPushAPIV3MockRecorder +} + +// MockGuardianFactorPushAPIV3MockRecorder is the mock recorder for MockGuardianFactorPushAPIV3. +type MockGuardianFactorPushAPIV3MockRecorder struct { + mock *MockGuardianFactorPushAPIV3 +} + +// NewMockGuardianFactorPushAPIV3 creates a new mock instance. +func NewMockGuardianFactorPushAPIV3(ctrl *gomock.Controller) *MockGuardianFactorPushAPIV3 { + mock := &MockGuardianFactorPushAPIV3{ctrl: ctrl} + mock.recorder = &MockGuardianFactorPushAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGuardianFactorPushAPIV3) EXPECT() *MockGuardianFactorPushAPIV3MockRecorder { + return m.recorder +} + +// GetApnsProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) GetApnsProvider(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorsProviderApnsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetApnsProvider", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorsProviderApnsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetApnsProvider indicates an expected call of GetApnsProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) GetApnsProvider(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetApnsProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).GetApnsProvider), varargs...) +} + +// GetSelectedProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) GetSelectedProvider(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorsProviderPushNotificationResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetSelectedProvider", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorsProviderPushNotificationResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetSelectedProvider indicates an expected call of GetSelectedProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) GetSelectedProvider(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSelectedProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).GetSelectedProvider), varargs...) +} + +// GetSnsProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) GetSnsProvider(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorsProviderSnsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetSnsProvider", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorsProviderSnsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetSnsProvider indicates an expected call of GetSnsProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) GetSnsProvider(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSnsProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).GetSnsProvider), varargs...) +} + +// SetApnsProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) SetApnsProvider(ctx context.Context, request *management.SetGuardianFactorsProviderPushNotificationApnsRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorsProviderPushNotificationApnsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetApnsProvider", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorsProviderPushNotificationApnsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetApnsProvider indicates an expected call of SetApnsProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) SetApnsProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetApnsProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).SetApnsProvider), varargs...) +} + +// SetFcmProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) SetFcmProvider(ctx context.Context, request *management.SetGuardianFactorsProviderPushNotificationFcmRequestContent, opts ...option.RequestOption) (management.SetGuardianFactorsProviderPushNotificationFcmResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetFcmProvider", varargs...) + ret0, _ := ret[0].(management.SetGuardianFactorsProviderPushNotificationFcmResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetFcmProvider indicates an expected call of SetFcmProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) SetFcmProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetFcmProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).SetFcmProvider), varargs...) +} + +// SetFcmv1Provider mocks base method. +func (m *MockGuardianFactorPushAPIV3) SetFcmv1Provider(ctx context.Context, request *management.SetGuardianFactorsProviderPushNotificationFcmv1RequestContent, opts ...option.RequestOption) (management.SetGuardianFactorsProviderPushNotificationFcmv1ResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetFcmv1Provider", varargs...) + ret0, _ := ret[0].(management.SetGuardianFactorsProviderPushNotificationFcmv1ResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetFcmv1Provider indicates an expected call of SetFcmv1Provider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) SetFcmv1Provider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetFcmv1Provider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).SetFcmv1Provider), varargs...) +} + +// SetProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) SetProvider(ctx context.Context, request *management.SetGuardianFactorsProviderPushNotificationRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorsProviderPushNotificationResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetProvider", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorsProviderPushNotificationResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetProvider indicates an expected call of SetProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) SetProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).SetProvider), varargs...) +} + +// SetSnsProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) SetSnsProvider(ctx context.Context, request *management.SetGuardianFactorsProviderPushNotificationSnsRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorsProviderPushNotificationSnsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetSnsProvider", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorsProviderPushNotificationSnsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetSnsProvider indicates an expected call of SetSnsProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) SetSnsProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSnsProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).SetSnsProvider), varargs...) +} + +// UpdateApnsProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) UpdateApnsProvider(ctx context.Context, request *management.UpdateGuardianFactorsProviderPushNotificationApnsRequestContent, opts ...option.RequestOption) (*management.UpdateGuardianFactorsProviderPushNotificationApnsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateApnsProvider", varargs...) + ret0, _ := ret[0].(*management.UpdateGuardianFactorsProviderPushNotificationApnsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateApnsProvider indicates an expected call of UpdateApnsProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) UpdateApnsProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateApnsProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).UpdateApnsProvider), varargs...) +} + +// UpdateFcmProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) UpdateFcmProvider(ctx context.Context, request *management.UpdateGuardianFactorsProviderPushNotificationFcmRequestContent, opts ...option.RequestOption) (management.UpdateGuardianFactorsProviderPushNotificationFcmResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateFcmProvider", varargs...) + ret0, _ := ret[0].(management.UpdateGuardianFactorsProviderPushNotificationFcmResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateFcmProvider indicates an expected call of UpdateFcmProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) UpdateFcmProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateFcmProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).UpdateFcmProvider), varargs...) +} + +// UpdateFcmv1Provider mocks base method. +func (m *MockGuardianFactorPushAPIV3) UpdateFcmv1Provider(ctx context.Context, request *management.UpdateGuardianFactorsProviderPushNotificationFcmv1RequestContent, opts ...option.RequestOption) (management.UpdateGuardianFactorsProviderPushNotificationFcmv1ResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateFcmv1Provider", varargs...) + ret0, _ := ret[0].(management.UpdateGuardianFactorsProviderPushNotificationFcmv1ResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateFcmv1Provider indicates an expected call of UpdateFcmv1Provider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) UpdateFcmv1Provider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateFcmv1Provider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).UpdateFcmv1Provider), varargs...) +} + +// UpdateSnsProvider mocks base method. +func (m *MockGuardianFactorPushAPIV3) UpdateSnsProvider(ctx context.Context, request *management.UpdateGuardianFactorsProviderPushNotificationSnsRequestContent, opts ...option.RequestOption) (*management.UpdateGuardianFactorsProviderPushNotificationSnsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UpdateSnsProvider", varargs...) + ret0, _ := ret[0].(*management.UpdateGuardianFactorsProviderPushNotificationSnsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UpdateSnsProvider indicates an expected call of UpdateSnsProvider. +func (mr *MockGuardianFactorPushAPIV3MockRecorder) UpdateSnsProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSnsProvider", reflect.TypeOf((*MockGuardianFactorPushAPIV3)(nil).UpdateSnsProvider), varargs...) +} diff --git a/internal/auth0/mock/guardian_factor_sms_mock.go b/internal/auth0/mock/guardian_factor_sms_mock.go new file mode 100644 index 000000000..bcd035cb3 --- /dev/null +++ b/internal/auth0/mock/guardian_factor_sms_mock.go @@ -0,0 +1,157 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: guardian_factor_sms.go + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + reflect "reflect" + + management "github.com/auth0/go-auth0/v3/management" + option "github.com/auth0/go-auth0/v3/management/option" + gomock "github.com/golang/mock/gomock" +) + +// MockGuardianFactorSmsAPIV3 is a mock of GuardianFactorSmsAPIV3 interface. +type MockGuardianFactorSmsAPIV3 struct { + ctrl *gomock.Controller + recorder *MockGuardianFactorSmsAPIV3MockRecorder +} + +// MockGuardianFactorSmsAPIV3MockRecorder is the mock recorder for MockGuardianFactorSmsAPIV3. +type MockGuardianFactorSmsAPIV3MockRecorder struct { + mock *MockGuardianFactorSmsAPIV3 +} + +// NewMockGuardianFactorSmsAPIV3 creates a new mock instance. +func NewMockGuardianFactorSmsAPIV3(ctrl *gomock.Controller) *MockGuardianFactorSmsAPIV3 { + mock := &MockGuardianFactorSmsAPIV3{ctrl: ctrl} + mock.recorder = &MockGuardianFactorSmsAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGuardianFactorSmsAPIV3) EXPECT() *MockGuardianFactorSmsAPIV3MockRecorder { + return m.recorder +} + +// GetSelectedProvider mocks base method. +func (m *MockGuardianFactorSmsAPIV3) GetSelectedProvider(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorsProviderSmsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetSelectedProvider", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorsProviderSmsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetSelectedProvider indicates an expected call of GetSelectedProvider. +func (mr *MockGuardianFactorSmsAPIV3MockRecorder) GetSelectedProvider(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSelectedProvider", reflect.TypeOf((*MockGuardianFactorSmsAPIV3)(nil).GetSelectedProvider), varargs...) +} + +// GetTemplates mocks base method. +func (m *MockGuardianFactorSmsAPIV3) GetTemplates(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorSmsTemplatesResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetTemplates", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorSmsTemplatesResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTemplates indicates an expected call of GetTemplates. +func (mr *MockGuardianFactorSmsAPIV3MockRecorder) GetTemplates(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTemplates", reflect.TypeOf((*MockGuardianFactorSmsAPIV3)(nil).GetTemplates), varargs...) +} + +// GetTwilioProvider mocks base method. +func (m *MockGuardianFactorSmsAPIV3) GetTwilioProvider(ctx context.Context, opts ...option.RequestOption) (*management.GetGuardianFactorsProviderSmsTwilioResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "GetTwilioProvider", varargs...) + ret0, _ := ret[0].(*management.GetGuardianFactorsProviderSmsTwilioResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTwilioProvider indicates an expected call of GetTwilioProvider. +func (mr *MockGuardianFactorSmsAPIV3MockRecorder) GetTwilioProvider(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTwilioProvider", reflect.TypeOf((*MockGuardianFactorSmsAPIV3)(nil).GetTwilioProvider), varargs...) +} + +// SetProvider mocks base method. +func (m *MockGuardianFactorSmsAPIV3) SetProvider(ctx context.Context, request *management.SetGuardianFactorsProviderSmsRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorsProviderSmsResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetProvider", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorsProviderSmsResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetProvider indicates an expected call of SetProvider. +func (mr *MockGuardianFactorSmsAPIV3MockRecorder) SetProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetProvider", reflect.TypeOf((*MockGuardianFactorSmsAPIV3)(nil).SetProvider), varargs...) +} + +// SetTemplates mocks base method. +func (m *MockGuardianFactorSmsAPIV3) SetTemplates(ctx context.Context, request *management.SetGuardianFactorSmsTemplatesRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorSmsTemplatesResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetTemplates", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorSmsTemplatesResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetTemplates indicates an expected call of SetTemplates. +func (mr *MockGuardianFactorSmsAPIV3MockRecorder) SetTemplates(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTemplates", reflect.TypeOf((*MockGuardianFactorSmsAPIV3)(nil).SetTemplates), varargs...) +} + +// SetTwilioProvider mocks base method. +func (m *MockGuardianFactorSmsAPIV3) SetTwilioProvider(ctx context.Context, request *management.SetGuardianFactorsProviderSmsTwilioRequestContent, opts ...option.RequestOption) (*management.SetGuardianFactorsProviderSmsTwilioResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "SetTwilioProvider", varargs...) + ret0, _ := ret[0].(*management.SetGuardianFactorsProviderSmsTwilioResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SetTwilioProvider indicates an expected call of SetTwilioProvider. +func (mr *MockGuardianFactorSmsAPIV3MockRecorder) SetTwilioProvider(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTwilioProvider", reflect.TypeOf((*MockGuardianFactorSmsAPIV3)(nil).SetTwilioProvider), varargs...) +} diff --git a/internal/auth0/mock/guardian_policy_mock.go b/internal/auth0/mock/guardian_policy_mock.go new file mode 100644 index 000000000..d3dc3bf3a --- /dev/null +++ b/internal/auth0/mock/guardian_policy_mock.go @@ -0,0 +1,77 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: guardian_policy.go + +// Package mock is a generated GoMock package. +package mock + +import ( + context "context" + reflect "reflect" + + management "github.com/auth0/go-auth0/v3/management" + option "github.com/auth0/go-auth0/v3/management/option" + gomock "github.com/golang/mock/gomock" +) + +// MockGuardianPolicyAPIV3 is a mock of GuardianPolicyAPIV3 interface. +type MockGuardianPolicyAPIV3 struct { + ctrl *gomock.Controller + recorder *MockGuardianPolicyAPIV3MockRecorder +} + +// MockGuardianPolicyAPIV3MockRecorder is the mock recorder for MockGuardianPolicyAPIV3. +type MockGuardianPolicyAPIV3MockRecorder struct { + mock *MockGuardianPolicyAPIV3 +} + +// NewMockGuardianPolicyAPIV3 creates a new mock instance. +func NewMockGuardianPolicyAPIV3(ctrl *gomock.Controller) *MockGuardianPolicyAPIV3 { + mock := &MockGuardianPolicyAPIV3{ctrl: ctrl} + mock.recorder = &MockGuardianPolicyAPIV3MockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockGuardianPolicyAPIV3) EXPECT() *MockGuardianPolicyAPIV3MockRecorder { + return m.recorder +} + +// List mocks base method. +func (m *MockGuardianPolicyAPIV3) List(ctx context.Context, opts ...option.RequestOption) (management.ListGuardianPoliciesResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "List", varargs...) + ret0, _ := ret[0].(management.ListGuardianPoliciesResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// List indicates an expected call of List. +func (mr *MockGuardianPolicyAPIV3MockRecorder) List(ctx interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockGuardianPolicyAPIV3)(nil).List), varargs...) +} + +// Set mocks base method. +func (m *MockGuardianPolicyAPIV3) Set(ctx context.Context, request management.SetGuardianPoliciesRequestContent, opts ...option.RequestOption) (management.SetGuardianPoliciesResponseContent, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, request} + for _, a := range opts { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "Set", varargs...) + ret0, _ := ret[0].(management.SetGuardianPoliciesResponseContent) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Set indicates an expected call of Set. +func (mr *MockGuardianPolicyAPIV3MockRecorder) Set(ctx, request interface{}, opts ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, request}, opts...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockGuardianPolicyAPIV3)(nil).Set), varargs...) +} diff --git a/internal/cli/guardian.go b/internal/cli/guardian.go new file mode 100644 index 000000000..54c335e5e --- /dev/null +++ b/internal/cli/guardian.go @@ -0,0 +1,50 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" +) + +// legacyPhoneProviderErrorCode is the errorCode the Management API returns when +// a tenant uses the deprecated Guardian phone/SMS provider, template or Twilio +// endpoints without the legacy phone-provider flags enabled. +const legacyPhoneProviderErrorCode = "legacy_mfa_phone_provider_not_allowed" + +// guardianLegacyPhoneHint augments the deprecated legacy phone-provider error +// with actionable guidance. These endpoints are gated behind the tenant flags +// legacy_mfa_phone_provider and legacy_passwordless_phone_provider; without them +// the API refuses the request in favour of Tenant Phone Settings. +func guardianLegacyPhoneHint(err error) error { + if err == nil || !strings.Contains(err.Error(), legacyPhoneProviderErrorCode) { + return err + } + + return fmt.Errorf( + "%w\n\n"+ + "This is a deprecated Guardian phone/SMS provider endpoint, gated behind the tenant's "+ + "legacy_mfa_phone_provider migration flag. That flag is toggled via PATCH /api/v2/migrations, "+ + "which requires Auth0 Dashboard (session) access and is not available to Management API tokens, "+ + "so it cannot be enabled from the CLI. Use the unified phone experience instead: configure a "+ + "tenant phone provider (Dashboard: Authentication > Phone), or set the MFA phone provider to "+ + "'phone-message-hook' backed by a send-phone-message action", + err, + ) +} + +func guardianCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "guardian", + Short: "Manage multi-factor authentication (Guardian)", + Long: "Manage Auth0 multi-factor authentication (MFA), also known as Guardian. " + + "Configure MFA policies, factors and their providers, and manage user enrollments.", + } + + cmd.SetUsageTemplate(resourceUsageTemplate()) + cmd.AddCommand(guardianPoliciesCmd(cli)) + cmd.AddCommand(guardianEnrollmentsCmd(cli)) + cmd.AddCommand(guardianFactorsCmd(cli)) + + return cmd +} diff --git a/internal/cli/guardian_enrollments.go b/internal/cli/guardian_enrollments.go new file mode 100644 index 000000000..b7dbd297e --- /dev/null +++ b/internal/cli/guardian_enrollments.go @@ -0,0 +1,231 @@ +package cli + +import ( + "fmt" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/spf13/cobra" + + "github.com/auth0/auth0-cli/internal/ansi" + "github.com/auth0/auth0-cli/internal/prompt" +) + +var ( + guardianEnrollmentID = Argument{ + Name: "Id", + Help: "Id of the enrollment.", + } + guardianEnrollmentUserID = Flag{ + Name: "User ID", + LongForm: "user-id", + ShortForm: "u", + Help: "User ID to create the enrollment ticket for.", + IsRequired: true, + } + guardianEnrollmentFactor = Flag{ + Name: "Factor", + LongForm: "factor", + ShortForm: "f", + Help: "Factor the user must enroll with, e.g. push-notification, sms, email, otp, webauthn-roaming, webauthn-platform, recovery-code, duo.", + } + guardianEnrollmentEmail = Flag{ + Name: "Email", + LongForm: "email", + Help: "Alternate email address to send the enrollment email to. Defaults to the user's email.", + } + guardianEnrollmentSendEmail = Flag{ + Name: "Send Email", + LongForm: "send-email", + Help: "Send an email to the user to start the enrollment.", + } + guardianEnrollmentEmailLocale = Flag{ + Name: "Email Locale", + LongForm: "email-locale", + Help: "Locale of the enrollment email. Used with --send-email.", + } + guardianEnrollmentAllowMultiple = Flag{ + Name: "Allow Multiple Enrollments", + LongForm: "allow-multiple", + Help: "Allow a user who has previously enrolled in MFA to enroll with additional factors. Universal Login only.", + } +) + +func guardianEnrollmentsCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "enrollments", + Short: "Manage multi-factor authentication enrollments", + Long: "Manage user multi-factor authentication (MFA) enrollments and enrollment tickets.", + } + + cmd.SetUsageTemplate(resourceUsageTemplate()) + cmd.AddCommand(createGuardianEnrollmentTicketCmd(cli)) + cmd.AddCommand(showGuardianEnrollmentCmd(cli)) + cmd.AddCommand(deleteGuardianEnrollmentCmd(cli)) + + return cmd +} + +func createGuardianEnrollmentTicketCmd(cli *cli) *cobra.Command { + var inputs struct { + UserID string + Factor string + Email string + SendEmail bool + EmailLocale string + AllowMultiple bool + } + + cmd := &cobra.Command{ + Use: "create-ticket", + Args: cobra.NoArgs, + Short: "Create a multi-factor authentication enrollment ticket", + Long: "Create an MFA enrollment ticket for a user and, optionally, email it to them.\n\n" + + "The returned ticket URL is the link the user follows to enroll.", + Example: ` auth0 guardian enrollments create-ticket --user-id "auth0|123" + auth0 guardian enrollments create-ticket --user-id "auth0|123" --factor push-notification + auth0 guardian enrollments create-ticket --user-id "auth0|123" --send-email --email me@example.com + auth0 guardian enrollments create-ticket --user-id "auth0|123" --allow-multiple --json`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianEnrollmentUserID.Ask(cmd, &inputs.UserID, nil); err != nil { + return err + } + + body := &managementv3.CreateGuardianEnrollmentTicketRequestContent{ + UserID: inputs.UserID, + } + if inputs.Factor != "" { + factor, err := managementv3.NewGuardianEnrollmentFactorEnumFromString(inputs.Factor) + if err != nil { + return fmt.Errorf("invalid factor %q: %w", inputs.Factor, err) + } + body.Factor = &factor + } + if inputs.Email != "" { + body.Email = &inputs.Email + } + if guardianEnrollmentSendEmail.IsSet(cmd) { + body.SendMail = &inputs.SendEmail + } + if inputs.EmailLocale != "" { + body.EmailLocale = &inputs.EmailLocale + } + if guardianEnrollmentAllowMultiple.IsSet(cmd) { + body.AllowMultipleEnrollments = &inputs.AllowMultiple + } + + var ticket *managementv3.CreateGuardianEnrollmentTicketResponseContent + if err := ansi.Waiting(func() (err error) { + ticket, err = cli.apiv3.GuardianEnrollment.CreateTicket(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to create guardian enrollment ticket for user %q: %w", inputs.UserID, err) + } + + cli.renderer.GuardianEnrollmentTicketCreate(ticket) + + return nil + }, + } + + cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") + cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") + cmd.MarkFlagsMutuallyExclusive("json", "json-compact") + + guardianEnrollmentUserID.RegisterString(cmd, &inputs.UserID, "") + guardianEnrollmentFactor.RegisterString(cmd, &inputs.Factor, "") + guardianEnrollmentEmail.RegisterString(cmd, &inputs.Email, "") + guardianEnrollmentSendEmail.RegisterBool(cmd, &inputs.SendEmail, false) + guardianEnrollmentEmailLocale.RegisterString(cmd, &inputs.EmailLocale, "") + guardianEnrollmentAllowMultiple.RegisterBool(cmd, &inputs.AllowMultiple, false) + + return cmd +} + +func showGuardianEnrollmentCmd(cli *cli) *cobra.Command { + var inputs struct { + ID string + } + + cmd := &cobra.Command{ + Use: "show", + Args: cobra.MaximumNArgs(1), + Short: "Show a multi-factor authentication enrollment", + Long: "Display the status, type and details of an MFA enrollment.", + Example: ` auth0 guardian enrollments show + auth0 guardian enrollments show --json`, + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) == 0 { + if err := guardianEnrollmentID.Ask(cmd, &inputs.ID); err != nil { + return err + } + } else { + inputs.ID = args[0] + } + + var enrollment *managementv3.GetGuardianEnrollmentResponseContent + if err := ansi.Waiting(func() (err error) { + enrollment, err = cli.apiv3.GuardianEnrollment.Get(cmd.Context(), inputs.ID) + return err + }); err != nil { + return fmt.Errorf("failed to read guardian enrollment with ID %q: %w", inputs.ID, err) + } + + cli.renderer.GuardianEnrollmentShow(enrollment) + + return nil + }, + } + + cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") + cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") + cmd.MarkFlagsMutuallyExclusive("json", "json-compact") + + return cmd +} + +func deleteGuardianEnrollmentCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "delete", + Aliases: []string{"rm"}, + Args: cobra.MaximumNArgs(1), + Short: "Delete a multi-factor authentication enrollment", + Long: "Delete an MFA enrollment, allowing the user to re-enroll.\n\n" + + "To delete interactively, use `auth0 guardian enrollments delete` with no arguments.\n\n" + + "To delete non-interactively, supply the enrollment id and the `--force` flag to skip confirmation.", + Example: ` auth0 guardian enrollments delete + auth0 guardian enrollments rm + auth0 guardian enrollments delete + auth0 guardian enrollments delete --force`, + RunE: func(cmd *cobra.Command, args []string) error { + var id string + if len(args) == 0 { + if err := guardianEnrollmentID.Ask(cmd, &id); err != nil { + return err + } + } else { + id = args[0] + } + + if !cli.force && cli.agentMode { + return errDestructiveNoConfirm + } + + if !cli.force && canPrompt(cmd) { + if confirmed := prompt.Confirm("Are you sure you want to proceed?"); !confirmed { + return nil + } + } + + return ansi.Spinner("Deleting guardian enrollment", func() error { + if err := cli.apiv3.GuardianEnrollment.Delete(cmd.Context(), id); err != nil { + return fmt.Errorf("failed to delete guardian enrollment with ID %q: %w", id, err) + } + return nil + }) + }, + } + + cmd.Flags().BoolVar(&cli.force, "force", false, "Skip confirmation.") + + return cmd +} diff --git a/internal/cli/guardian_factor_duo.go b/internal/cli/guardian_factor_duo.go new file mode 100644 index 000000000..925b58144 --- /dev/null +++ b/internal/cli/guardian_factor_duo.go @@ -0,0 +1,211 @@ +package cli + +import ( + "fmt" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/spf13/cobra" + + "github.com/auth0/auth0-cli/internal/ansi" + "github.com/auth0/auth0-cli/internal/display" +) + +func guardianFactorDuoCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "duo", + Short: "Manage the Duo multi-factor authentication factor", + Long: "Manage the Duo MFA factor settings.", + } + + cmd.SetUsageTemplate(resourceUsageTemplate()) + + settings := &cobra.Command{ + Use: "settings", + Short: "Manage the Duo settings", + Long: "Manage the Duo MFA factor settings.", + } + settings.SetUsageTemplate(resourceUsageTemplate()) + settings.AddCommand(showGuardianDuoSettingsCmd(cli)) + settings.AddCommand(setGuardianDuoSettingsCmd(cli)) + settings.AddCommand(updateGuardianDuoSettingsCmd(cli)) + + cmd.AddCommand(settings) + + return cmd +} + +func guardianDuoSettingsRows(host, ikey, skey string) [][]string { + return [][]string{ + {"HOST", host}, + {"INTEGRATION KEY", ikey}, + {"SECRET KEY", display.MaskSecret(skey)}, + } +} + +func showGuardianDuoSettingsCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show", + Args: cobra.NoArgs, + Short: "Show the Duo settings", + Long: "Display the Duo MFA factor settings.", + Example: ` auth0 guardian factors duo settings show --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorDuoSettingsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorDuo.Get(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read Duo settings: %w", err) + } + + cli.renderer.GuardianDetail("duo settings", guardianDuoSettingsRows(resp.GetHost(), resp.GetIkey(), resp.GetSkey()), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianDuoSettingsCmd(cli *cli) *cobra.Command { + var inputs struct { + Ikey string + Skey string + Host string + } + + cmd := &cobra.Command{ + Use: "set", + Args: cobra.NoArgs, + Short: "Set the Duo settings", + Long: "Replace the Duo MFA factor settings. This overwrites all Duo settings, so the host, " + + "integration key and secret key are all required. To change a single field without " + + "clearing the others, use `auth0 guardian factors duo settings update` instead.", + Example: ` auth0 guardian factors duo settings set --ikey --skey --host api-xxxx.duosecurity.com`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianDuoHost.Ask(cmd, &inputs.Host, nil); err != nil { + return err + } + if err := guardianDuoIkey.Ask(cmd, &inputs.Ikey, nil); err != nil { + return err + } + if err := guardianDuoSkey.Ask(cmd, &inputs.Skey, nil); err != nil { + return err + } + + if inputs.Host == "" || inputs.Ikey == "" || inputs.Skey == "" { + return fmt.Errorf( + "--host, --ikey and --skey are all required for set, since it replaces the entire " + + "Duo configuration. To change a single field, use 'auth0 guardian factors duo settings update'", + ) + } + + body := &managementv3.SetGuardianFactorDuoSettingsRequestContent{ + Host: &inputs.Host, + Ikey: &inputs.Ikey, + Skey: &inputs.Skey, + } + + var resp *managementv3.SetGuardianFactorDuoSettingsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorDuo.Set(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to set Duo settings: %w", err) + } + + cli.renderer.GuardianDetail("duo settings updated", guardianDuoSettingsRows(resp.GetHost(), resp.GetIkey(), resp.GetSkey()), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianDuoIkey.RegisterString(cmd, &inputs.Ikey, "") + guardianDuoSkey.RegisterString(cmd, &inputs.Skey, "") + guardianDuoHost.RegisterString(cmd, &inputs.Host, "") + + return cmd +} + +func updateGuardianDuoSettingsCmd(cli *cli) *cobra.Command { + var inputs struct { + Ikey string + Skey string + Host string + } + + cmd := &cobra.Command{ + Use: "update", + Args: cobra.NoArgs, + Short: "Update the Duo settings", + Long: "Partially update the Duo MFA factor settings. Only the fields you provide are changed; " + + "the rest keep their current values. Run without flags to be prompted for each field, " + + "pre-filled with the current value (leave the secret key blank to keep it unchanged).", + Example: ` auth0 guardian factors duo settings update --host api-xxxx.duosecurity.com`, + RunE: func(cmd *cobra.Command, args []string) error { + // Fetch the current settings so the interactive prompts can default + // to the existing values (the secret key is never pre-filled). + var current *managementv3.GetGuardianFactorDuoSettingsResponseContent + if err := ansi.Waiting(func() (err error) { + current, err = cli.apiv3.GuardianFactorDuo.Get(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read Duo settings: %w", err) + } + + currentHost := current.GetHost() + currentIkey := current.GetIkey() + if err := guardianDuoHost.AskU(cmd, &inputs.Host, ¤tHost); err != nil { + return err + } + if err := guardianDuoIkey.AskU(cmd, &inputs.Ikey, ¤tIkey); err != nil { + return err + } + if err := guardianDuoSkey.AskU(cmd, &inputs.Skey, nil); err != nil { + return err + } + + body := &managementv3.UpdateGuardianFactorDuoSettingsRequestContent{} + if inputs.Ikey != "" { + body.Ikey = &inputs.Ikey + } + if inputs.Skey != "" { + body.Skey = &inputs.Skey + } + if inputs.Host != "" { + body.Host = &inputs.Host + } + + if err := ansi.Waiting(func() (err error) { + _, err = cli.apiv3.GuardianFactorDuo.Update(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to update Duo settings: %w", err) + } + + // The PATCH response only echoes the fields that were sent, so + // re-fetch the full settings to render the complete current state. + var resp *managementv3.GetGuardianFactorDuoSettingsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorDuo.Get(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read Duo settings: %w", err) + } + + cli.renderer.GuardianDetail("duo settings updated", guardianDuoSettingsRows(resp.GetHost(), resp.GetIkey(), resp.GetSkey()), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianDuoIkey.RegisterString(cmd, &inputs.Ikey, "") + guardianDuoSkey.RegisterString(cmd, &inputs.Skey, "") + guardianDuoHost.RegisterString(cmd, &inputs.Host, "") + + return cmd +} diff --git a/internal/cli/guardian_factor_phone.go b/internal/cli/guardian_factor_phone.go new file mode 100644 index 000000000..cf31c06d4 --- /dev/null +++ b/internal/cli/guardian_factor_phone.go @@ -0,0 +1,373 @@ +package cli + +import ( + "fmt" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/spf13/cobra" + + "github.com/auth0/auth0-cli/internal/ansi" + "github.com/auth0/auth0-cli/internal/display" +) + +func guardianFactorPhoneCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "phone", + Short: "Manage the phone multi-factor authentication factor", + Long: "Manage the phone MFA factor provider, message types and templates.", + } + + cmd.SetUsageTemplate(resourceUsageTemplate()) + cmd.AddCommand(showGuardianPhoneProviderCmd(cli)) + cmd.AddCommand(setGuardianPhoneProviderCmd(cli)) + cmd.AddCommand(showGuardianPhoneMessageTypesCmd(cli)) + cmd.AddCommand(setGuardianPhoneMessageTypesCmd(cli)) + cmd.AddCommand(showGuardianPhoneTemplatesCmd(cli)) + cmd.AddCommand(setGuardianPhoneTemplatesCmd(cli)) + cmd.AddCommand(showGuardianPhoneTwilioCmd(cli)) + cmd.AddCommand(setGuardianPhoneTwilioCmd(cli)) + + return cmd +} + +func registerGuardianJSONFlags(cli *cli, cmd *cobra.Command) { + cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") + cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") + cmd.MarkFlagsMutuallyExclusive("json", "json-compact") +} + +func showGuardianPhoneProviderCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-provider", + Args: cobra.NoArgs, + Short: "Show the phone provider (legacy)", + Long: "Display the configured phone MFA provider.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage phone " + + "delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens.", + Example: ` auth0 guardian factors phone show-provider + auth0 guardian factors phone show-provider --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorsProviderPhoneResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPhone.GetSelectedProvider(cmd.Context()) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to read phone provider: %w", err)) + } + + cli.renderer.GuardianDetail("phone provider", [][]string{ + {"PROVIDER", string(resp.GetProvider())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianPhoneProviderCmd(cli *cli) *cobra.Command { + var provider string + + cmd := &cobra.Command{ + Use: "set-provider", + Args: cobra.NoArgs, + Short: "Set the phone provider (legacy)", + Long: "Set the phone MFA provider. One of: auth0, twilio, phone-message-hook.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage phone " + + "delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens.", + Example: ` auth0 guardian factors phone set-provider --provider twilio + auth0 guardian factors phone set-provider --provider auth0 --json`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianProvider.Select(cmd, &provider, guardianSmsProviderOptions, nil); err != nil { + return err + } + + value, err := managementv3.NewGuardianFactorsProviderSmsProviderEnumFromString(provider) + if err != nil { + return fmt.Errorf("invalid provider %q: valid values are auth0, twilio, phone-message-hook", provider) + } + + body := &managementv3.SetGuardianFactorsProviderPhoneRequestContent{Provider: value} + + var resp *managementv3.SetGuardianFactorsProviderPhoneResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPhone.SetProvider(cmd.Context(), body) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to set phone provider: %w", err)) + } + + cli.renderer.GuardianDetail("phone provider updated", [][]string{ + {"PROVIDER", string(resp.GetProvider())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianProvider.RegisterString(cmd, &provider, "") + + return cmd +} + +func showGuardianPhoneMessageTypesCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-message-types", + Args: cobra.NoArgs, + Short: "Show the phone message types", + Long: "Display the enabled phone message types (sms, voice).", + Example: ` auth0 guardian factors phone show-message-types --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorPhoneMessageTypesResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPhone.GetMessageTypes(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read phone message types: %w", err) + } + + cli.renderer.GuardianDetail("phone message types", [][]string{ + {"MESSAGE TYPES", messageTypesForDisplay(resp.GetMessageTypes())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianPhoneMessageTypesCmd(cli *cli) *cobra.Command { + var messageTypes []string + + cmd := &cobra.Command{ + Use: "set-message-types", + Args: cobra.NoArgs, + Short: "Set the phone message types", + Long: "Set the enabled phone message types. Supported values: sms, voice.", + Example: ` auth0 guardian factors phone set-message-types --message-type sms --message-type voice + auth0 guardian factors phone set-message-types --message-type sms --json`, + RunE: func(cmd *cobra.Command, args []string) error { + if !guardianMessageType.IsSet(cmd) && canPrompt(cmd) { + if err := guardianMessageType.PickMany(cmd, &messageTypes, staticPickerOptions(guardianMessageTypeOptions)); err != nil { + return err + } + } + + types := make([]managementv3.GuardianFactorPhoneFactorMessageTypeEnum, 0, len(messageTypes)) + for _, t := range messageTypes { + value, err := managementv3.NewGuardianFactorPhoneFactorMessageTypeEnumFromString(t) + if err != nil { + return fmt.Errorf("invalid message type %q: valid values are sms, voice", t) + } + types = append(types, value) + } + + body := &managementv3.SetGuardianFactorPhoneMessageTypesRequestContent{MessageTypes: types} + + var resp *managementv3.SetGuardianFactorPhoneMessageTypesResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPhone.SetMessageTypes(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to set phone message types: %w", err) + } + + cli.renderer.GuardianDetail("phone message types updated", [][]string{ + {"MESSAGE TYPES", messageTypesForDisplay(resp.GetMessageTypes())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianMessageType.RegisterStringSlice(cmd, &messageTypes, nil) + + return cmd +} + +func showGuardianPhoneTemplatesCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-templates", + Args: cobra.NoArgs, + Short: "Show the phone templates (legacy)", + Long: "Display the phone enrollment and verification message templates.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage phone " + + "templates from the Dashboard (Branding > Phone Templates); it is not available to Management API tokens.", + Example: ` auth0 guardian factors phone show-templates --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorPhoneTemplatesResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPhone.GetTemplates(cmd.Context()) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to read phone templates: %w", err)) + } + + cli.renderer.GuardianDetail("phone templates", [][]string{ + {"ENROLLMENT MESSAGE", resp.GetEnrollmentMessage()}, + {"VERIFICATION MESSAGE", resp.GetVerificationMessage()}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianPhoneTemplatesCmd(cli *cli) *cobra.Command { + var inputs struct { + EnrollmentMessage string + VerificationMessage string + } + + cmd := &cobra.Command{ + Use: "set-templates", + Args: cobra.NoArgs, + Short: "Set the phone templates (legacy)", + Long: "Set the phone enrollment and verification message templates.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage phone " + + "templates from the Dashboard (Branding > Phone Templates); it is not available to Management API tokens.", + Example: ` auth0 guardian factors phone set-templates \ + --enrollment-message "Your verification code is {{code}}" \ + --verification-message "Your verification code is {{code}}"`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianEnrollmentMessage.Ask(cmd, &inputs.EnrollmentMessage, nil); err != nil { + return err + } + if err := guardianVerificationMessage.Ask(cmd, &inputs.VerificationMessage, nil); err != nil { + return err + } + + body := &managementv3.SetGuardianFactorPhoneTemplatesRequestContent{ + EnrollmentMessage: inputs.EnrollmentMessage, + VerificationMessage: inputs.VerificationMessage, + } + + var resp *managementv3.SetGuardianFactorPhoneTemplatesResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPhone.SetTemplates(cmd.Context(), body) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to set phone templates: %w", err)) + } + + cli.renderer.GuardianDetail("phone templates updated", [][]string{ + {"ENROLLMENT MESSAGE", resp.GetEnrollmentMessage()}, + {"VERIFICATION MESSAGE", resp.GetVerificationMessage()}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianEnrollmentMessage.RegisterString(cmd, &inputs.EnrollmentMessage, "") + guardianVerificationMessage.RegisterString(cmd, &inputs.VerificationMessage, "") + + return cmd +} + +func showGuardianPhoneTwilioCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-twilio", + Args: cobra.NoArgs, + Short: "Show the phone Twilio configuration (legacy)", + Long: "Display the Twilio configuration for the phone MFA factor.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage phone " + + "delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens.", + Example: ` auth0 guardian factors phone show-twilio --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorsProviderPhoneTwilioResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPhone.GetTwilioProvider(cmd.Context()) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to read phone Twilio configuration: %w", err)) + } + + cli.renderer.GuardianDetail("phone twilio configuration", [][]string{ + {"FROM", resp.GetFrom()}, + {"MESSAGING SERVICE SID", resp.GetMessagingServiceSid()}, + {"SID", resp.GetSid()}, + {"AUTH TOKEN", display.MaskSecret(resp.GetAuthToken())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianPhoneTwilioCmd(cli *cli) *cobra.Command { + var inputs struct { + From string + MessagingServiceSid string + Sid string + AuthToken string + } + + cmd := &cobra.Command{ + Use: "set-twilio", + Args: cobra.NoArgs, + Short: "Set the phone Twilio configuration (legacy)", + Long: "Set the Twilio configuration for the phone MFA factor.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage phone " + + "delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens.", + Example: ` auth0 guardian factors phone set-twilio --sid AC... --auth-token --from "+14155550100" + auth0 guardian factors phone set-twilio --sid AC... --auth-token --messaging-service-sid MG...`, + RunE: func(cmd *cobra.Command, args []string) error { + body := &managementv3.SetGuardianFactorsProviderPhoneTwilioRequestContent{} + if inputs.From != "" { + body.From = &inputs.From + } + if inputs.MessagingServiceSid != "" { + body.MessagingServiceSid = &inputs.MessagingServiceSid + } + if inputs.Sid != "" { + body.Sid = &inputs.Sid + } + if inputs.AuthToken != "" { + body.AuthToken = &inputs.AuthToken + } + + var resp *managementv3.SetGuardianFactorsProviderPhoneTwilioResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPhone.SetTwilioProvider(cmd.Context(), body) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to set phone Twilio configuration: %w", err)) + } + + cli.renderer.GuardianDetail("phone twilio configuration updated", [][]string{ + {"FROM", resp.GetFrom()}, + {"MESSAGING SERVICE SID", resp.GetMessagingServiceSid()}, + {"SID", resp.GetSid()}, + {"AUTH TOKEN", display.MaskSecret(resp.GetAuthToken())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianTwilioFrom.RegisterString(cmd, &inputs.From, "") + guardianTwilioMessagingServiceSid.RegisterString(cmd, &inputs.MessagingServiceSid, "") + guardianTwilioSid.RegisterString(cmd, &inputs.Sid, "") + guardianTwilioAuthToken.RegisterString(cmd, &inputs.AuthToken, "") + + return cmd +} diff --git a/internal/cli/guardian_factor_push.go b/internal/cli/guardian_factor_push.go new file mode 100644 index 000000000..1e0dbdebd --- /dev/null +++ b/internal/cli/guardian_factor_push.go @@ -0,0 +1,676 @@ +package cli + +import ( + "fmt" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/spf13/cobra" + + "github.com/auth0/auth0-cli/internal/ansi" + "github.com/auth0/auth0-cli/internal/display" +) + +func guardianFactorPushCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "push", + Short: "Manage the push-notification multi-factor authentication factor", + Long: "Manage the push-notification MFA factor provider and its APNs, FCM, FCM v1 and SNS configuration.", + } + + cmd.SetUsageTemplate(resourceUsageTemplate()) + cmd.AddCommand(showGuardianPushProviderCmd(cli)) + cmd.AddCommand(setGuardianPushProviderCmd(cli)) + cmd.AddCommand(showGuardianPushApnsCmd(cli)) + cmd.AddCommand(setGuardianPushApnsCmd(cli)) + cmd.AddCommand(updateGuardianPushApnsCmd(cli)) + cmd.AddCommand(setGuardianPushFcmCmd(cli)) + cmd.AddCommand(updateGuardianPushFcmCmd(cli)) + cmd.AddCommand(setGuardianPushFcmv1Cmd(cli)) + cmd.AddCommand(updateGuardianPushFcmv1Cmd(cli)) + cmd.AddCommand(showGuardianPushSnsCmd(cli)) + cmd.AddCommand(setGuardianPushSnsCmd(cli)) + cmd.AddCommand(updateGuardianPushSnsCmd(cli)) + + return cmd +} + +func showGuardianPushProviderCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-provider", + Args: cobra.NoArgs, + Short: "Show the push-notification provider", + Long: "Display the configured push-notification MFA provider.", + Example: ` auth0 guardian factors push show-provider --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorsProviderPushNotificationResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.GetSelectedProvider(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read push provider: %w", err) + } + + cli.renderer.GuardianDetail("push provider", [][]string{ + {"PROVIDER", string(resp.GetProvider())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianPushProviderCmd(cli *cli) *cobra.Command { + var provider string + + cmd := &cobra.Command{ + Use: "set-provider", + Args: cobra.NoArgs, + Short: "Set the push-notification provider", + Long: "Set the push-notification MFA provider. One of: guardian, sns, direct.", + Example: ` auth0 guardian factors push set-provider --provider guardian + auth0 guardian factors push set-provider --provider sns --json`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianProvider.Select(cmd, &provider, guardianPushProviderOptions, nil); err != nil { + return err + } + + if provider == "" { + return fmt.Errorf("--provider is required: valid values are guardian, sns, direct") + } + + value, err := managementv3.NewGuardianFactorsProviderPushNotificationProviderDataEnumFromString(provider) + if err != nil { + return fmt.Errorf("invalid provider %q: valid values are guardian, sns, direct", provider) + } + + body := &managementv3.SetGuardianFactorsProviderPushNotificationRequestContent{Provider: value} + + var resp *managementv3.SetGuardianFactorsProviderPushNotificationResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.SetProvider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to set push provider: %w", err) + } + + cli.renderer.GuardianDetail("push provider updated", [][]string{ + {"PROVIDER", string(resp.GetProvider())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianProvider.RegisterString(cmd, &provider, "") + + return cmd +} + +func guardianApnsRows(sandbox bool, bundleID string) [][]string { + return [][]string{ + {"BUNDLE ID", orDashCLI(bundleID)}, + {"SANDBOX", fmt.Sprintf("%t", sandbox)}, + } +} + +// orDashCLI mirrors the display package's dash placeholder for empty strings so +// the command layer can compose rows without leaking an empty cell. +func orDashCLI(value string) string { + if value == "" { + return "-" + } + return value +} + +func showGuardianPushApnsCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-apns", + Args: cobra.NoArgs, + Short: "Show the APNs configuration", + Long: "Display the Apple Push Notification service (APNs) configuration.", + Example: ` auth0 guardian factors push show-apns --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorsProviderApnsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.GetApnsProvider(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read APNs configuration: %w", err) + } + + cli.renderer.GuardianDetail("push apns configuration", guardianApnsRows(resp.GetSandbox(), resp.GetBundleID()), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianPushApnsCmd(cli *cli) *cobra.Command { + var inputs struct { + BundleID string + Sandbox bool + P12 string + } + + cmd := &cobra.Command{ + Use: "set-apns", + Args: cobra.NoArgs, + Short: "Set the APNs configuration", + Long: "Replace the Apple Push Notification service (APNs) configuration.", + Example: ` auth0 guardian factors push set-apns --bundle-id com.example.app --sandbox --p12 `, + RunE: func(cmd *cobra.Command, args []string) error { + if inputs.BundleID == "" && inputs.P12 == "" && !cmd.Flags().Changed("sandbox") { + return fmt.Errorf( + "set replaces the entire APNs configuration, so pass at least one of --bundle-id, " + + "--p12 or --sandbox. To change a single field, use 'auth0 guardian factors push update-apns'", + ) + } + + body := &managementv3.SetGuardianFactorsProviderPushNotificationApnsRequestContent{} + if inputs.BundleID != "" { + body.BundleID = &inputs.BundleID + } + if cmd.Flags().Changed("sandbox") { + body.Sandbox = &inputs.Sandbox + } + if inputs.P12 != "" { + body.P12 = &inputs.P12 + } + + var resp *managementv3.SetGuardianFactorsProviderPushNotificationApnsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.SetApnsProvider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to set APNs configuration: %w", err) + } + + cli.renderer.GuardianDetail("push apns configuration updated", guardianApnsRows(resp.GetSandbox(), resp.GetBundleID()), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianApnsBundleID.RegisterString(cmd, &inputs.BundleID, "") + guardianApnsSandbox.RegisterBool(cmd, &inputs.Sandbox, false) + guardianApnsP12.RegisterString(cmd, &inputs.P12, "") + + return cmd +} + +func updateGuardianPushApnsCmd(cli *cli) *cobra.Command { + var inputs struct { + BundleID string + Sandbox bool + P12 string + } + + cmd := &cobra.Command{ + Use: "update-apns", + Args: cobra.NoArgs, + Short: "Update the APNs configuration", + Long: "Partially update the Apple Push Notification service (APNs) configuration. Only the fields " + + "you provide are changed; the rest keep their current values. Run without flags to be prompted " + + "for each field, pre-filled with the current value (leave the .p12 blank to keep it unchanged).", + Example: ` auth0 guardian factors push update-apns --sandbox`, + RunE: func(cmd *cobra.Command, args []string) error { + // Fetch the current configuration so the interactive prompts can + // default to the existing values (the .p12 is never pre-filled). + var current *managementv3.GetGuardianFactorsProviderApnsResponseContent + if err := ansi.Waiting(func() (err error) { + current, err = cli.apiv3.GuardianFactorPush.GetApnsProvider(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read APNs configuration: %w", err) + } + + currentBundleID := current.GetBundleID() + if err := guardianApnsBundleID.AskU(cmd, &inputs.BundleID, ¤tBundleID); err != nil { + return err + } + if !guardianApnsSandbox.IsSet(cmd) { + inputs.Sandbox = current.GetSandbox() + } + currentSandbox := current.GetSandbox() + if err := guardianApnsSandbox.AskBoolU(cmd, &inputs.Sandbox, ¤tSandbox); err != nil { + return err + } + if err := guardianApnsP12.AskU(cmd, &inputs.P12, nil); err != nil { + return err + } + + body := &managementv3.UpdateGuardianFactorsProviderPushNotificationApnsRequestContent{ + Sandbox: &inputs.Sandbox, + } + if inputs.BundleID != "" { + body.BundleID = &inputs.BundleID + } + if inputs.P12 != "" { + body.P12 = &inputs.P12 + } + + if err := ansi.Waiting(func() (err error) { + _, err = cli.apiv3.GuardianFactorPush.UpdateApnsProvider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to update APNs configuration: %w", err) + } + + // The PATCH response only echoes the fields that were sent, so + // re-fetch the full configuration to render the complete state. + var resp *managementv3.GetGuardianFactorsProviderApnsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.GetApnsProvider(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read APNs configuration: %w", err) + } + + cli.renderer.GuardianDetail("push apns configuration updated", guardianApnsRows(resp.GetSandbox(), resp.GetBundleID()), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianApnsBundleID.RegisterString(cmd, &inputs.BundleID, "") + guardianApnsSandbox.RegisterBool(cmd, &inputs.Sandbox, false) + guardianApnsP12.RegisterString(cmd, &inputs.P12, "") + + return cmd +} + +func setGuardianPushFcmCmd(cli *cli) *cobra.Command { + var serverKey string + + cmd := &cobra.Command{ + Use: "set-fcm", + Args: cobra.NoArgs, + Short: "Set the FCM (legacy) configuration", + Long: "Replace the Google FCM (legacy) push-notification configuration.", + Example: ` auth0 guardian factors push set-fcm --server-key `, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianFcmServerKey.Ask(cmd, &serverKey, nil); err != nil { + return err + } + + body := &managementv3.SetGuardianFactorsProviderPushNotificationFcmRequestContent{} + if serverKey != "" { + body.ServerKey = &serverKey + } + + var resp managementv3.SetGuardianFactorsProviderPushNotificationFcmResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.SetFcmProvider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to set FCM configuration: %w", err) + } + + cli.renderer.GuardianDetail("push fcm configuration updated", [][]string{ + {"SERVER KEY", display.MaskSecret(serverKey)}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianFcmServerKey.RegisterString(cmd, &serverKey, "") + + return cmd +} + +func updateGuardianPushFcmCmd(cli *cli) *cobra.Command { + var serverKey string + + cmd := &cobra.Command{ + Use: "update-fcm", + Args: cobra.NoArgs, + Short: "Update the FCM (legacy) configuration", + Long: "Partially update the Google FCM (legacy) push-notification configuration.", + Example: ` auth0 guardian factors push update-fcm --server-key `, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianFcmServerKey.Ask(cmd, &serverKey, nil); err != nil { + return err + } + + body := &managementv3.UpdateGuardianFactorsProviderPushNotificationFcmRequestContent{} + if serverKey != "" { + body.ServerKey = &serverKey + } + + var resp managementv3.UpdateGuardianFactorsProviderPushNotificationFcmResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.UpdateFcmProvider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to update FCM configuration: %w", err) + } + + cli.renderer.GuardianDetail("push fcm configuration updated", [][]string{ + {"SERVER KEY", display.MaskSecret(serverKey)}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianFcmServerKey.RegisterString(cmd, &serverKey, "") + + return cmd +} + +func setGuardianPushFcmv1Cmd(cli *cli) *cobra.Command { + var serverCredentials string + + cmd := &cobra.Command{ + Use: "set-fcmv1", + Args: cobra.NoArgs, + Short: "Set the FCM v1 configuration", + Long: "Replace the Google FCM v1 push-notification configuration.", + Example: ` auth0 guardian factors push set-fcmv1 --server-credentials "$(cat service-account.json)"`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianFcmServerCredentials.Ask(cmd, &serverCredentials, nil); err != nil { + return err + } + + body := &managementv3.SetGuardianFactorsProviderPushNotificationFcmv1RequestContent{} + if serverCredentials != "" { + body.ServerCredentials = &serverCredentials + } + + var resp managementv3.SetGuardianFactorsProviderPushNotificationFcmv1ResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.SetFcmv1Provider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to set FCM v1 configuration: %w", err) + } + + cli.renderer.GuardianDetail("push fcmv1 configuration updated", [][]string{ + {"SERVER CREDENTIALS", display.MaskSecret(serverCredentials)}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianFcmServerCredentials.RegisterString(cmd, &serverCredentials, "") + + return cmd +} + +func updateGuardianPushFcmv1Cmd(cli *cli) *cobra.Command { + var serverCredentials string + + cmd := &cobra.Command{ + Use: "update-fcmv1", + Args: cobra.NoArgs, + Short: "Update the FCM v1 configuration", + Long: "Partially update the Google FCM v1 push-notification configuration.", + Example: ` auth0 guardian factors push update-fcmv1 --server-credentials "$(cat service-account.json)"`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianFcmServerCredentials.Ask(cmd, &serverCredentials, nil); err != nil { + return err + } + + body := &managementv3.UpdateGuardianFactorsProviderPushNotificationFcmv1RequestContent{} + if serverCredentials != "" { + body.ServerCredentials = &serverCredentials + } + + var resp managementv3.UpdateGuardianFactorsProviderPushNotificationFcmv1ResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.UpdateFcmv1Provider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to update FCM v1 configuration: %w", err) + } + + cli.renderer.GuardianDetail("push fcmv1 configuration updated", [][]string{ + {"SERVER CREDENTIALS", display.MaskSecret(serverCredentials)}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianFcmServerCredentials.RegisterString(cmd, &serverCredentials, "") + + return cmd +} + +func guardianSnsRows(accessKeyID, secretAccessKey, region, apnsArn, gcmArn string) [][]string { + return [][]string{ + {"AWS ACCESS KEY ID", orDashCLI(accessKeyID)}, + {"AWS SECRET ACCESS KEY", display.MaskSecret(secretAccessKey)}, + {"AWS REGION", orDashCLI(region)}, + {"APNS PLATFORM APPLICATION ARN", orDashCLI(apnsArn)}, + {"GCM PLATFORM APPLICATION ARN", orDashCLI(gcmArn)}, + } +} + +func showGuardianPushSnsCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-sns", + Args: cobra.NoArgs, + Short: "Show the SNS configuration", + Long: "Display the Amazon SNS push-notification configuration.", + Example: ` auth0 guardian factors push show-sns --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorsProviderSnsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.GetSnsProvider(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read SNS configuration: %w", err) + } + + cli.renderer.GuardianDetail("push sns configuration", guardianSnsRows( + resp.GetAwsAccessKeyID(), + resp.GetAwsSecretAccessKey(), + resp.GetAwsRegion(), + resp.GetSnsApnsPlatformApplicationArn(), + resp.GetSnsGcmPlatformApplicationArn(), + ), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianPushSnsCmd(cli *cli) *cobra.Command { + var inputs struct { + AccessKeyID string + SecretAccessKey string + Region string + ApnsArn string + GcmArn string + } + + cmd := &cobra.Command{ + Use: "set-sns", + Args: cobra.NoArgs, + Short: "Set the SNS configuration", + Long: "Replace the Amazon SNS push-notification configuration.", + Example: ` auth0 guardian factors push set-sns \ + --aws-access-key-id --aws-secret-access-key --aws-region us-east-1 \ + --apns-platform-arn --gcm-platform-arn `, + RunE: func(cmd *cobra.Command, args []string) error { + if inputs.AccessKeyID == "" && inputs.SecretAccessKey == "" && inputs.Region == "" && + inputs.ApnsArn == "" && inputs.GcmArn == "" { + return fmt.Errorf( + "set replaces the entire SNS configuration, so pass at least one of --aws-access-key-id, " + + "--aws-secret-access-key, --aws-region, --apns-platform-arn or --gcm-platform-arn. " + + "To change a single field, use 'auth0 guardian factors push update-sns'", + ) + } + + body := &managementv3.SetGuardianFactorsProviderPushNotificationSnsRequestContent{} + if inputs.AccessKeyID != "" { + body.AwsAccessKeyID = &inputs.AccessKeyID + } + if inputs.SecretAccessKey != "" { + body.AwsSecretAccessKey = &inputs.SecretAccessKey + } + if inputs.Region != "" { + body.AwsRegion = &inputs.Region + } + if inputs.ApnsArn != "" { + body.SnsApnsPlatformApplicationArn = &inputs.ApnsArn + } + if inputs.GcmArn != "" { + body.SnsGcmPlatformApplicationArn = &inputs.GcmArn + } + + var resp *managementv3.SetGuardianFactorsProviderPushNotificationSnsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.SetSnsProvider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to set SNS configuration: %w", err) + } + + cli.renderer.GuardianDetail("push sns configuration updated", guardianSnsRows( + resp.GetAwsAccessKeyID(), + resp.GetAwsSecretAccessKey(), + resp.GetAwsRegion(), + resp.GetSnsApnsPlatformApplicationArn(), + resp.GetSnsGcmPlatformApplicationArn(), + ), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianSnsAccessKeyID.RegisterString(cmd, &inputs.AccessKeyID, "") + guardianSnsSecretAccessKey.RegisterString(cmd, &inputs.SecretAccessKey, "") + guardianSnsRegion.RegisterString(cmd, &inputs.Region, "") + guardianSnsApnsArn.RegisterString(cmd, &inputs.ApnsArn, "") + guardianSnsGcmArn.RegisterString(cmd, &inputs.GcmArn, "") + + return cmd +} + +func updateGuardianPushSnsCmd(cli *cli) *cobra.Command { + var inputs struct { + AccessKeyID string + SecretAccessKey string + Region string + ApnsArn string + GcmArn string + } + + cmd := &cobra.Command{ + Use: "update-sns", + Args: cobra.NoArgs, + Short: "Update the SNS configuration", + Long: "Partially update the Amazon SNS push-notification configuration. Only the fields you provide " + + "are changed; the rest keep their current values. Run without flags to be prompted for each field, " + + "pre-filled with the current value (leave the secret access key blank to keep it unchanged).", + Example: ` auth0 guardian factors push update-sns --aws-region us-west-2`, + RunE: func(cmd *cobra.Command, args []string) error { + // Fetch the current configuration so the interactive prompts can + // default to the existing values (the secret is never pre-filled). + var current *managementv3.GetGuardianFactorsProviderSnsResponseContent + if err := ansi.Waiting(func() (err error) { + current, err = cli.apiv3.GuardianFactorPush.GetSnsProvider(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read SNS configuration: %w", err) + } + + currentAccessKeyID := current.GetAwsAccessKeyID() + currentRegion := current.GetAwsRegion() + currentApnsArn := current.GetSnsApnsPlatformApplicationArn() + currentGcmArn := current.GetSnsGcmPlatformApplicationArn() + if err := guardianSnsAccessKeyID.AskU(cmd, &inputs.AccessKeyID, ¤tAccessKeyID); err != nil { + return err + } + if err := guardianSnsSecretAccessKey.AskU(cmd, &inputs.SecretAccessKey, nil); err != nil { + return err + } + if err := guardianSnsRegion.AskU(cmd, &inputs.Region, ¤tRegion); err != nil { + return err + } + if err := guardianSnsApnsArn.AskU(cmd, &inputs.ApnsArn, ¤tApnsArn); err != nil { + return err + } + if err := guardianSnsGcmArn.AskU(cmd, &inputs.GcmArn, ¤tGcmArn); err != nil { + return err + } + + body := &managementv3.UpdateGuardianFactorsProviderPushNotificationSnsRequestContent{} + if inputs.AccessKeyID != "" { + body.AwsAccessKeyID = &inputs.AccessKeyID + } + if inputs.SecretAccessKey != "" { + body.AwsSecretAccessKey = &inputs.SecretAccessKey + } + if inputs.Region != "" { + body.AwsRegion = &inputs.Region + } + if inputs.ApnsArn != "" { + body.SnsApnsPlatformApplicationArn = &inputs.ApnsArn + } + if inputs.GcmArn != "" { + body.SnsGcmPlatformApplicationArn = &inputs.GcmArn + } + + if err := ansi.Waiting(func() (err error) { + _, err = cli.apiv3.GuardianFactorPush.UpdateSnsProvider(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to update SNS configuration: %w", err) + } + + // The PATCH response only echoes the fields that were sent, so + // re-fetch the full configuration to render the complete state. + var resp *managementv3.GetGuardianFactorsProviderSnsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorPush.GetSnsProvider(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read SNS configuration: %w", err) + } + + cli.renderer.GuardianDetail("push sns configuration updated", guardianSnsRows( + resp.GetAwsAccessKeyID(), + resp.GetAwsSecretAccessKey(), + resp.GetAwsRegion(), + resp.GetSnsApnsPlatformApplicationArn(), + resp.GetSnsGcmPlatformApplicationArn(), + ), resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianSnsAccessKeyID.RegisterString(cmd, &inputs.AccessKeyID, "") + guardianSnsSecretAccessKey.RegisterString(cmd, &inputs.SecretAccessKey, "") + guardianSnsRegion.RegisterString(cmd, &inputs.Region, "") + guardianSnsApnsArn.RegisterString(cmd, &inputs.ApnsArn, "") + guardianSnsGcmArn.RegisterString(cmd, &inputs.GcmArn, "") + + return cmd +} diff --git a/internal/cli/guardian_factor_sms.go b/internal/cli/guardian_factor_sms.go new file mode 100644 index 000000000..af0730004 --- /dev/null +++ b/internal/cli/guardian_factor_sms.go @@ -0,0 +1,287 @@ +package cli + +import ( + "fmt" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/spf13/cobra" + + "github.com/auth0/auth0-cli/internal/ansi" + "github.com/auth0/auth0-cli/internal/display" +) + +func guardianFactorSmsCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "sms", + Short: "Manage the SMS multi-factor authentication factor (legacy)", + Long: "Manage the SMS MFA factor provider, templates and Twilio configuration.\n\n" + + "These are legacy endpoints. Tenants on the unified phone experience must manage SMS " + + "delivery from the Dashboard (Branding > Phone Provider); they are not available to Management API tokens.", + } + + cmd.SetUsageTemplate(resourceUsageTemplate()) + cmd.AddCommand(showGuardianSmsProviderCmd(cli)) + cmd.AddCommand(setGuardianSmsProviderCmd(cli)) + cmd.AddCommand(showGuardianSmsTemplatesCmd(cli)) + cmd.AddCommand(setGuardianSmsTemplatesCmd(cli)) + cmd.AddCommand(showGuardianSmsTwilioCmd(cli)) + cmd.AddCommand(setGuardianSmsTwilioCmd(cli)) + + return cmd +} + +func showGuardianSmsProviderCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-provider", + Args: cobra.NoArgs, + Short: "Show the SMS provider (legacy)", + Long: "Display the configured SMS MFA provider.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage SMS " + + "delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens.", + Example: ` auth0 guardian factors sms show-provider --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorsProviderSmsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorSms.GetSelectedProvider(cmd.Context()) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to read SMS provider: %w", err)) + } + + cli.renderer.GuardianDetail("sms provider", [][]string{ + {"PROVIDER", string(resp.GetProvider())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianSmsProviderCmd(cli *cli) *cobra.Command { + var provider string + + cmd := &cobra.Command{ + Use: "set-provider", + Args: cobra.NoArgs, + Short: "Set the SMS provider (legacy)", + Long: "Set the SMS MFA provider. One of: auth0, twilio, phone-message-hook.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage SMS " + + "delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens.", + Example: ` auth0 guardian factors sms set-provider --provider twilio + auth0 guardian factors sms set-provider --provider auth0 --json`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianProvider.Select(cmd, &provider, guardianSmsProviderOptions, nil); err != nil { + return err + } + + value, err := managementv3.NewGuardianFactorsProviderSmsProviderEnumFromString(provider) + if err != nil { + return fmt.Errorf("invalid provider %q: valid values are auth0, twilio, phone-message-hook", provider) + } + + body := &managementv3.SetGuardianFactorsProviderSmsRequestContent{Provider: value} + + var resp *managementv3.SetGuardianFactorsProviderSmsResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorSms.SetProvider(cmd.Context(), body) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to set SMS provider: %w", err)) + } + + cli.renderer.GuardianDetail("sms provider updated", [][]string{ + {"PROVIDER", string(resp.GetProvider())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianProvider.RegisterString(cmd, &provider, "") + + return cmd +} + +func showGuardianSmsTemplatesCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-templates", + Args: cobra.NoArgs, + Short: "Show the SMS templates (legacy)", + Long: "Display the SMS enrollment and verification message templates.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage SMS " + + "templates from the Dashboard (Branding > Phone Templates); it is not available to Management API tokens.", + Example: ` auth0 guardian factors sms show-templates --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorSmsTemplatesResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorSms.GetTemplates(cmd.Context()) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to read SMS templates: %w", err)) + } + + cli.renderer.GuardianDetail("sms templates", [][]string{ + {"ENROLLMENT MESSAGE", resp.GetEnrollmentMessage()}, + {"VERIFICATION MESSAGE", resp.GetVerificationMessage()}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianSmsTemplatesCmd(cli *cli) *cobra.Command { + var inputs struct { + EnrollmentMessage string + VerificationMessage string + } + + cmd := &cobra.Command{ + Use: "set-templates", + Args: cobra.NoArgs, + Short: "Set the SMS templates (legacy)", + Long: "Set the SMS enrollment and verification message templates.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage SMS " + + "templates from the Dashboard (Branding > Phone Templates); it is not available to Management API tokens.", + Example: ` auth0 guardian factors sms set-templates \ + --enrollment-message "Your verification code is {{code}}" \ + --verification-message "Your verification code is {{code}}"`, + RunE: func(cmd *cobra.Command, args []string) error { + if err := guardianEnrollmentMessage.Ask(cmd, &inputs.EnrollmentMessage, nil); err != nil { + return err + } + if err := guardianVerificationMessage.Ask(cmd, &inputs.VerificationMessage, nil); err != nil { + return err + } + + body := &managementv3.SetGuardianFactorSmsTemplatesRequestContent{ + EnrollmentMessage: inputs.EnrollmentMessage, + VerificationMessage: inputs.VerificationMessage, + } + + var resp *managementv3.SetGuardianFactorSmsTemplatesResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorSms.SetTemplates(cmd.Context(), body) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to set SMS templates: %w", err)) + } + + cli.renderer.GuardianDetail("sms templates updated", [][]string{ + {"ENROLLMENT MESSAGE", resp.GetEnrollmentMessage()}, + {"VERIFICATION MESSAGE", resp.GetVerificationMessage()}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianEnrollmentMessage.RegisterString(cmd, &inputs.EnrollmentMessage, "") + guardianVerificationMessage.RegisterString(cmd, &inputs.VerificationMessage, "") + + return cmd +} + +func showGuardianSmsTwilioCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show-twilio", + Args: cobra.NoArgs, + Short: "Show the SMS Twilio configuration (legacy)", + Long: "Display the Twilio configuration for the SMS MFA factor.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage SMS " + + "delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens.", + Example: ` auth0 guardian factors sms show-twilio --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var resp *managementv3.GetGuardianFactorsProviderSmsTwilioResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorSms.GetTwilioProvider(cmd.Context()) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to read SMS Twilio configuration: %w", err)) + } + + cli.renderer.GuardianDetail("sms twilio configuration", [][]string{ + {"FROM", resp.GetFrom()}, + {"MESSAGING SERVICE SID", resp.GetMessagingServiceSid()}, + {"SID", resp.GetSid()}, + {"AUTH TOKEN", display.MaskSecret(resp.GetAuthToken())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + + return cmd +} + +func setGuardianSmsTwilioCmd(cli *cli) *cobra.Command { + var inputs struct { + From string + MessagingServiceSid string + Sid string + AuthToken string + } + + cmd := &cobra.Command{ + Use: "set-twilio", + Args: cobra.NoArgs, + Short: "Set the SMS Twilio configuration (legacy)", + Long: "Set the Twilio configuration for the SMS MFA factor.\n\n" + + "This is a legacy endpoint. Tenants on the unified phone experience must manage SMS " + + "delivery from the Dashboard (Branding > Phone Provider); it is not available to Management API tokens.", + Example: ` auth0 guardian factors sms set-twilio --sid AC... --auth-token --from "+14155550100" + auth0 guardian factors sms set-twilio --sid AC... --auth-token --messaging-service-sid MG...`, + RunE: func(cmd *cobra.Command, args []string) error { + body := &managementv3.SetGuardianFactorsProviderSmsTwilioRequestContent{} + if inputs.From != "" { + body.From = &inputs.From + } + if inputs.MessagingServiceSid != "" { + body.MessagingServiceSid = &inputs.MessagingServiceSid + } + if inputs.Sid != "" { + body.Sid = &inputs.Sid + } + if inputs.AuthToken != "" { + body.AuthToken = &inputs.AuthToken + } + + var resp *managementv3.SetGuardianFactorsProviderSmsTwilioResponseContent + if err := ansi.Waiting(func() (err error) { + resp, err = cli.apiv3.GuardianFactorSms.SetTwilioProvider(cmd.Context(), body) + return err + }); err != nil { + return guardianLegacyPhoneHint(fmt.Errorf("failed to set SMS Twilio configuration: %w", err)) + } + + cli.renderer.GuardianDetail("sms twilio configuration updated", [][]string{ + {"FROM", resp.GetFrom()}, + {"MESSAGING SERVICE SID", resp.GetMessagingServiceSid()}, + {"SID", resp.GetSid()}, + {"AUTH TOKEN", display.MaskSecret(resp.GetAuthToken())}, + }, resp) + + return nil + }, + } + + registerGuardianJSONFlags(cli, cmd) + guardianTwilioFrom.RegisterString(cmd, &inputs.From, "") + guardianTwilioMessagingServiceSid.RegisterString(cmd, &inputs.MessagingServiceSid, "") + guardianTwilioSid.RegisterString(cmd, &inputs.Sid, "") + guardianTwilioAuthToken.RegisterString(cmd, &inputs.AuthToken, "") + + return cmd +} diff --git a/internal/cli/guardian_factors.go b/internal/cli/guardian_factors.go new file mode 100644 index 000000000..6edf6edbe --- /dev/null +++ b/internal/cli/guardian_factors.go @@ -0,0 +1,142 @@ +package cli + +import ( + "fmt" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/spf13/cobra" + + "github.com/auth0/auth0-cli/internal/ansi" +) + +var guardianFactorNameOptions = []string{ + string(managementv3.GuardianFactorNameEnumSms), + string(managementv3.GuardianFactorNameEnumPushNotification), + string(managementv3.GuardianFactorNameEnumEmail), + string(managementv3.GuardianFactorNameEnumOtp), + string(managementv3.GuardianFactorNameEnumDuo), + string(managementv3.GuardianFactorNameEnumWebauthnRoaming), + string(managementv3.GuardianFactorNameEnumWebauthnPlatform), + string(managementv3.GuardianFactorNameEnumRecoveryCode), +} + +var ( + guardianFactorName = Argument{ + Name: "Factor", + Help: "Name of the factor. One of: sms, push-notification, email, otp, duo, webauthn-roaming, webauthn-platform, recovery-code.", + } + guardianFactorEnabled = Flag{ + Name: "Enabled", + LongForm: "enabled", + Help: "Whether the factor is enabled.", + } +) + +func guardianFactorsCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "factors", + Short: "Manage multi-factor authentication factors", + Long: "Manage multi-factor authentication (MFA) factors and their providers.", + } + + cmd.SetUsageTemplate(resourceUsageTemplate()) + cmd.AddCommand(listGuardianFactorsCmd(cli)) + cmd.AddCommand(setGuardianFactorCmd(cli)) + cmd.AddCommand(guardianFactorPhoneCmd(cli)) + cmd.AddCommand(guardianFactorSmsCmd(cli)) + cmd.AddCommand(guardianFactorPushCmd(cli)) + cmd.AddCommand(guardianFactorDuoCmd(cli)) + + return cmd +} + +func listGuardianFactorsCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Args: cobra.NoArgs, + Short: "List multi-factor authentication factors", + Long: "List all MFA factors and their enabled/disabled status.", + Aliases: []string{"ls"}, + Example: ` auth0 guardian factors list + auth0 guardian factors ls + auth0 guardian factors list --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var factors []*managementv3.GuardianFactor + if err := ansi.Waiting(func() (err error) { + factors, err = cli.apiv3.GuardianFactor.List(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to list guardian factors: %w", err) + } + + cli.renderer.GuardianFactorList(factors) + + return nil + }, + } + + cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") + cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") + cmd.MarkFlagsMutuallyExclusive("json", "json-compact") + + return cmd +} + +func setGuardianFactorCmd(cli *cli) *cobra.Command { + var inputs struct { + Factor string + Enabled bool + } + + cmd := &cobra.Command{ + Use: "set", + Args: cobra.MaximumNArgs(1), + Short: "Enable or disable a multi-factor authentication factor", + Long: "Enable or disable a single MFA factor.", + Example: ` auth0 guardian factors set sms --enabled + auth0 guardian factors set email --enabled=false + auth0 guardian factors set push-notification --enabled --json`, + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) == 0 { + if err := guardianFactorName.Pick(cmd, &inputs.Factor, staticPickerOptions(guardianFactorNameOptions)); err != nil { + return err + } + } else { + inputs.Factor = args[0] + } + + factor, err := managementv3.NewGuardianFactorNameEnumFromString(inputs.Factor) + if err != nil { + return fmt.Errorf("invalid factor %q: %w", inputs.Factor, err) + } + + if !guardianFactorEnabled.IsSet(cmd) { + if err := guardianFactorEnabled.AskBool(cmd, &inputs.Enabled, nil); err != nil { + return err + } + } + + body := &managementv3.SetGuardianFactorRequestContent{Enabled: inputs.Enabled} + + var result *managementv3.SetGuardianFactorResponseContent + if err := ansi.Waiting(func() (err error) { + result, err = cli.apiv3.GuardianFactor.Set(cmd.Context(), &factor, body) + return err + }); err != nil { + return fmt.Errorf("failed to set guardian factor %q: %w", inputs.Factor, err) + } + + cli.renderer.GuardianFactorSet(result, inputs.Factor) + + return nil + }, + } + + cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") + cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") + cmd.MarkFlagsMutuallyExclusive("json", "json-compact") + + guardianFactorEnabled.RegisterBool(cmd, &inputs.Enabled, false) + + return cmd +} diff --git a/internal/cli/guardian_factors_providers.go b/internal/cli/guardian_factors_providers.go new file mode 100644 index 000000000..e033804f6 --- /dev/null +++ b/internal/cli/guardian_factors_providers.go @@ -0,0 +1,183 @@ +package cli + +import ( + "context" + "strings" + + managementv3 "github.com/auth0/go-auth0/v3/management" +) + +// staticPickerOptions returns a pickerOptionsFunc over a fixed set of string +// values, used for interactive multi-select of enum values. +func staticPickerOptions(values []string) pickerOptionsFunc { + return func(_ context.Context) (pickerOptions, error) { + var opts pickerOptions + for _, v := range values { + opts = append(opts, pickerOption{value: v, label: v}) + } + return opts, nil + } +} + +// messageTypesForDisplay renders a list of phone message types for output. +func messageTypesForDisplay(types []managementv3.GuardianFactorPhoneFactorMessageTypeEnum) string { + if len(types) == 0 { + return "-" + } + values := make([]string, 0, len(types)) + for _, t := range types { + values = append(values, string(t)) + } + return strings.Join(values, ", ") +} + +// Provider selection option lists. +var ( + guardianSmsProviderOptions = []string{ + string(managementv3.GuardianFactorsProviderSmsProviderEnumAuth0), + string(managementv3.GuardianFactorsProviderSmsProviderEnumTwilio), + string(managementv3.GuardianFactorsProviderSmsProviderEnumPhoneMessageHook), + } + guardianPushProviderOptions = []string{ + string(managementv3.GuardianFactorsProviderPushNotificationProviderDataEnumGuardian), + string(managementv3.GuardianFactorsProviderPushNotificationProviderDataEnumSns), + string(managementv3.GuardianFactorsProviderPushNotificationProviderDataEnumDirect), + } + guardianMessageTypeOptions = []string{ + string(managementv3.GuardianFactorPhoneFactorMessageTypeEnumSms), + string(managementv3.GuardianFactorPhoneFactorMessageTypeEnumVoice), + } +) + +// Shared flags reused across the phone, sms, push and duo provider commands. +// Each command registers only the flags it needs, so sharing the definitions is +// safe and keeps help text consistent. +var ( + guardianProvider = Flag{ + Name: "Provider", + LongForm: "provider", + ShortForm: "p", + Help: "Provider to use for the factor.", + } + guardianMessageType = Flag{ + Name: "Message Type", + LongForm: "message-type", + Help: "Message type to enable. Repeat the flag for multiple types. Supported values: sms, voice.", + } + guardianEnrollmentMessage = Flag{ + Name: "Enrollment Message", + LongForm: "enrollment-message", + Help: "Message sent to the user when they enroll.", + } + guardianVerificationMessage = Flag{ + Name: "Verification Message", + LongForm: "verification-message", + Help: "Message sent to the user when they verify.", + } + + // Twilio. + guardianTwilioFrom = Flag{ + Name: "From", + LongForm: "from", + Help: "Twilio 'from' phone number.", + } + guardianTwilioMessagingServiceSid = Flag{ + Name: "Messaging Service SID", + LongForm: "messaging-service-sid", + Help: "Twilio messaging service SID.", + } + guardianTwilioSid = Flag{ + Name: "SID", + LongForm: "sid", + Help: "Twilio account SID.", + } + guardianTwilioAuthToken = Flag{ + Name: "Auth Token", + LongForm: "auth-token", + Help: "Twilio authentication token.", + } + + // APNs. + guardianApnsBundleID = Flag{ + Name: "Bundle ID", + LongForm: "bundle-id", + Help: "Apple app bundle identifier.", + AlwaysPrompt: true, + } + guardianApnsSandbox = Flag{ + Name: "Sandbox", + LongForm: "sandbox", + Help: "Whether to use the APNs sandbox environment.", + AlwaysPrompt: true, + } + guardianApnsP12 = Flag{ + Name: "P12", + LongForm: "p12", + Help: "Base64-encoded .p12 certificate for APNs.", + AlwaysPrompt: true, + } + + // FCM. + guardianFcmServerKey = Flag{ + Name: "Server Key", + LongForm: "server-key", + Help: "Google FCM (legacy) server key.", + } + guardianFcmServerCredentials = Flag{ + Name: "Server Credentials", + LongForm: "server-credentials", + Help: "Google FCM v1 service account credentials (JSON).", + } + + // SNS. + guardianSnsAccessKeyID = Flag{ + Name: "AWS Access Key ID", + LongForm: "aws-access-key-id", + Help: "AWS access key ID for SNS.", + AlwaysPrompt: true, + } + guardianSnsSecretAccessKey = Flag{ + Name: "AWS Secret Access Key", + LongForm: "aws-secret-access-key", + Help: "AWS secret access key for SNS.", + AlwaysPrompt: true, + } + guardianSnsRegion = Flag{ + Name: "AWS Region", + LongForm: "aws-region", + Help: "AWS region for SNS.", + AlwaysPrompt: true, + } + guardianSnsApnsArn = Flag{ + Name: "APNs Platform Application ARN", + LongForm: "apns-platform-arn", + Help: "SNS APNs platform application ARN.", + AlwaysPrompt: true, + } + guardianSnsGcmArn = Flag{ + Name: "GCM Platform Application ARN", + LongForm: "gcm-platform-arn", + Help: "SNS GCM platform application ARN.", + AlwaysPrompt: true, + } + + // Duo. + guardianDuoIkey = Flag{ + Name: "Integration Key", + LongForm: "ikey", + Help: "Duo integration key.", + AlwaysPrompt: true, + } + guardianDuoSkey = Flag{ + Name: "Secret Key", + LongForm: "skey", + Help: "Duo secret key.", + AlwaysPrompt: true, + } + guardianDuoHost = Flag{ + Name: "API Hostname", + LongForm: "host", + Help: "Duo API hostname.", + AlwaysPrompt: true, + } +) diff --git a/internal/cli/guardian_policies.go b/internal/cli/guardian_policies.go new file mode 100644 index 000000000..bd9060e60 --- /dev/null +++ b/internal/cli/guardian_policies.go @@ -0,0 +1,141 @@ +package cli + +import ( + "fmt" + + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/spf13/cobra" + + "github.com/auth0/auth0-cli/internal/ansi" +) + +// guardianPolicyNone is the interactive/CLI value that clears all MFA policies. +// The two real policies are mutually exclusive, so the CLI treats the policy as +// a single choice (all-applications, confidence-score or none) even though the +// Management API models it as a list. +const guardianPolicyNone = "none" + +var guardianPolicyOptions = []string{ + string(managementv3.MfaPolicyEnumAllApplications), + string(managementv3.MfaPolicyEnumConfidenceScore), + guardianPolicyNone, +} + +var guardianPolicies = Flag{ + Name: "Policy", + LongForm: "policy", + ShortForm: "p", + Help: "MFA policy to enable. Supported values: all-applications, confidence-score. " + + "The policies are mutually exclusive; pass none (or --none) to clear all policies.", +} + +var guardianPoliciesNone = Flag{ + Name: "None", + LongForm: "none", + Help: "Clear all MFA policies.", +} + +func guardianPoliciesCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "policies", + Short: "Manage multi-factor authentication policies", + Long: "Manage the tenant-wide multi-factor authentication (MFA) policies.", + } + + cmd.SetUsageTemplate(resourceUsageTemplate()) + cmd.AddCommand(showGuardianPoliciesCmd(cli)) + cmd.AddCommand(setGuardianPoliciesCmd(cli)) + + return cmd +} + +func showGuardianPoliciesCmd(cli *cli) *cobra.Command { + cmd := &cobra.Command{ + Use: "show", + Args: cobra.NoArgs, + Short: "Show the multi-factor authentication policies", + Long: "Display the tenant-wide multi-factor authentication (MFA) policies.", + Example: ` auth0 guardian policies show + auth0 guardian policies show --json`, + RunE: func(cmd *cobra.Command, args []string) error { + var policies managementv3.ListGuardianPoliciesResponseContent + if err := ansi.Waiting(func() (err error) { + policies, err = cli.apiv3.GuardianPolicy.List(cmd.Context()) + return err + }); err != nil { + return fmt.Errorf("failed to read guardian policies: %w", err) + } + + cli.renderer.GuardianPolicyList(policies) + + return nil + }, + } + + cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") + cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") + cmd.MarkFlagsMutuallyExclusive("json", "json-compact") + + return cmd +} + +func setGuardianPoliciesCmd(cli *cli) *cobra.Command { + var inputs struct { + Policy string + None bool + } + + cmd := &cobra.Command{ + Use: "set", + Args: cobra.NoArgs, + Short: "Set the multi-factor authentication policy", + Long: "Set the tenant-wide multi-factor authentication (MFA) policy.\n\n" + + "The policies are mutually exclusive, so this sets a single policy and replaces the " + + "existing one. Pass `--policy none` or `--none` (or select none interactively) to clear " + + "the policy.", + Example: ` auth0 guardian policies set + auth0 guardian policies set --policy all-applications + auth0 guardian policies set --policy confidence-score + auth0 guardian policies set --none + auth0 guardian policies set --policy all-applications --json`, + RunE: func(cmd *cobra.Command, args []string) error { + // Interactively pick a policy unless the user passed --policy or --none. + if !guardianPolicies.IsSet(cmd) && !inputs.None && canPrompt(cmd) { + if err := guardianPolicies.Select(cmd, &inputs.Policy, guardianPolicyOptions, nil); err != nil { + return err + } + } + + body := make(managementv3.SetGuardianPoliciesRequestContent, 0, 1) + if !inputs.None && inputs.Policy != "" && inputs.Policy != guardianPolicyNone { + policy, err := managementv3.NewMfaPolicyEnumFromString(inputs.Policy) + if err != nil { + return fmt.Errorf("invalid policy %q: valid values are all-applications, confidence-score, none", inputs.Policy) + } + body = append(body, policy) + } + + var policies managementv3.SetGuardianPoliciesResponseContent + if err := ansi.Waiting(func() (err error) { + policies, err = cli.apiv3.GuardianPolicy.Set(cmd.Context(), body) + return err + }); err != nil { + return fmt.Errorf("failed to set guardian policies: %w", err) + } + + cli.renderer.GuardianPolicyList(policies) + + return nil + }, + } + + cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.") + cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.") + cmd.MarkFlagsMutuallyExclusive("json", "json-compact") + + guardianPolicies.RegisterString(cmd, &inputs.Policy, "") + guardianPoliciesNone.RegisterBool(cmd, &inputs.None, false) + cmd.MarkFlagsMutuallyExclusive("policy", "none") + + return cmd +} diff --git a/internal/cli/root.go b/internal/cli/root.go index 9e472aac6..c060b0cd6 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -306,6 +306,7 @@ func addSubCommands(rootCmd *cobra.Command, cli *cli) { rootCmd.AddCommand(tokenExchangeCmd(cli)) rootCmd.AddCommand(sessionsCmd(cli)) rootCmd.AddCommand(refreshTokensCmd(cli)) + rootCmd.AddCommand(guardianCmd(cli)) rootCmd.AddCommand(commandsCmd(cli)) rootCmd.AddCommand(agentCmd(cli)) diff --git a/internal/display/guardian.go b/internal/display/guardian.go new file mode 100644 index 000000000..219fa3e8f --- /dev/null +++ b/internal/display/guardian.go @@ -0,0 +1,231 @@ +package display + +import ( + "fmt" + + managementv3 "github.com/auth0/go-auth0/v3/management" + + "github.com/auth0/auth0-cli/internal/ansi" +) + +// guardianFactorView renders a single MFA factor and its enabled status. +type guardianFactorView struct { + Name string + Enabled string + + raw interface{} +} + +func (v *guardianFactorView) AsTableHeader() []string { + return []string{"Factor", "Status"} +} + +func (v *guardianFactorView) AsTableRow() []string { + return []string{v.Name, v.Enabled} +} + +func (v *guardianFactorView) KeyValues() [][]string { + return [][]string{ + {"FACTOR", v.Name}, + {"STATUS", v.Enabled}, + } +} + +func (v *guardianFactorView) Object() interface{} { + return v.raw +} + +func (r *Renderer) GuardianFactorList(factors []*managementv3.GuardianFactor) { + resource := "guardian factors" + + r.Heading(fmt.Sprintf("%s (%d)", resource, len(factors))) + + if len(factors) == 0 { + r.EmptyState(resource, "No MFA factors found") + return + } + + var results []View + for _, factor := range factors { + results = append(results, &guardianFactorView{ + Name: string(factor.GetName()), + Enabled: enabledStatus(factor.GetEnabled()), + raw: factor, + }) + } + + r.Results(results) +} + +func (r *Renderer) GuardianFactorSet(factor *managementv3.SetGuardianFactorResponseContent, name string) { + r.Heading("guardian factor updated") + r.Result(&guardianFactorView{ + Name: name, + Enabled: enabledStatus(factor.GetEnabled()), + raw: factor, + }) +} + +// guardianPolicyView renders the tenant MFA policy list. +type guardianPolicyView struct { + Policy string + + raw interface{} +} + +func (v *guardianPolicyView) AsTableHeader() []string { return []string{"Policy"} } +func (v *guardianPolicyView) AsTableRow() []string { return []string{v.Policy} } +func (v *guardianPolicyView) KeyValues() [][]string { return [][]string{{"POLICY", v.Policy}} } +func (v *guardianPolicyView) Object() interface{} { return v.raw } + +func (r *Renderer) GuardianPolicyList(policies []managementv3.MfaPolicyEnum) { + resource := "guardian policies" + + r.Heading(fmt.Sprintf("%s (%d)", resource, len(policies))) + + if len(policies) == 0 { + r.EmptyState(resource, "No MFA policies configured") + return + } + + var results []View + for _, policy := range policies { + results = append(results, &guardianPolicyView{Policy: string(policy), raw: policy}) + } + + r.Results(results) +} + +// guardianEnrollmentView renders a single MFA enrollment. +type guardianEnrollmentView struct { + ID string + Status string + Name string + Identifier string + Phone string + EnrolledAt string + LastAuth string + + raw interface{} +} + +func (v *guardianEnrollmentView) AsTableHeader() []string { + return []string{"ID", "Status", "Name", "Identifier"} +} + +func (v *guardianEnrollmentView) AsTableRow() []string { + return []string{ansi.Faint(v.ID), v.Status, v.Name, v.Identifier} +} + +func (v *guardianEnrollmentView) KeyValues() [][]string { + return [][]string{ + {"ID", ansi.Faint(v.ID)}, + {"STATUS", v.Status}, + {"NAME", v.Name}, + {"IDENTIFIER", v.Identifier}, + {"PHONE NUMBER", v.Phone}, + {"ENROLLED AT", v.EnrolledAt}, + {"LAST AUTH", v.LastAuth}, + } +} + +func (v *guardianEnrollmentView) Object() interface{} { return v.raw } + +func (r *Renderer) GuardianEnrollmentShow(enrollment *managementv3.GetGuardianEnrollmentResponseContent) { + r.Heading("guardian enrollment") + r.Result(&guardianEnrollmentView{ + ID: enrollment.GetID(), + Status: string(enrollment.GetStatus()), + Name: orDash(enrollment.GetName()), + Identifier: orDash(enrollment.GetIdentifier()), + Phone: orDash(enrollment.GetPhoneNumber()), + EnrolledAt: orDash(enrollment.GetEnrolledAt()), + LastAuth: orDash(enrollment.GetLastAuth()), + raw: enrollment, + }) +} + +// guardianEnrollmentTicketView renders a created enrollment ticket. The ticket +// URL is the actionable artifact the user shares with the enrollee. +type guardianEnrollmentTicketView struct { + TicketID string + TicketURL string + + raw interface{} +} + +func (v *guardianEnrollmentTicketView) AsTableHeader() []string { + return []string{"Ticket ID", "Ticket URL"} +} + +func (v *guardianEnrollmentTicketView) AsTableRow() []string { + return []string{ansi.Faint(v.TicketID), v.TicketURL} +} + +func (v *guardianEnrollmentTicketView) KeyValues() [][]string { + return [][]string{ + {"TICKET ID", ansi.Faint(v.TicketID)}, + {"TICKET URL", v.TicketURL}, + } +} + +func (v *guardianEnrollmentTicketView) Object() interface{} { return v.raw } + +func (r *Renderer) GuardianEnrollmentTicketCreate(ticket *managementv3.CreateGuardianEnrollmentTicketResponseContent) { + r.Heading("guardian enrollment ticket created") + r.Result(&guardianEnrollmentTicketView{ + TicketID: ticket.GetTicketID(), + TicketURL: ticket.GetTicketURL(), + raw: ticket, + }) +} + +// guardianDetailView renders an arbitrary key/value detail for the Guardian +// factor provider configuration commands. Callers compose the rows (masking +// secrets with MaskSecret) and pass the raw SDK response for --json output. +type guardianDetailView struct { + rows [][]string + raw interface{} +} + +func (v *guardianDetailView) AsTableHeader() []string { return []string{} } +func (v *guardianDetailView) AsTableRow() []string { + row := make([]string, 0, len(v.rows)) + for _, kv := range v.rows { + row = append(row, kv[1]) + } + return row +} +func (v *guardianDetailView) KeyValues() [][]string { return v.rows } +func (v *guardianDetailView) Object() interface{} { return v.raw } + +// GuardianDetail renders a titled key/value detail for a Guardian factor +// provider configuration response. +func (r *Renderer) GuardianDetail(heading string, rows [][]string, raw interface{}) { + r.Heading(heading) + r.Result(&guardianDetailView{rows: rows, raw: raw}) +} + +func orDash(value string) string { + if value == "" { + return "-" + } + return value +} + +func enabledStatus(enabled bool) string { + if enabled { + return ansi.Green("enabled") + } + return ansi.Faint("disabled") +} + +// MaskSecret masks a stored secret for display. It never reveals the value, +// only whether one is set. This keeps credentials out of terminal output and +// logs, per the CLI's secret-handling rules. +func MaskSecret(value string) string { + if value == "" { + return ansi.Faint("(not set)") + } + return "•••••••• " + ansi.Faint("(set)") +} diff --git a/internal/display/guardian_test.go b/internal/display/guardian_test.go new file mode 100644 index 000000000..f732c5786 --- /dev/null +++ b/internal/display/guardian_test.go @@ -0,0 +1,53 @@ +package display + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMaskSecret(t *testing.T) { + t.Run("renders a not-set placeholder for an empty secret", func(t *testing.T) { + assert.Contains(t, MaskSecret(""), "(not set)") + }) + + t.Run("never reveals a set secret", func(t *testing.T) { + masked := MaskSecret("super-secret-value") + assert.NotContains(t, masked, "super-secret-value") + assert.Contains(t, masked, "(set)") + assert.Contains(t, masked, "••••••••") + }) +} + +func TestOrDash(t *testing.T) { + assert.Equal(t, "-", orDash("")) + assert.Equal(t, "value", orDash("value")) +} + +func TestEnabledStatus(t *testing.T) { + assert.Contains(t, enabledStatus(true), "enabled") + assert.Contains(t, enabledStatus(false), "disabled") +} + +func TestGuardianFactorView(t *testing.T) { + view := &guardianFactorView{Name: "sms", Enabled: "enabled"} + + assert.Equal(t, []string{"Factor", "Status"}, view.AsTableHeader()) + assert.Equal(t, []string{"sms", "enabled"}, view.AsTableRow()) + assert.Equal(t, [][]string{ + {"FACTOR", "sms"}, + {"STATUS", "enabled"}, + }, view.KeyValues()) +} + +func TestGuardianDetailView(t *testing.T) { + rows := [][]string{ + {"PROVIDER", "twilio"}, + {"AUTH TOKEN", MaskSecret("token")}, + } + view := &guardianDetailView{rows: rows, raw: map[string]string{"provider": "twilio"}} + + assert.Equal(t, rows, view.KeyValues()) + assert.Equal(t, []string{"twilio", MaskSecret("token")}, view.AsTableRow()) + assert.Equal(t, map[string]string{"provider": "twilio"}, view.Object()) +} diff --git a/test/integration/guardian-test-cases.yaml b/test/integration/guardian-test-cases.yaml new file mode 100644 index 000000000..10c1cae08 --- /dev/null +++ b/test/integration/guardian-test-cases.yaml @@ -0,0 +1,495 @@ +config: + inherit-env: true + retries: 1 + +tests: + # ---------------------------------------------------------------------------- + # Factors: list and enable/disable for every supported factor value. + # ---------------------------------------------------------------------------- + 001 - guardian factors list: + command: auth0 guardian factors list + exit-code: 0 + stdout: + contains: + - FACTOR + - STATUS + + 002 - guardian factors list (json): + command: auth0 guardian factors list --json + exit-code: 0 + stdout: + contains: + - '"name"' + - '"enabled"' + + 003 - guardian factors set sms enabled: + command: auth0 guardian factors set sms --enabled + exit-code: 0 + stdout: + contains: + - sms + - enabled + + 004 - guardian factors set push-notification enabled: + command: auth0 guardian factors set push-notification --enabled + exit-code: 0 + stdout: + contains: + - push-notification + - enabled + + 005 - guardian factors set otp enabled: + command: auth0 guardian factors set otp --enabled + exit-code: 0 + stdout: + contains: + - otp + - enabled + + 006 - guardian factors set duo enabled: + command: auth0 guardian factors set duo --enabled + exit-code: 0 + stdout: + contains: + - duo + - enabled + + 007 - guardian factors set webauthn-roaming enabled: + command: auth0 guardian factors set webauthn-roaming --enabled + exit-code: 0 + stdout: + contains: + - webauthn-roaming + - enabled + + 008 - guardian factors set webauthn-platform enabled: + command: auth0 guardian factors set webauthn-platform --enabled + exit-code: 0 + stdout: + contains: + - webauthn-platform + - enabled + + 009 - guardian factors set recovery-code enabled: + command: auth0 guardian factors set recovery-code --enabled + exit-code: 0 + stdout: + contains: + - recovery-code + - enabled + + 010 - guardian factors set email enabled: + command: auth0 guardian factors set email --enabled + exit-code: 0 + stdout: + contains: + - email + - enabled + + 011 - guardian factors set otp disabled: + command: auth0 guardian factors set otp --enabled=false + exit-code: 0 + stdout: + contains: + - otp + - disabled + + 012 - guardian factors set otp enabled (json): + command: auth0 guardian factors set otp --enabled --json + exit-code: 0 + stdout: + contains: + - '"enabled"' + + 013 - guardian factors set invalid factor fails: + command: auth0 guardian factors set bogus-factor --enabled + exit-code: 1 + stderr: + contains: + - 'Invalid factor' + + # ---------------------------------------------------------------------------- + # Policies: mutually-exclusive single value plus the clear paths. + # ---------------------------------------------------------------------------- + 014 - guardian policies show: + command: auth0 guardian policies show + exit-code: 0 + + 015 - guardian policies show (json): + command: auth0 guardian policies show --json + exit-code: 0 + + 016 - guardian policies set all-applications: + command: auth0 guardian policies set --policy all-applications + exit-code: 0 + stdout: + contains: + - POLICY + - all-applications + + 017 - guardian policies set confidence-score: + command: auth0 guardian policies set --policy confidence-score + exit-code: 0 + stdout: + contains: + - POLICY + - confidence-score + + 018 - guardian policies set policy none clears: + command: auth0 guardian policies set --policy none + exit-code: 0 + + 019 - guardian policies set --none clears: + command: auth0 guardian policies set --none + exit-code: 0 + + 020 - guardian policies set invalid value fails: + command: auth0 guardian policies set --policy bogus + exit-code: 1 + stderr: + contains: + - 'valid values are all-applications, confidence-score, none' + + # ---------------------------------------------------------------------------- + # Enrollments: error paths (create/show/delete require real users/enrollments). + # ---------------------------------------------------------------------------- + 021 - guardian enrollments show unknown id fails: + command: auth0 guardian enrollments show dev_invalid_enrollment_id + exit-code: 1 + stderr: + contains: + - read guardian enrollment with ID + + 022 - guardian enrollments delete unknown id fails: + command: auth0 guardian enrollments delete dev_invalid_enrollment_id --force + exit-code: 1 + stderr: + contains: + - delete guardian enrollment with ID + + 023 - guardian enrollments create-ticket unknown user fails: + command: auth0 guardian enrollments create-ticket --user-id "auth0|000000000000000000000000" + exit-code: 1 + stderr: + contains: + - create guardian enrollment ticket for user + + # ---------------------------------------------------------------------------- + # Phone factor: message-types work; provider/templates/twilio are the legacy + # MFA endpoints Auth0 deprecated in favour of Tenant Phone Settings, so they + # surface a clean 403 with the legacy_mfa_phone_provider_not_allowed code. + # ---------------------------------------------------------------------------- + 024 - guardian factors phone show-message-types: + command: auth0 guardian factors phone show-message-types + exit-code: 0 + stdout: + contains: + - MESSAGE TYPES + + 025 - guardian factors phone set-message-types sms: + command: auth0 guardian factors phone set-message-types --message-type sms + exit-code: 0 + stdout: + contains: + - MESSAGE TYPES + - sms + + 026 - guardian factors phone set-message-types voice: + command: auth0 guardian factors phone set-message-types --message-type voice + exit-code: 0 + stdout: + contains: + - MESSAGE TYPES + - voice + + 027 - guardian factors phone set-message-types sms and voice: + command: auth0 guardian factors phone set-message-types --message-type sms --message-type voice + exit-code: 0 + stdout: + contains: + - MESSAGE TYPES + - sms + - voice + + 028 - guardian factors phone show-provider is deprecated: + command: auth0 guardian factors phone show-provider + exit-code: 1 + stderr: + contains: + - legacy_mfa_phone_provider_not_allowed + + 029 - guardian factors phone show-templates is deprecated: + command: auth0 guardian factors phone show-templates + exit-code: 1 + stderr: + contains: + - legacy_mfa_phone_provider_not_allowed + + 030 - guardian factors phone show-twilio is deprecated: + command: auth0 guardian factors phone show-twilio + exit-code: 1 + stderr: + contains: + - legacy_mfa_phone_provider_not_allowed + + # ---------------------------------------------------------------------------- + # SMS factor: provider/templates/twilio share the same legacy deprecation. + # ---------------------------------------------------------------------------- + 031 - guardian factors sms show-provider is deprecated: + command: auth0 guardian factors sms show-provider + exit-code: 1 + stderr: + contains: + - legacy_mfa_phone_provider_not_allowed + + 032 - guardian factors sms show-templates is deprecated: + command: auth0 guardian factors sms show-templates + exit-code: 1 + stderr: + contains: + - legacy_mfa_phone_provider_not_allowed + + 033 - guardian factors sms show-twilio is deprecated: + command: auth0 guardian factors sms show-twilio + exit-code: 1 + stderr: + contains: + - legacy_mfa_phone_provider_not_allowed + + # ---------------------------------------------------------------------------- + # Push factor: provider selection plus APNs, FCM, FCM v1 and SNS config. + # ---------------------------------------------------------------------------- + 034 - guardian factors push show-provider: + command: auth0 guardian factors push show-provider + exit-code: 0 + stdout: + contains: + - PROVIDER + + 035 - guardian factors push set-provider sns: + command: auth0 guardian factors push set-provider --provider sns + exit-code: 0 + stdout: + contains: + - PROVIDER + - sns + + 036 - guardian factors push set-provider direct: + command: auth0 guardian factors push set-provider --provider direct + exit-code: 0 + stdout: + contains: + - PROVIDER + - direct + + 037 - guardian factors push set-provider guardian: + command: auth0 guardian factors push set-provider --provider guardian + exit-code: 0 + stdout: + contains: + - PROVIDER + - guardian + + 038 - guardian factors push set-provider invalid fails: + command: auth0 guardian factors push set-provider --provider bogus + exit-code: 1 + stderr: + contains: + - 'valid values are guardian, sns, direct' + + 039 - guardian factors push show-apns: + command: auth0 guardian factors push show-apns + exit-code: 0 + stdout: + contains: + - BUNDLE ID + - SANDBOX + + 040 - guardian factors push set-apns: + command: auth0 guardian factors push set-apns --sandbox --bundle-id com.example.app + exit-code: 0 + stdout: + contains: + - BUNDLE ID + - com.example.app + - SANDBOX + + 041 - guardian factors push update-apns sandbox only: + command: auth0 guardian factors push update-apns --sandbox=false + exit-code: 0 + stdout: + contains: + - SANDBOX + + 042 - guardian factors push show-sns: + command: auth0 guardian factors push show-sns + exit-code: 0 + stdout: + contains: + - AWS ACCESS KEY ID + - AWS REGION + + 043 - guardian factors push set-sns masks the secret in its response: + command: auth0 guardian factors push set-sns --aws-access-key-id AKIAEXAMPLE --aws-secret-access-key secretexample --aws-region us-east-1 --apns-platform-arn arn:aws:sns:us-east-1:apns --gcm-platform-arn arn:aws:sns:us-east-1:gcm + exit-code: 0 + stdout: + contains: + - AWS ACCESS KEY ID + - AKIAEXAMPLE + - AWS REGION + - us-east-1 + - AWS SECRET ACCESS KEY + - (set) + not-contains: + - secretexample + + 044 - guardian factors push show-sns does not echo the secret: + command: auth0 guardian factors push show-sns + exit-code: 0 + stdout: + contains: + - AWS SECRET ACCESS KEY + - (not set) + not-contains: + - secretexample + + 045 - guardian factors push update-sns region only: + command: auth0 guardian factors push update-sns --aws-region us-west-2 + exit-code: 0 + stdout: + contains: + - AWS REGION + - us-west-2 + + 046 - guardian factors push set-fcm masks the server key: + command: auth0 guardian factors push set-fcm --server-key dummy-server-key + exit-code: 0 + stdout: + contains: + - SERVER KEY + - (set) + not-contains: + - dummy-server-key + + 047 - guardian factors push update-fcm masks the server key: + command: auth0 guardian factors push update-fcm --server-key another-dummy-key + exit-code: 0 + stdout: + contains: + - SERVER KEY + - (set) + not-contains: + - another-dummy-key + + 048 - guardian factors push set-fcmv1 validates credentials: + command: auth0 guardian factors push set-fcmv1 --server-credentials '{"type":"service_account"}' + exit-code: 1 + stderr: + contains: + - set FCM v1 configuration + + # ---------------------------------------------------------------------------- + # Duo factor settings: show, replace and partial update. + # ---------------------------------------------------------------------------- + 049 - guardian factors duo settings show: + command: auth0 guardian factors duo settings show + exit-code: 0 + stdout: + contains: + - HOST + - INTEGRATION KEY + - SECRET KEY + + 050 - guardian factors duo settings set: + command: auth0 guardian factors duo settings set --ikey IKEYEXAMPLE --skey skeyexample --host api-example.duosecurity.com + exit-code: 0 + stdout: + contains: + - HOST + - api-example.duosecurity.com + - INTEGRATION KEY + - IKEYEXAMPLE + + 051 - guardian factors duo settings set masks the secret key: + command: auth0 guardian factors duo settings show + exit-code: 0 + stdout: + contains: + - SECRET KEY + - (set) + not-contains: + - skeyexample + + 052 - guardian factors duo settings update host only: + command: auth0 guardian factors duo settings update --host api-updated.duosecurity.com + exit-code: 0 + stdout: + contains: + - HOST + - api-updated.duosecurity.com + + # ---------------------------------------------------------------------------- + # Guards: a bare "set" (full replace) must not silently wipe configuration. + # ---------------------------------------------------------------------------- + 053 - guardian factors push set-provider requires a provider: + command: auth0 guardian factors push set-provider + exit-code: 1 + stderr: + contains: + - '--provider is required' + + 054 - guardian factors push set-apns rejects an empty replace: + command: auth0 guardian factors push set-apns + exit-code: 1 + stderr: + contains: + - replaces the entire APNs configuration + + 055 - guardian factors push set-sns rejects an empty replace: + command: auth0 guardian factors push set-sns + exit-code: 1 + stderr: + contains: + - replaces the entire SNS configuration + + 056 - guardian factors duo settings set rejects an empty replace: + command: auth0 guardian factors duo settings set + exit-code: 1 + stderr: + contains: + - are all required for set + + # ---------------------------------------------------------------------------- + # Partial update preserves the fields it does not touch and renders the full + # current state (the PATCH response only echoes changed fields, so the command + # re-fetches before rendering). + # ---------------------------------------------------------------------------- + 057 - guardian factors duo settings set full config: + command: auth0 guardian factors duo settings set --host api-preserve.duosecurity.com --ikey IKEYPRESERVE --skey skeypreserve + exit-code: 0 + stdout: + contains: + - api-preserve.duosecurity.com + - IKEYPRESERVE + + 058 - guardian factors duo settings update host preserves ikey: + command: auth0 guardian factors duo settings update --host api-updated2.duosecurity.com + exit-code: 0 + stdout: + contains: + - api-updated2.duosecurity.com + - IKEYPRESERVE + - (set) + not-contains: + - skeypreserve + + # ---------------------------------------------------------------------------- + # Restore a sensible baseline for the test tenant. + # ---------------------------------------------------------------------------- + 059 - restore otp factor enabled: + command: auth0 guardian factors set otp --enabled + exit-code: 0 + + 060 - restore push provider to guardian: + command: auth0 guardian factors push set-provider --provider guardian + exit-code: 0 From 015d3a7ab712cffcd24d77d5478480c6d1c45d1e Mon Sep 17 00:00:00 2001 From: Kunal Dawar Date: Tue, 8 Sep 2026 11:17:33 +0530 Subject: [PATCH 2/5] test: cover guardian legacy phone hint via unit test Replace the six integration cases that asserted a 403 legacy_mfa_phone_provider_not_allowed on the phone/SMS legacy provider, template and Twilio endpoints. Their outcome is tenant-dependent (403 on tenants moved to the unified phone experience, success or an empty-body error where the legacy provider is still enabled), so they cannot be asserted deterministically against a single live tenant. Cover the deprecation-hint logic with a deterministic unit test instead. --- internal/cli/guardian_test.go | 38 ++++++++++++++++ test/integration/guardian-test-cases.yaml | 54 +++-------------------- 2 files changed, 44 insertions(+), 48 deletions(-) create mode 100644 internal/cli/guardian_test.go diff --git a/internal/cli/guardian_test.go b/internal/cli/guardian_test.go new file mode 100644 index 000000000..fca294a61 --- /dev/null +++ b/internal/cli/guardian_test.go @@ -0,0 +1,38 @@ +package cli + +import ( + "errors" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGuardianLegacyPhoneHint(t *testing.T) { + t.Run("returns nil unchanged", func(t *testing.T) { + assert.NoError(t, guardianLegacyPhoneHint(nil)) + }) + + t.Run("passes through an unrelated error untouched", func(t *testing.T) { + original := errors.New("failed to read phone provider: 404 not found") + + got := guardianLegacyPhoneHint(original) + + assert.Equal(t, original, got) + }) + + t.Run("augments the legacy phone-provider error with guidance", func(t *testing.T) { + original := fmt.Errorf("failed to read phone provider: 403 %s", legacyPhoneProviderErrorCode) + + got := guardianLegacyPhoneHint(original) + + // The original error is preserved (wrapped) so callers keep the code. + assert.ErrorIs(t, got, original) + assert.Contains(t, got.Error(), legacyPhoneProviderErrorCode) + + // The hint names the actual mechanism and the recommended path forward. + assert.Contains(t, got.Error(), "legacy_mfa_phone_provider migration flag") + assert.Contains(t, got.Error(), "PATCH /api/v2/migrations") + assert.Contains(t, got.Error(), "unified phone experience") + }) +} diff --git a/test/integration/guardian-test-cases.yaml b/test/integration/guardian-test-cases.yaml index 10c1cae08..bcb2e83df 100644 --- a/test/integration/guardian-test-cases.yaml +++ b/test/integration/guardian-test-cases.yaml @@ -175,9 +175,12 @@ tests: - create guardian enrollment ticket for user # ---------------------------------------------------------------------------- - # Phone factor: message-types work; provider/templates/twilio are the legacy - # MFA endpoints Auth0 deprecated in favour of Tenant Phone Settings, so they - # surface a clean 403 with the legacy_mfa_phone_provider_not_allowed code. + # Phone factor: message-types are tenant-agnostic and covered here. The legacy + # provider/templates/twilio endpoints have tenant-dependent behaviour (403 on + # tenants moved to the unified phone experience, success or an empty-body error + # on tenants where the legacy provider is still enabled), so they cannot be + # asserted deterministically against a single live tenant. The deprecation-hint + # logic is covered by a unit test instead (internal/cli/guardian_test.go). # ---------------------------------------------------------------------------- 024 - guardian factors phone show-message-types: command: auth0 guardian factors phone show-message-types @@ -211,51 +214,6 @@ tests: - sms - voice - 028 - guardian factors phone show-provider is deprecated: - command: auth0 guardian factors phone show-provider - exit-code: 1 - stderr: - contains: - - legacy_mfa_phone_provider_not_allowed - - 029 - guardian factors phone show-templates is deprecated: - command: auth0 guardian factors phone show-templates - exit-code: 1 - stderr: - contains: - - legacy_mfa_phone_provider_not_allowed - - 030 - guardian factors phone show-twilio is deprecated: - command: auth0 guardian factors phone show-twilio - exit-code: 1 - stderr: - contains: - - legacy_mfa_phone_provider_not_allowed - - # ---------------------------------------------------------------------------- - # SMS factor: provider/templates/twilio share the same legacy deprecation. - # ---------------------------------------------------------------------------- - 031 - guardian factors sms show-provider is deprecated: - command: auth0 guardian factors sms show-provider - exit-code: 1 - stderr: - contains: - - legacy_mfa_phone_provider_not_allowed - - 032 - guardian factors sms show-templates is deprecated: - command: auth0 guardian factors sms show-templates - exit-code: 1 - stderr: - contains: - - legacy_mfa_phone_provider_not_allowed - - 033 - guardian factors sms show-twilio is deprecated: - command: auth0 guardian factors sms show-twilio - exit-code: 1 - stderr: - contains: - - legacy_mfa_phone_provider_not_allowed - # ---------------------------------------------------------------------------- # Push factor: provider selection plus APNs, FCM, FCM v1 and SNS config. # ---------------------------------------------------------------------------- From 97bb5a6b350a5cc24e0dd985a4343d81c1be04f1 Mon Sep 17 00:00:00 2001 From: Kunal Dawar Date: Tue, 8 Sep 2026 12:10:47 +0530 Subject: [PATCH 3/5] fix: render empty guardian phone/sms templates instead of erroring The GetTemplates endpoints return an empty body when a tenant has no templates configured. The go-auth0 SDK surfaces that as an error, so show-templates failed with "the server responded with nothing" on a valid empty state. Treat the empty-body error as no templates and render blank rows instead. Adds isEmptyResponseErr plus unit coverage. --- internal/cli/guardian.go | 12 ++++++++++++ internal/cli/guardian_factor_phone.go | 6 +++++- internal/cli/guardian_factor_sms.go | 6 +++++- internal/cli/guardian_test.go | 16 ++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/internal/cli/guardian.go b/internal/cli/guardian.go index 54c335e5e..c1f7b5723 100644 --- a/internal/cli/guardian.go +++ b/internal/cli/guardian.go @@ -33,6 +33,18 @@ func guardianLegacyPhoneHint(err error) error { ) } +// emptyResponseErrorFragment identifies the go-auth0 SDK error returned when the +// API responds with an empty body (see the SDK's caller: "expected a %T +// response, but the server responded with nothing"). The Guardian phone/SMS +// template endpoints return an empty body when no templates are configured, +// which is a valid state rather than a failure. +const emptyResponseErrorFragment = "server responded with nothing" + +// isEmptyResponseErr reports whether err is the go-auth0 empty-body error. +func isEmptyResponseErr(err error) bool { + return err != nil && strings.Contains(err.Error(), emptyResponseErrorFragment) +} + func guardianCmd(cli *cli) *cobra.Command { cmd := &cobra.Command{ Use: "guardian", diff --git a/internal/cli/guardian_factor_phone.go b/internal/cli/guardian_factor_phone.go index cf31c06d4..33793d115 100644 --- a/internal/cli/guardian_factor_phone.go +++ b/internal/cli/guardian_factor_phone.go @@ -208,7 +208,11 @@ func showGuardianPhoneTemplatesCmd(cli *cli) *cobra.Command { resp, err = cli.apiv3.GuardianFactorPhone.GetTemplates(cmd.Context()) return err }); err != nil { - return guardianLegacyPhoneHint(fmt.Errorf("failed to read phone templates: %w", err)) + if !isEmptyResponseErr(err) { + return guardianLegacyPhoneHint(fmt.Errorf("failed to read phone templates: %w", err)) + } + // No templates configured: the endpoint returns an empty body. + resp = &managementv3.GetGuardianFactorPhoneTemplatesResponseContent{} } cli.renderer.GuardianDetail("phone templates", [][]string{ diff --git a/internal/cli/guardian_factor_sms.go b/internal/cli/guardian_factor_sms.go index af0730004..4c403ddf6 100644 --- a/internal/cli/guardian_factor_sms.go +++ b/internal/cli/guardian_factor_sms.go @@ -122,7 +122,11 @@ func showGuardianSmsTemplatesCmd(cli *cli) *cobra.Command { resp, err = cli.apiv3.GuardianFactorSms.GetTemplates(cmd.Context()) return err }); err != nil { - return guardianLegacyPhoneHint(fmt.Errorf("failed to read SMS templates: %w", err)) + if !isEmptyResponseErr(err) { + return guardianLegacyPhoneHint(fmt.Errorf("failed to read SMS templates: %w", err)) + } + // No templates configured: the endpoint returns an empty body. + resp = &managementv3.GetGuardianFactorSmsTemplatesResponseContent{} } cli.renderer.GuardianDetail("sms templates", [][]string{ diff --git a/internal/cli/guardian_test.go b/internal/cli/guardian_test.go index fca294a61..de7eace00 100644 --- a/internal/cli/guardian_test.go +++ b/internal/cli/guardian_test.go @@ -36,3 +36,19 @@ func TestGuardianLegacyPhoneHint(t *testing.T) { assert.Contains(t, got.Error(), "unified phone experience") }) } + +func TestIsEmptyResponseErr(t *testing.T) { + t.Run("false for nil", func(t *testing.T) { + assert.False(t, isEmptyResponseErr(nil)) + }) + + t.Run("false for an unrelated error", func(t *testing.T) { + assert.False(t, isEmptyResponseErr(errors.New("403 forbidden"))) + }) + + t.Run("true for the go-auth0 empty-body error", func(t *testing.T) { + // Matches the SDK caller's wording for a response with no body. + err := fmt.Errorf("expected a *management.GetGuardianFactorPhoneTemplatesResponseContent response, but the server responded with nothing") + assert.True(t, isEmptyResponseErr(err)) + }) +} From 26d644a1c643bbc5dc19b8119b21e31d3f5651fe Mon Sep 17 00:00:00 2001 From: Kunal Dawar Date: Tue, 8 Sep 2026 12:10:48 +0530 Subject: [PATCH 4/5] test: reset guardian factors so terraform export stays plannable The Duo, APNs and FCM secrets set by the guardian tests are write-only and cannot be cleared via the API. Left enabled, the auth0_guardian resource exported those required sensitive fields as null, which made the terraform integration suite fail terraform plan. Disable the duo and push-notification factors in the restore section so auth0_guardian returns to a plannable state. --- test/integration/guardian-test-cases.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/integration/guardian-test-cases.yaml b/test/integration/guardian-test-cases.yaml index bcb2e83df..926f1bd47 100644 --- a/test/integration/guardian-test-cases.yaml +++ b/test/integration/guardian-test-cases.yaml @@ -443,11 +443,23 @@ tests: # ---------------------------------------------------------------------------- # Restore a sensible baseline for the test tenant. + # + # The Duo, APNs and FCM secrets configured by the tests above are write-only, + # so once set they cannot be read back and there is no API to clear them. + # Left enabled, the auth0_guardian resource would export those required + # sensitive fields as null, and `auth0 tf generate` (terraform-test-cases, + # which runs after this suite) would fail `terraform plan` with "Missing + # required argument". Disabling the duo and push-notification factors drops + # those sub-blocks and returns auth0_guardian to a terraform-plannable state. # ---------------------------------------------------------------------------- 059 - restore otp factor enabled: command: auth0 guardian factors set otp --enabled exit-code: 0 - 060 - restore push provider to guardian: - command: auth0 guardian factors push set-provider --provider guardian + 060 - reset duo factor to a terraform-clean state: + command: auth0 guardian factors set duo --enabled=false + exit-code: 0 + + 061 - reset push factor to a terraform-clean state: + command: auth0 guardian factors set push-notification --enabled=false exit-code: 0 From b109b0746dcbf0970db0fd1be4a215e988813c14 Mon Sep 17 00:00:00 2001 From: Kunal Dawar Date: Tue, 8 Sep 2026 20:41:40 +0530 Subject: [PATCH 5/5] fix: guard destructive guardian set defaults and hide secret prompts Require --policy/--none for policies set and --enabled for factors set when running non-interactively, so an empty invocation no longer silently clears MFA policies or disables a factor. Prompt Duo, FCM, APNs and SNS secrets with the hidden password input instead of echoing them. Add mock-backed unit tests for the set handlers and integration cases for the new guards. --- internal/cli/guardian_factor_duo.go | 4 +- internal/cli/guardian_factor_push.go | 12 +- internal/cli/guardian_factors.go | 3 + internal/cli/guardian_policies.go | 5 +- internal/cli/guardian_test.go | 224 ++++++++++++++++++++++ test/integration/guardian-test-cases.yaml | 24 ++- 6 files changed, 258 insertions(+), 14 deletions(-) diff --git a/internal/cli/guardian_factor_duo.go b/internal/cli/guardian_factor_duo.go index 925b58144..24067441d 100644 --- a/internal/cli/guardian_factor_duo.go +++ b/internal/cli/guardian_factor_duo.go @@ -91,7 +91,7 @@ func setGuardianDuoSettingsCmd(cli *cli) *cobra.Command { if err := guardianDuoIkey.Ask(cmd, &inputs.Ikey, nil); err != nil { return err } - if err := guardianDuoSkey.Ask(cmd, &inputs.Skey, nil); err != nil { + if err := guardianDuoSkey.AskPassword(cmd, &inputs.Skey); err != nil { return err } @@ -164,7 +164,7 @@ func updateGuardianDuoSettingsCmd(cli *cli) *cobra.Command { if err := guardianDuoIkey.AskU(cmd, &inputs.Ikey, ¤tIkey); err != nil { return err } - if err := guardianDuoSkey.AskU(cmd, &inputs.Skey, nil); err != nil { + if err := guardianDuoSkey.AskPasswordU(cmd, &inputs.Skey); err != nil { return err } diff --git a/internal/cli/guardian_factor_push.go b/internal/cli/guardian_factor_push.go index 1e0dbdebd..d2f178100 100644 --- a/internal/cli/guardian_factor_push.go +++ b/internal/cli/guardian_factor_push.go @@ -245,7 +245,7 @@ func updateGuardianPushApnsCmd(cli *cli) *cobra.Command { if err := guardianApnsSandbox.AskBoolU(cmd, &inputs.Sandbox, ¤tSandbox); err != nil { return err } - if err := guardianApnsP12.AskU(cmd, &inputs.P12, nil); err != nil { + if err := guardianApnsP12.AskPasswordU(cmd, &inputs.P12); err != nil { return err } @@ -300,7 +300,7 @@ func setGuardianPushFcmCmd(cli *cli) *cobra.Command { Long: "Replace the Google FCM (legacy) push-notification configuration.", Example: ` auth0 guardian factors push set-fcm --server-key `, RunE: func(cmd *cobra.Command, args []string) error { - if err := guardianFcmServerKey.Ask(cmd, &serverKey, nil); err != nil { + if err := guardianFcmServerKey.AskPassword(cmd, &serverKey); err != nil { return err } @@ -341,7 +341,7 @@ func updateGuardianPushFcmCmd(cli *cli) *cobra.Command { Long: "Partially update the Google FCM (legacy) push-notification configuration.", Example: ` auth0 guardian factors push update-fcm --server-key `, RunE: func(cmd *cobra.Command, args []string) error { - if err := guardianFcmServerKey.Ask(cmd, &serverKey, nil); err != nil { + if err := guardianFcmServerKey.AskPassword(cmd, &serverKey); err != nil { return err } @@ -382,7 +382,7 @@ func setGuardianPushFcmv1Cmd(cli *cli) *cobra.Command { Long: "Replace the Google FCM v1 push-notification configuration.", Example: ` auth0 guardian factors push set-fcmv1 --server-credentials "$(cat service-account.json)"`, RunE: func(cmd *cobra.Command, args []string) error { - if err := guardianFcmServerCredentials.Ask(cmd, &serverCredentials, nil); err != nil { + if err := guardianFcmServerCredentials.AskPassword(cmd, &serverCredentials); err != nil { return err } @@ -423,7 +423,7 @@ func updateGuardianPushFcmv1Cmd(cli *cli) *cobra.Command { Long: "Partially update the Google FCM v1 push-notification configuration.", Example: ` auth0 guardian factors push update-fcmv1 --server-credentials "$(cat service-account.json)"`, RunE: func(cmd *cobra.Command, args []string) error { - if err := guardianFcmServerCredentials.Ask(cmd, &serverCredentials, nil); err != nil { + if err := guardianFcmServerCredentials.AskPassword(cmd, &serverCredentials); err != nil { return err } @@ -606,7 +606,7 @@ func updateGuardianPushSnsCmd(cli *cli) *cobra.Command { if err := guardianSnsAccessKeyID.AskU(cmd, &inputs.AccessKeyID, ¤tAccessKeyID); err != nil { return err } - if err := guardianSnsSecretAccessKey.AskU(cmd, &inputs.SecretAccessKey, nil); err != nil { + if err := guardianSnsSecretAccessKey.AskPasswordU(cmd, &inputs.SecretAccessKey); err != nil { return err } if err := guardianSnsRegion.AskU(cmd, &inputs.Region, ¤tRegion); err != nil { diff --git a/internal/cli/guardian_factors.go b/internal/cli/guardian_factors.go index 6edf6edbe..4a2713f9b 100644 --- a/internal/cli/guardian_factors.go +++ b/internal/cli/guardian_factors.go @@ -111,6 +111,9 @@ func setGuardianFactorCmd(cli *cli) *cobra.Command { } if !guardianFactorEnabled.IsSet(cmd) { + if !canPrompt(cmd) { + return fmt.Errorf("--enabled is required when running non-interactively (use --enabled or --enabled=false)") + } if err := guardianFactorEnabled.AskBool(cmd, &inputs.Enabled, nil); err != nil { return err } diff --git a/internal/cli/guardian_policies.go b/internal/cli/guardian_policies.go index bd9060e60..8ed3f4cc4 100644 --- a/internal/cli/guardian_policies.go +++ b/internal/cli/guardian_policies.go @@ -100,7 +100,10 @@ func setGuardianPoliciesCmd(cli *cli) *cobra.Command { auth0 guardian policies set --policy all-applications --json`, RunE: func(cmd *cobra.Command, args []string) error { // Interactively pick a policy unless the user passed --policy or --none. - if !guardianPolicies.IsSet(cmd) && !inputs.None && canPrompt(cmd) { + if !guardianPolicies.IsSet(cmd) && !inputs.None { + if !canPrompt(cmd) { + return fmt.Errorf("--policy or --none is required when running non-interactively; supported values: all-applications, confidence-score, none") + } if err := guardianPolicies.Select(cmd, &inputs.Policy, guardianPolicyOptions, nil); err != nil { return err } diff --git a/internal/cli/guardian_test.go b/internal/cli/guardian_test.go index de7eace00..9eb268521 100644 --- a/internal/cli/guardian_test.go +++ b/internal/cli/guardian_test.go @@ -1,11 +1,18 @@ package cli import ( + "context" "errors" "fmt" "testing" + managementv3 "github.com/auth0/go-auth0/v3/management" + "github.com/auth0/go-auth0/v3/management/option" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + + "github.com/auth0/auth0-cli/internal/auth0" + "github.com/auth0/auth0-cli/internal/auth0/mock" ) func TestGuardianLegacyPhoneHint(t *testing.T) { @@ -52,3 +59,220 @@ func TestIsEmptyResponseErr(t *testing.T) { assert.True(t, isEmptyResponseErr(err)) }) } + +func TestSetGuardianPoliciesCmd(t *testing.T) { + t.Run("requires --policy or --none when it cannot prompt", func(t *testing.T) { + // In tests canPrompt is false (no TTY), so an empty invocation must not + // silently clear every MFA policy. + policy := mock.NewMockGuardianPolicyAPIV3(gomock.NewController(t)) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianPolicy: policy}, + renderer: testRenderer(), + } + + cmd := setGuardianPoliciesCmd(cli) + cmd.SetArgs([]string{}) + + assert.EqualError( + t, + cmd.Execute(), + "--policy or --none is required when running non-interactively; supported values: all-applications, confidence-score, none", + ) + }) + + t.Run("--none clears every policy with an empty body", func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + policy := mock.NewMockGuardianPolicyAPIV3(ctrl) + policy.EXPECT(). + Set(gomock.Any(), gomock.Any()). + DoAndReturn(func(_ context.Context, req managementv3.SetGuardianPoliciesRequestContent, _ ...option.RequestOption) (managementv3.SetGuardianPoliciesResponseContent, error) { + assert.Empty(t, req) + return managementv3.SetGuardianPoliciesResponseContent{}, nil + }) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianPolicy: policy}, + renderer: testRenderer(), + } + + cmd := setGuardianPoliciesCmd(cli) + cmd.SetArgs([]string{"--none"}) + + assert.NoError(t, cmd.Execute()) + }) + + t.Run("--policy sends the single selected policy", func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + policy := mock.NewMockGuardianPolicyAPIV3(ctrl) + policy.EXPECT(). + Set(gomock.Any(), gomock.Any()). + DoAndReturn(func(_ context.Context, req managementv3.SetGuardianPoliciesRequestContent, _ ...option.RequestOption) (managementv3.SetGuardianPoliciesResponseContent, error) { + assert.Equal(t, managementv3.SetGuardianPoliciesRequestContent{managementv3.MfaPolicyEnumAllApplications}, req) + return managementv3.SetGuardianPoliciesResponseContent{}, nil + }) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianPolicy: policy}, + renderer: testRenderer(), + } + + cmd := setGuardianPoliciesCmd(cli) + cmd.SetArgs([]string{"--policy", "all-applications"}) + + assert.NoError(t, cmd.Execute()) + }) + + t.Run("wraps the API error", func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + policy := mock.NewMockGuardianPolicyAPIV3(ctrl) + policy.EXPECT(). + Set(gomock.Any(), gomock.Any()). + Return(managementv3.SetGuardianPoliciesResponseContent{}, errors.New("boom")) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianPolicy: policy}, + renderer: testRenderer(), + } + + cmd := setGuardianPoliciesCmd(cli) + cmd.SetArgs([]string{"--none"}) + + assert.EqualError(t, cmd.Execute(), "failed to set guardian policies: boom") + }) +} + +func TestSetGuardianFactorCmd(t *testing.T) { + t.Run("requires --enabled when it cannot prompt", func(t *testing.T) { + // The factor is supplied positionally but --enabled is omitted; without a + // TTY this must not silently disable the factor. + factor := mock.NewMockGuardianFactorAPIV3(gomock.NewController(t)) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianFactor: factor}, + renderer: testRenderer(), + } + + cmd := setGuardianFactorCmd(cli) + cmd.SetArgs([]string{"sms"}) + + assert.EqualError( + t, + cmd.Execute(), + "--enabled is required when running non-interactively (use --enabled or --enabled=false)", + ) + }) + + t.Run("enables the named factor", func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + factor := mock.NewMockGuardianFactorAPIV3(ctrl) + factor.EXPECT(). + Set(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(_ context.Context, name *managementv3.GuardianFactorNameEnum, req *managementv3.SetGuardianFactorRequestContent, _ ...option.RequestOption) (*managementv3.SetGuardianFactorResponseContent, error) { + assert.Equal(t, managementv3.GuardianFactorNameEnumSms, *name) + assert.True(t, req.Enabled) + return &managementv3.SetGuardianFactorResponseContent{}, nil + }) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianFactor: factor}, + renderer: testRenderer(), + } + + cmd := setGuardianFactorCmd(cli) + cmd.SetArgs([]string{"sms", "--enabled"}) + + assert.NoError(t, cmd.Execute()) + }) + + t.Run("disables the named factor with --enabled=false", func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + factor := mock.NewMockGuardianFactorAPIV3(ctrl) + factor.EXPECT(). + Set(gomock.Any(), gomock.Any(), gomock.Any()). + DoAndReturn(func(_ context.Context, name *managementv3.GuardianFactorNameEnum, req *managementv3.SetGuardianFactorRequestContent, _ ...option.RequestOption) (*managementv3.SetGuardianFactorResponseContent, error) { + assert.Equal(t, managementv3.GuardianFactorNameEnumEmail, *name) + assert.False(t, req.Enabled) + return &managementv3.SetGuardianFactorResponseContent{}, nil + }) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianFactor: factor}, + renderer: testRenderer(), + } + + cmd := setGuardianFactorCmd(cli) + cmd.SetArgs([]string{"email", "--enabled=false"}) + + assert.NoError(t, cmd.Execute()) + }) + + t.Run("rejects an unknown factor before calling the API", func(t *testing.T) { + factor := mock.NewMockGuardianFactorAPIV3(gomock.NewController(t)) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianFactor: factor}, + renderer: testRenderer(), + } + + cmd := setGuardianFactorCmd(cli) + cmd.SetArgs([]string{"not-a-factor", "--enabled"}) + + assert.ErrorContains(t, cmd.Execute(), `invalid factor "not-a-factor"`) + }) +} + +func TestUpdateGuardianDuoSettingsCmd(t *testing.T) { + t.Run("re-fetches the full settings after the PATCH", func(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + duo := mock.NewMockGuardianFactorDuoAPIV3(ctrl) + + // The PATCH response only echoes the sent fields, so the command must + // Get -> Update -> Get to render the complete current state. + gomock.InOrder( + duo.EXPECT(). + Get(gomock.Any()). + Return(&managementv3.GetGuardianFactorDuoSettingsResponseContent{ + Host: auth0.String("api-old.duosecurity.com"), + Ikey: auth0.String("ikey-1"), + }, nil), + duo.EXPECT(). + Update(gomock.Any(), gomock.Any()). + DoAndReturn(func(_ context.Context, req *managementv3.UpdateGuardianFactorDuoSettingsRequestContent, _ ...option.RequestOption) (*managementv3.UpdateGuardianFactorDuoSettingsResponseContent, error) { + // Only the host was provided, so only it is sent. + assert.Equal(t, "api-new.duosecurity.com", *req.Host) + assert.Nil(t, req.Ikey) + assert.Nil(t, req.Skey) + return &managementv3.UpdateGuardianFactorDuoSettingsResponseContent{}, nil + }), + duo.EXPECT(). + Get(gomock.Any()). + Return(&managementv3.GetGuardianFactorDuoSettingsResponseContent{ + Host: auth0.String("api-new.duosecurity.com"), + Ikey: auth0.String("ikey-1"), + }, nil), + ) + + cli := &cli{ + apiv3: &auth0.APIV3{GuardianFactorDuo: duo}, + renderer: testRenderer(), + } + + cmd := updateGuardianDuoSettingsCmd(cli) + cmd.SetArgs([]string{"--host", "api-new.duosecurity.com"}) + + assert.NoError(t, cmd.Execute()) + }) +} diff --git a/test/integration/guardian-test-cases.yaml b/test/integration/guardian-test-cases.yaml index 926f1bd47..7c7ede302 100644 --- a/test/integration/guardian-test-cases.yaml +++ b/test/integration/guardian-test-cases.yaml @@ -417,12 +417,26 @@ tests: contains: - are all required for set + 057 - guardian policies set rejects an empty invocation: + command: auth0 guardian policies set + exit-code: 1 + stderr: + contains: + - '--policy or --none is required' + + 058 - guardian factors set rejects a missing enabled flag: + command: auth0 guardian factors set sms + exit-code: 1 + stderr: + contains: + - '--enabled is required' + # ---------------------------------------------------------------------------- # Partial update preserves the fields it does not touch and renders the full # current state (the PATCH response only echoes changed fields, so the command # re-fetches before rendering). # ---------------------------------------------------------------------------- - 057 - guardian factors duo settings set full config: + 059 - guardian factors duo settings set full config: command: auth0 guardian factors duo settings set --host api-preserve.duosecurity.com --ikey IKEYPRESERVE --skey skeypreserve exit-code: 0 stdout: @@ -430,7 +444,7 @@ tests: - api-preserve.duosecurity.com - IKEYPRESERVE - 058 - guardian factors duo settings update host preserves ikey: + 060 - guardian factors duo settings update host preserves ikey: command: auth0 guardian factors duo settings update --host api-updated2.duosecurity.com exit-code: 0 stdout: @@ -452,14 +466,14 @@ tests: # required argument". Disabling the duo and push-notification factors drops # those sub-blocks and returns auth0_guardian to a terraform-plannable state. # ---------------------------------------------------------------------------- - 059 - restore otp factor enabled: + 061 - restore otp factor enabled: command: auth0 guardian factors set otp --enabled exit-code: 0 - 060 - reset duo factor to a terraform-clean state: + 062 - reset duo factor to a terraform-clean state: command: auth0 guardian factors set duo --enabled=false exit-code: 0 - 061 - reset push factor to a terraform-clean state: + 063 - reset push factor to a terraform-clean state: command: auth0 guardian factors set push-notification --enabled=false exit-code: 0