Skip to content

fix(bootstrap): gate local management controllers with the local feature state (#8221) - #8232

Open
konlue wants to merge 1 commit into
apache:masterfrom
konlue:fix/local-management-gate
Open

konlue wants to merge 1 commit into
apache:masterfrom
konlue:fix/local-management-gate

Conversation

@konlue

@konlue konlue commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #8221.

Problem

With shenyu.local.enabled=false only the local dispatch filter is removed; the Local*Controller handlers stay registered as ordinary /shenyu controllers. HealthFilter dispatches configured path prefixes directly to DispatcherHandler without a method restriction, so broadening shenyu.health.paths to / exposes anonymous local plugin/selector/rule/metadata/app-auth writes. The starter's filter condition also used matchIfMissing=true, contradicting the false default of ShenyuConfig.Local.

Change

  • All three local controllers and the LocalDispatcherFilter now share one explicit gate: shenyu.local.enabled=true (matchIfMissing=false).
  • With the property absent or false, both the controllers and the filter are absent, so even a health prefix matching / finds no /shenyu handler and cannot reach a writer. With true, the existing key filter still runs before health dispatch and rejects missing/wrong keys.
  • HealthFilter behavior and ordinary forwarding are unchanged.
  • Compatibility: Omitting the property now disables local management entirely (previously the filter was implicitly registered and failed closed without a key). Deployments relying on implicit enablement must set shenyu.local.enabled=true and configure sha512Key; documented in the file-mode README, bootstrap defaults and root README. File mode continues to force it off.

Tests

  • ShenyuConfigurationTest asserts the filter and all three controllers are absent when the property is omitted or false, and present when true.
  • FileModeIntegrationTest starts a real Boot application with shenyu.health.paths=/ and asserts a POST to /shenyu/plugin/rule/saveOrUpdate returns 404 and leaves the rule cache unchanged; the controller and filter beans are absent.
  • LocalManagementDispatchTest boots a real HTTP server with explicit enablement and a broad health prefix: a missing localKey is rejected with 403, while the correct key reaches the controller and updates the cache.

Verification

shenyu-web: 170/170
starter-gateway: 14/14
starter-sync-data-file: 72/72
wasm-base: 47/47
shenyu-common: 626 (4 skipped)
plugin-base: 334

Checkstyle clean on the touched modules. No request hot-path change: only startup bean registration is gated.

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 879300f.

The three local controllers and their dispatch filter now share the same explicit enablement condition. With the feature absent or false, a broad health prefix cannot reach a local writer because no handler is registered. Explicit enablement retains the existing localKey check before health dispatch, and file mode continues to reject conflicting writers. The omitted-property compatibility change is documented. This is a startup-registration change and adds no work to ordinary forwarding.

Targeted validation includes real Boot/HTTP dispatch: disabled file-mode writes return 404 without mutating the cache; enabled local management rejects a missing key and accepts the configured key.

Targeted test report: 37 cases, 0 failures, 0 errors, 0 skipped. Checkstyle, separately executed Apache RAT and git diff --check pass. Validation used ./mvnw and Corretto 21/project target 17; no full-repository/Docker E2E pass is claimed. Required CI must pass before merge.

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.

[BUG][Bootstrap] Keep disabled local writers unreachable through health dispatch

2 participants