Skip to content

feat: add client-grants command resource - #1598

Open
developerkunal wants to merge 6 commits into
feat/go-auth0-v3-migrationfrom
feat/client-grants-commands
Open

feat: add client-grants command resource#1598
developerkunal wants to merge 6 commits into
feat/go-auth0-v3-migrationfrom
feat/client-grants-commands

Conversation

@developerkunal

Copy link
Copy Markdown
Contributor

🔧 Changes

Adds a client-grants command group so the CLI has full CRUD coverage for client grants, backed by the go-auth0 v3 Management SDK.

New commands:

  • auth0 client-grants list — list client grants, filterable by --client-id and --audience.
  • auth0 client-grants create — authorize an application against an API.
  • auth0 client-grants show — show a single client grant.
  • auth0 client-grants update — change a grant's scopes and organization settings.
  • auth0 client-grants delete — remove a grant.

Create behavior:

  • Scopes can be set three ways, matching the API: specific scopes (--scopes), every scope on the API (--allow-all-scopes), or no scopes at all. An empty scope list is sent to the API as [] rather than being dropped.
  • --subject-type accepts client, user, or anonymous_user. The organization flags (--organization-usage, --allow-any-organization) are rejected for the user and anonymous_user subject types, because the API does not allow organization settings on those.
  • The detail view always shows the subject type, defaulting an empty value to client so it reads clearly.

The v3 SDK client-grant wrapper replaces the v1 one, and the existing callers (quickstarts, terraform export, and the test command) are moved over to it.

📚 References

N/A

🔬 Testing

  • Added table-driven unit tests for the command input handling, subject-type validation, and the display views.
  • Added commander integration tests (test/integration/client-grants-test-cases.yaml) covering list, create (specific / all / no scopes), show, update, delete, and the validation failure paths, plus helper scripts.
  • Manually exercised the full command surface against a live tenant, including empty-scope grants on both custom and system APIs and the subject-type validation paths.

📝 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 client-grants command group (list, create, show, update, delete)
backed by the go-auth0 v3 Management SDK, giving the CLI full CRUD
coverage for client grants.

Create supports specific scopes, all scopes (--allow-all-scopes), or no
scopes at all, matching the API. It also accepts --subject-type
(client, user, anonymous_user); the organization flags are rejected for
user and anonymous_user subject types, which the API does not allow.

The detail view always shows the subject type, defaulting an empty value
to client so it reads clearly. The v3 SDK client grant wrapper replaces
the v1 one, and the callers that used it (quickstarts, terraform, test)
are moved over.

Adds unit tests, commander integration tests and helper scripts, and the
generated command docs.
@developerkunal
developerkunal requested a review from a team as a code owner August 5, 2026 19:17
Temporary: allow the integration-tests job to run on PRs targeting
feat/go-auth0-v3-migration so the client-grants suite is exercised
against the live tenant. Revert before merge.
The detail view now always shows SUBJECT TYPE, which is the widest
label, so the label column pads wider than before. Update the expected
spacing in the show-table integration test to match.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.95080% with 180 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feat/go-auth0-v3-migration@190477d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/cli/client_grants.go 70.17% 126 Missing and 27 partials ⚠️
internal/display/client_grant.go 86.25% 17 Missing and 1 partial ⚠️
internal/cli/test.go 50.00% 7 Missing ⚠️
internal/cli/terraform_fetcher.go 87.50% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##             feat/go-auth0-v3-migration    #1598   +/-   ##
=============================================================
  Coverage                              ?   59.87%           
=============================================================
  Files                                 ?      124           
  Lines                                 ?    24176           
  Branches                              ?        0           
=============================================================
  Hits                                  ?    14475           
  Misses                                ?     8792           
  Partials                              ?      909           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Update and delete now fail fast when a client grant is a system grant
(is_system), which Auth0 refuses to modify, instead of surfacing the raw
400 after the whole interactive flow. System grants are also hidden from
the update and delete pickers so they can't be selected.

The update scope picker now offers the No scopes option too, matching
create. Choosing it sends scope: [] so the grant's scopes are cleared,
rather than being read as leaving them untouched.
Update now reads the grant's immutable subject type and, like create,
skips the organization prompts and request fields for the user and
anonymous_user subject types, which Auth0 rejects organization settings
on. It also runs the subject-type validation so the flag path fails fast
with a clear message.

Both create and update now drop the all-scopes option in the interactive
picker when the audience is a system API, since Auth0 rejects
allow_all_scopes on system APIs.
…opes

Add command-level tests for the update system-grant fail-fast, the update
subject-type organization guard, and the delete system-grant fail-fast.

Also document that a user subject-type grant against the Auth0 Management
API takes a fixed current_user scope set that cannot be listed dynamically,
so the scopes must be passed inline with --scopes.
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.

2 participants