Skip to content

feat: add guardian (MFA) command group - #1646

Open
developerkunal wants to merge 5 commits into
mainfrom
feat/guardian-mfa-commands
Open

feat: add guardian (MFA) command group#1646
developerkunal wants to merge 5 commits into
mainfrom
feat/guardian-mfa-commands

Conversation

@developerkunal

Copy link
Copy Markdown
Contributor

🔧 Changes

Adds a new top-level auth0 guardian command group for managing Auth0 multi-factor authentication (Guardian), built entirely on the go-auth0/v3 SDK (cli.apiv3).

New commands:

  • guardian policiesshow, set (all-applications, confidence-score, none / --none).
  • guardian enrollmentsshow, delete, create-ticket.
  • guardian factorslist, set <factor> --enabled[=false] for every factor (sms, push-notification, otp, duo, webauthn-roaming, webauthn-platform, recovery-code, email).
  • guardian factors pushshow/set-provider (guardian, sns, direct), APNs (show/set/update-apns), FCM (set/update-fcm), FCM v1 (set-fcmv1), SNS (show/set/update-sns).
  • guardian factors duo settingsshow, set (full replace, all fields required), update (partial, interactive).
  • guardian factors phoneshow/set-message-types plus the legacy show/set-provider, show/set-templates, show/set-twilio.
  • guardian factors sms — the legacy show/set-provider, show/set-templates, show/set-twilio.

Behavior notes:

  • Secret values (Duo secret key, SNS secret access key, FCM server key, Twilio auth token) are masked in output via display.MaskSecret and never printed.
  • set commands that perform a full replace (duo settings, APNs, SNS) reject an empty invocation instead of silently wiping configuration, and update commands re-fetch after the PATCH so they render the complete current state.
  • The legacy phone/SMS provider, template and Twilio endpoints are marked (legacy) in help/docs. On tenants moved to the unified phone experience these endpoints are no longer reachable with Management API tokens, so a 403 legacy_mfa_phone_provider_not_allowed now surfaces an actionable hint pointing to the unified phone experience.
  • Bumps go-auth0/v3 to v3.4.0 and adds the required Guardian scopes to the device-code login flow.

📚 References

🔬 Testing

  • Unit tests added for the display layer (internal/display/guardian_test.go) and covered by the existing internal/cli and internal/auth suites; make test-unit passes.
  • YAML-driven integration cases added in test/integration/guardian-test-cases.yaml covering factors, policies, enrollment error paths, push providers, APNs/SNS/FCM, Duo settings, the full-replace guards, and the legacy-endpoint 403s.
  • Manually verified live against a development tenant: factor toggles, push provider selection, APNs/SNS/FCM configuration, policies, and Duo set/show/update.
  • make docs regenerated; make lint clean for all new files.

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

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.
@developerkunal
developerkunal requested a review from a team as a code owner September 8, 2026 05:33
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.
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.
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.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant