feat(router): add engine.require_request_tracing_auth toggle for ART#2559
feat(router): add engine.require_request_tracing_auth toggle for ART#2559ekroon wants to merge 1 commit intowundergraph:mainfrom
Conversation
WalkthroughThe PR introduces a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
router/core/graphql_prehandler.go (1)
1264-1267: Consider surfacing a warning when unauthenticated ART is enabled.When
require_request_tracing_auth=false, non-dev requests can enable ART/query-plan options without token validation. A startup warning or config-health warning would make accidental exposure easier to catch.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@router/core/graphql_prehandler.go` around lines 1264 - 1267, The code currently allows unauthenticated ART when requireRequestTracingAuth is false but does not warn operators; add a clear warning when this config is set to false so accidental exposure is visible. Modify the initialization path that sets h.requireRequestTracingAuth (or the constructor/new-handler function that creates this handler) to log a startup warning via the existing logger or config-health mechanism indicating "requireRequestTracingAuth=false allows unauthenticated ART/query-plan access" and, if you prefer runtime visibility, emit a single (once-only) warning the first time the branch in the request prehandler (the block guarding requireRequestTracingAuth where parseRequestExecutionOptions and parseRequestTraceOptions are returned) is hit; use an atomic boolean or once.Do to avoid flooding logs and include clear context about the setting and recommended secure alternatives.router/core/graphql_prehandler_request_options_test.go (1)
31-47: Add a positive auth-path subtest forrequireRequestTracingAuth=true.Please add one case with a valid
WGRequestToken+routerPublicKeyto assert ART options are enabled when auth is required and valid. That closes the remaining branch ininternalParseRequestOptions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@router/core/graphql_prehandler_request_options_test.go` around lines 31 - 47, Add a new subtest alongside the existing one that exercises the auth-success path for internalParseRequestOptions: create an httptest request with the same ART query params (e.g. wg_include_query_plan=1 and wg_trace=...) and include a valid WGRequestToken header signed with a matching routerPublicKey; construct the PreHandler with enableRequestTracing: true, developmentMode: false, requireRequestTracingAuth: true and set routerPublicKey to the public key that verifies the token; call h.internalParseRequestOptions(req, &ClientInfo{}, zap.NewNop()) and assert no error and that executionOptions.IncludeQueryPlanInResponse and traceOptions.Enable are true (and check traceOptions.ExcludeOutput matches the provided wg_trace behavior) so the authenticated branch is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@router/core/graphql_prehandler_request_options_test.go`:
- Around line 31-47: Add a new subtest alongside the existing one that exercises
the auth-success path for internalParseRequestOptions: create an httptest
request with the same ART query params (e.g. wg_include_query_plan=1 and
wg_trace=...) and include a valid WGRequestToken header signed with a matching
routerPublicKey; construct the PreHandler with enableRequestTracing: true,
developmentMode: false, requireRequestTracingAuth: true and set routerPublicKey
to the public key that verifies the token; call
h.internalParseRequestOptions(req, &ClientInfo{}, zap.NewNop()) and assert no
error and that executionOptions.IncludeQueryPlanInResponse and
traceOptions.Enable are true (and check traceOptions.ExcludeOutput matches the
provided wg_trace behavior) so the authenticated branch is covered.
In `@router/core/graphql_prehandler.go`:
- Around line 1264-1267: The code currently allows unauthenticated ART when
requireRequestTracingAuth is false but does not warn operators; add a clear
warning when this config is set to false so accidental exposure is visible.
Modify the initialization path that sets h.requireRequestTracingAuth (or the
constructor/new-handler function that creates this handler) to log a startup
warning via the existing logger or config-health mechanism indicating
"requireRequestTracingAuth=false allows unauthenticated ART/query-plan access"
and, if you prefer runtime visibility, emit a single (once-only) warning the
first time the branch in the request prehandler (the block guarding
requireRequestTracingAuth where parseRequestExecutionOptions and
parseRequestTraceOptions are returned) is hit; use an atomic boolean or once.Do
to avoid flooding logs and include clear context about the setting and
recommended secure alternatives.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
router/core/graph_server.gorouter/core/graphql_prehandler.gorouter/core/graphql_prehandler_request_options_test.gorouter/core/router_config.gorouter/pkg/config/config.gorouter/pkg/config/config.schema.jsonrouter/pkg/config/config_test.gorouter/pkg/config/fixtures/full.yamlrouter/pkg/config/testdata/config_defaults.jsonrouter/pkg/config/testdata/config_full.json
Summary by CodeRabbit
Release Notes
New Features
ENGINE_REQUIRE_REQUEST_TRACING_AUTH(YAML:engine.require_request_tracing_auth) to control request tracing authentication behavior. Defaults to enabled.Tests
Checklist
This is a proposal for #2555