Skip to content

feat(plugins): add dynamic plugin commands - #1731

Open
developerkunal wants to merge 9 commits into
DXCDT-2604/plugin-commandsfrom
DXCDT-2605/dynamic-plugin-commands
Open

developerkunal wants to merge 9 commits into
DXCDT-2604/plugin-commandsfrom
DXCDT-2605/dynamic-plugin-commands

Conversation

@developerkunal

@developerkunal developerkunal commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🔧 Changes

Installed plugins now show up as commands: auth0 <plugin> for the plugin's root command and auth0 <plugin> <command> for each of its other commands. This adds the checks before a plugin starts, the environment and timeout it runs with, and the error shape for a failed run. The feature is still behind the build gate, so a stable build registers no plugin command.

Registration. At startup the CLI reads each plugin's plugin.json, checked against the lockfile hash, without hashing the executable or using the network. A core command always wins over a plugin of the same name, with a stderr warning when it runs.

Arguments. The CLI takes out only the flags it owns and passes everything else, and everything after a bare --, to the plugin untouched. A call such as auth0 plugin-name --flag scan, where scan could be a subcommand, is refused as ambiguous, so the root command cannot run with the permissions meant for scan.

Checks before every run, in this order, all failing closed

  1. Plugins are not turned off with AUTH0_CLI_PLUGINS_DISABLED.
  2. The installed files match the lockfile.
  3. The registry index is usable and the version is not revoked.
  4. The call is allowed: an interactive command needs a terminal, and the output flags and agent mode need a matching manifest declaration.
  5. The tenant has approved the plugin's permissions, by a recorded approval or a pin.
  6. Only then is a session opened, so an unapproved or revoked plugin never triggers a login. The session tenant must equal the approved tenant.
  7. The files are verified again after the session opens. The gap between the check and the start is not closed completely.

How the plugin runs

  • The proxy gets only the scopes of the invoked command.
  • The plugin gets a small environment: a short allowlist from the user's environment, the proxy variables, the CLI owned flags as AUTH0_PLUGIN_<NAME>, and the variables the command declared in permissions.env. Nothing starting with AUTH0_ is passed through, and the manifest validator now rejects any AUTH0_ variable name.
  • On timeout or Ctrl-C the plugin is asked to stop and then killed after a short grace period. Denied proxy calls are summarized as a warning on stderr.

Failed runs. A new additive error class plugin covers a non-zero exit, a timeout, an interrupt and a failed start. The plugin's own exit code is in details.exitCode of the JSON error envelope. Other refusals use the existing validation and auth classes.

Existing code. The CLI now keeps the access token and tenant domain in memory for the proxy, and never prints them. resolveAgentMode stops reading arguments at --.

📚 References

DXCDT-2605. Part of the plugin framework stack of 11 PRs, and it builds on the PR below it (DXCDT-2604).

🔬 Testing

The new code is covered by unit tests.

📝 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)

@developerkunal
developerkunal requested a review from a team as a code owner October 24, 2026 14:47
@developerkunal
developerkunal force-pushed the DXCDT-2605/dynamic-plugin-commands branch from 8ee6021 to 494a96f Compare October 24, 2026 15:30
@developerkunal
developerkunal force-pushed the DXCDT-2605/dynamic-plugin-commands branch 2 times, most recently from 88526bc to ac95530 Compare November 2, 2026 14:31
@developerkunal
developerkunal force-pushed the DXCDT-2605/dynamic-plugin-commands branch from ac95530 to d8326f4 Compare November 2, 2026 19:36
@developerkunal
developerkunal force-pushed the DXCDT-2605/dynamic-plugin-commands branch from d8326f4 to 5e24fc0 Compare November 24, 2026 11:34
@developerkunal
developerkunal force-pushed the DXCDT-2605/dynamic-plugin-commands branch from 5e24fc0 to e67de32 Compare November 24, 2026 12:03
@bkiran6398
bkiran6398 force-pushed the DXCDT-2605/dynamic-plugin-commands branch from e67de32 to 20c2019 Compare November 27, 2026 06:23
@developerkunal
developerkunal removed this pull request from stack #1736 November 30, 2026 17:24
@developerkunal
developerkunal force-pushed the DXCDT-2605/dynamic-plugin-commands branch from 20c2019 to 42ee3f9 Compare November 30, 2026 17:24
@developerkunal
developerkunal removed this pull request from stack #1792 November 30, 2026 17:27
@developerkunal
developerkunal force-pushed the DXCDT-2605/dynamic-plugin-commands branch from 42ee3f9 to ff981f7 Compare December 1, 2026 17:11
- Register installed plugins as `auth0 <plugin> [command]` in builds where the plugin feature is on, reading only the lockfile and manifest at startup
- Pre-scan the CLI-owned global flags and pass everything else, and everything after `--`, to the plugin untouched
- Check the plugin on every run before any login: enabled, verified files, registry index and revocation, call rules, tenant approval, then verify again after the session opens
- Start the loopback proxy with only the invoked command's scopes and run the plugin with a small environment and a timeout, stopping the whole process tree on timeout or interrupt
- Add the token source for the proxy, the plugin error class, and a warning when a core command shadows an installed plugin
- Reject AUTH0_ environment variables in plugin manifests and refuse a root command call that names a subcommand
A plugin that ends with a non-zero exit code now makes the CLI exit with
that code, so scripts can tell what the plugin reported. Codes above 255 or
below zero are mapped into 1..255 so a failure never becomes success. The
CLI prints no extra error line for such an exit, does not send it to crash
reporting, and records it as a plugin_exit outcome with the exit code.
When a plugin run fails, the details of the JSON and agent mode error now
carry deniedCalls: the calls that the proxy denied or that Auth0 refused,
with their kind, method, path, scope, status and error code. A run that was
started always has the list, empty when nothing was denied. A plugin that
exits with a non-zero code gets it too.
…opes

A plugin command named with up to three words, such as scan secrets, is now
registered below its parent words. A parent that has no entry of its own
becomes a help only command that lists its children, and an unknown child
gives a usage error without starting the plugin. A parent that has an entry
runs with its own scopes only. The plugin receives all the words as plain
arguments, a runnable parent is listed by commands --json, and the check for an
ambiguous subcommand applies at every level.
…plugin flags

The help of a plugin command shows what the manifest says about each flag: the
default, the allowed values and whether it is required. Shell completion offers
the allowed values, and commands --json carries default, enum and required for
the flags of plugin commands. The CLI still does not check the arguments: the
plugin gets only what was typed and validates its own input.
…t follows -- verbatim

The error details of a plugin run that timed out, was interrupted or could not be
started now carry the exit code the CLI exits with, as the exit of a plugin does.

An unknown flag before a bare -- took the -- as its value, so the word after it
was routed as a command. The arguments are now guarded so that everything after
-- reaches the plugin as typed.
…ds it asks for and show its exit codes in help
@developerkunal
developerkunal force-pushed the DXCDT-2605/dynamic-plugin-commands branch from ff981f7 to e2bbb71 Compare December 2, 2026 07:25

This branch has not been deployed

No deployments
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