Title: fix(forge-server): configurable CORS allowlist, asymmetric-only JWKS verification & shared HTTP client · Issue #262 · elcode-id/elcode-forge · GitHub
Open Graph Title: fix(forge-server): configurable CORS allowlist, asymmetric-only JWKS verification & shared HTTP client · Issue #262 · elcode-id/elcode-forge
X Title: fix(forge-server): configurable CORS allowlist, asymmetric-only JWKS verification & shared HTTP client · Issue #262 · elcode-id/elcode-forge
Description: Part of #256. Scope Add cors_allowed_origins: Vec
Open Graph Description: Part of #256. Scope Add cors_allowed_origins: Vec
X Description: Part of #256. Scope Add cors_allowed_origins: Vec<String> to ServerConfig (crates/forge-server/src/config.rs), configurable via EFORGE_CORS_ALLOWED_ORIGINS (defaulting to local dashboard orig...
Opengraph URL: https://github.com/elcode-id/elcode-forge/issues/262
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix(forge-server): configurable CORS allowlist, asymmetric-only JWKS verification & shared HTTP client","articleBody":"Part of #256.\n\n## Scope\n- Add `cors_allowed_origins: Vec\u003cString>` to `ServerConfig` (`crates/forge-server/src/config.rs`), configurable via `EFORGE_CORS_ALLOWED_ORIGINS` (defaulting to local dashboard origins instead of wildcard `*`, while still supporting explicit `*` when configured).\n- Replace unconditional `CorsLayer::permissive()` in `crates/forge-server/src/app.rs` with configurable `CorsLayer` driven by `state.config.cors_allowed_origins`.\n- Harden `JwksCache` in `crates/forge-server/src/auth/jwks.rs`:\n 1. Reuse a persistent `reqwest::Client` field instead of creating one per request.\n 2. Restrict remote JWKS URLs to `https://` or explicit loopback `http://` (`localhost`, `127.0.0.1`, `[::1]`) to mitigate SSRF.\n 3. Reject symmetric algorithms (`HS256`/`HS384`/`HS512`) and symmetric `jwk.k` keys in `verify_token` to prevent algorithm-confusion attacks, and always enforce `validation.validate_exp = true`.\n\n## Out of scope\n- Changing SQLite/PostgreSQL database migrations or API endpoint paths.\n\n## Acceptance criteria\n- Tokens signed with symmetric algorithms (`HS256`) or non-RSA JWKs are rejected with `401 Unauthorized` (`ServerError::Auth`).\n- Non-HTTPS, non-loopback JWKS fetch URLs are rejected safely before making outbound HTTP requests.\n- `forge-server` CORS responds according to `EFORGE_CORS_ALLOWED_ORIGINS` rather than permissive wildcard by default.\n- All `forge-server` unit and integration tests pass.\n\n## Technical notes\n- Use `tower_http::cors::AllowOrigin::list(...)` for parsed `HeaderValue` origins and explicit `AllowMethods` / `AllowHeaders`.\n- Restrict accepted JWKS token header algorithms to `Algorithm::RS256 | Algorithm::RS384 | Algorithm::RS512`.\n\n## Dependencies\n- Part of #256 (independent leaf crate hardening in `forge-server`).\n\n## Definition of Done\n- [ ] Implementation completed in `crates/forge-server/src/{config.rs,app.rs,auth/jwks.rs}`.\n- [ ] Unit/integration tests cover symmetric JWKS rejection, SSRF URL validation, and CORS allowlist config.\n- [ ] Tier 1 CI verification passes (`cargo fmt -p forge-server -- --check`, `cargo clippy -p forge-server --all-targets -- -D warnings`, `cargo test -p forge-server`).\n- [ ] `docs/ARCHITECTURE_STATE.md` updated and PR squash-merged to `develop` after 100% green CI.\n","author":{"url":"https://github.com/luksluki","@type":"Person","name":"luksluki"},"datePublished":"2026-11-17T05:25:56Z","url":"https://github.com/elcode-id/elcode-forge/issues/262"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f723f88a-74a8-8c87-dad7-b8e18709eda3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D16A:B4606:198075D:235EC07:6B0593E3 |
| html-safe-nonce | 957d2274360e40e62b09ab93a2128e6b4076ce24a332a2e9bf5567d024253f98 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTZBOkI0NjA2OjE5ODA3NUQ6MjM1RUMwNzo2QjA1OTNFMyIsInZpc2l0b3JfaWQiOiI4Mzk5Mzk1MzUzMzI1MzEwOTQ3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 89d58bee052e0f3c5f9ed3f91d92d951940d62effcabf8f4e58c6437158d3a60 |
| hovercard-subject-tag | issue:6438045394 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/elcode-id/elcode-forge/262/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a33554d29c4352b31ad3c2e154251b97fb50b89e498b5006d90b2bbbb234f5cc/elcode-id/elcode-forge/issues/262 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a33554d29c4352b31ad3c2e154251b97fb50b89e498b5006d90b2bbbb234f5cc/elcode-id/elcode-forge/issues/262 |
| og:image:alt | Part of #256. Scope Add cors_allowed_origins: Vec |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | luksluki |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3b72fd2385d76a50ce0fe937d50bb4a81434432c4fd47866074a26f6cd03623f |
| turbo-cache-control | no-preview |
| go-import | github.com/elcode-id/elcode-forge git https://github.com/elcode-id/elcode-forge.git |
| octolytics-dimension-user_id | 337957755 |
| octolytics-dimension-user_login | elcode-id |
| octolytics-dimension-repository_id | 1423983661 |
| octolytics-dimension-repository_nwo | elcode-id/elcode-forge |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1423983661 |
| octolytics-dimension-repository_network_root_nwo | elcode-id/elcode-forge |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 58e2bd32336f3dcee343ec627a4d09c7c444e214 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width