Skip to content

http: add cors filtering#10106

Open
jherrera-jump wants to merge 1 commit into
firedancer-io:mainfrom
jherrera-jump:jherrera/http-cors-filter
Open

http: add cors filtering#10106
jherrera-jump wants to merge 1 commit into
firedancer-io:mainfrom
jherrera-jump:jherrera/http-cors-filter

Conversation

@jherrera-jump

@jherrera-jump jherrera-jump commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Adds option to allow operators to enable CORS filtering. Disabled by default.

Copilot AI 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.

Pull request overview

This PR adds configurable CORS handling to Firedancer’s embedded HTTP server usage (GUI + metrics), including parsing the Origin request header, generating Access-Control-* response headers, and wiring an origin allowlist through config → topology → tiles.

Changes:

  • Add CORS origin allowlist constants/util (fd_http_cors_match_origin) and parse the Origin request header in the HTTP server.
  • Add per-tile access_control_allow_origin configuration for tiles.gui and tiles.metric, including OPTIONS preflight handling and emitting Allow / Vary: Origin.
  • Update HTTP server footprint assertions in tests and propagate new config fields through topology setup.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/waltz/http/test_http_server.c Updates expected server footprint values due to added server state/headers.
src/waltz/http/fd_http.h Introduces CORS allowlist sizing constants and an origin matching helper.
src/waltz/http/fd_http_server.h Extends request/response structs with Origin and Allow header support.
src/waltz/http/fd_http_server.c Parses Origin, emits Allow, and adds Vary: Origin for non-wildcard CORS.
src/disco/topo/fd_topo.h Adds CORS allowlist storage to GUI + metrics tile config in topology.
src/disco/metrics/fd_metric_tile.c Implements metrics CORS allowlisting and OPTIONS preflight responses.
src/disco/gui/fd_gui_tile.c Implements GUI CORS allowlisting and OPTIONS preflight responses.
src/app/shared/fd_config.h Adds CORS allowlist fields to config structs for GUI + metrics tiles.
src/app/shared/fd_config_parse.c Parses new TOML array config into *_cnt + fixed-size arrays.
src/app/firedancer/topology.c Copies parsed allowlists into tile topology structs for Firedancer.
src/app/firedancer/config/default.toml Documents and adds default access_control_allow_origin = [] for tiles.
src/app/fdctl/topology.c Copies parsed allowlists into tile topology structs for fdctl.
src/app/fdctl/config/default.toml Documents and adds default access_control_allow_origin = [] for tiles.
Comments suppressed due to low confidence (1)

src/disco/metrics/fd_metric_tile.c:96

  • If an allowed Origin triggers a metrics request but staging the body fails, the 500 response should still carry Access-Control-Allow-Origin; otherwise browser clients can't read the error status due to CORS.
    if( FD_UNLIKELY( fd_http_server_stage_body( ctx->metrics_server, &response ) ) ) {
      FD_LOG_WARNING(( "fd_http_server_stage_body failed, metrics response too long" ));
      return (fd_http_server_response_t){
        .status = 500,
      };
    }

Comment thread src/disco/metrics/fd_metric_tile.c
Comment thread src/disco/metrics/fd_metric_tile.c
Comment thread src/disco/gui/fd_gui_tile.c
Comment thread src/disco/gui/fd_gui_tile.c
Comment thread src/disco/gui/fd_gui_tile.c

Copilot AI 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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment thread src/waltz/http/fd_http_server.h Outdated
Comment thread src/waltz/http/fd_http_server.h
Comment thread src/waltz/http/fd_http.h

Copilot AI 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.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Comment thread src/waltz/http/fd_http.h Outdated
Comment thread src/discof/rpc/fd_rpc_tile.c
@jherrera-jump jherrera-jump force-pushed the jherrera/http-cors-filter branch 2 times, most recently from 64aa390 to cd3870d Compare June 5, 2026 18:29
@jherrera-jump jherrera-jump requested a review from Copilot June 5, 2026 18:29

Copilot AI 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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Comment thread src/waltz/http/fd_http_server.c
Comment thread src/waltz/http/fd_http_server.c
Comment thread src/waltz/http/fd_http_server.c
Comment thread src/discof/rpc/fd_rpc_tile.c Outdated
Comment thread src/disco/gui/fd_gui_tile.c

Copilot AI 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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

@jherrera-jump jherrera-jump marked this pull request as ready for review June 5, 2026 18:54
@jherrera-jump jherrera-jump requested a review from mmcgee-jump June 5, 2026 18:54
@jherrera-jump jherrera-jump force-pushed the jherrera/http-cors-filter branch from 1ab4703 to e53676d Compare June 10, 2026 22:10
Copilot AI review requested due to automatic review settings June 11, 2026 18:47
@jherrera-jump jherrera-jump force-pushed the jherrera/http-cors-filter branch from e53676d to 1710251 Compare June 11, 2026 18:47
@jherrera-jump jherrera-jump force-pushed the jherrera/http-cors-filter branch from 1710251 to 5a95d9d Compare June 11, 2026 18:49

Copilot AI 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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Comment thread src/app/firedancer/topology.c Outdated
Comment on lines +1577 to +1584
<<<<<<< HEAD
tile->gui.cache_size_gib = config->firedancer.accounts.cache_size_gib;
tile->gui.accdb_obj_id = fd_pod_query_ulong( config->topo.props, "accdb", ULONG_MAX );
FD_TEST( tile->gui.accdb_obj_id!=ULONG_MAX );
=======
tile->gui.access_control_allow_origin_cnt = config->tiles.gui.access_control_allow_origin_cnt;
fd_memcpy( tile->gui.access_control_allow_origin, config->tiles.gui.access_control_allow_origin, sizeof(tile->gui.access_control_allow_origin) );
>>>>>>> e53676dcc1 (http: add cors filtering)
Copilot AI review requested due to automatic review settings June 13, 2026 19:41

Copilot AI 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.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

static fd_http_server_response_t
rpc_http_request1( fd_rpc_tile_t * ctx,
fd_http_server_request_t const * request ) {
char const * allow_origin = fd_http_cors_match_origin( ctx->cors_origin, ctx->cors_origin_cnt, request->headers.origin );
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