Skip to content

feat(api): add startup CORS configuration validator and origin policy (#689) - #750

Open
ravendevhub wants to merge 1 commit into
Core-Foundry:mainfrom
ravendevhub:feat/cors-validation-689
Open

feat(api): add startup CORS configuration validator and origin policy (#689)#750
ravendevhub wants to merge 1 commit into
Core-Foundry:mainfrom
ravendevhub:feat/cors-validation-689

Conversation

@ravendevhub

Copy link
Copy Markdown

Summary

Resolves #689 by establishing startup CORS origin validation (listener/src/api/cors-validator.ts) that enforces explicit origin declarations via comma-separated strings or JSON lists, validates URL schemas, and strictly prohibits silent fallbacks to permissive wildcards in production environments.

Changes

  1. CORS Validation Engine (listener/src/api/cors-validator.ts):
    • Parses and validates origins from CORS_ALLOWED_ORIGINS.
    • Validates URI structure (protocols must be http: or https:, no trailing path segments).
    • Forbids permissive wildcard (*) in production environments unless explicitly opted in.
  2. Automated Unit Tests (listener/src/api/cors-validator.test.ts):
    • Tests comma-separated parsing, JSON array format, production wildcard rejection, and malformed URL detection.
  3. Documentation (docs/CORS_CONFIGURATION_VALIDATION.md):
    • Outlines CORS policy, configuration formats, and production hardening guidelines.

Acceptance Criteria

  • Allowed origins are explicitly configurable.
  • Invalid origin configuration is rejected.
  • Wildcard configuration is clearly documented.
  • Sensitive environments do not silently fall back to permissive settings.

…Core-Foundry#689)

- Enforce explicit allowed origins configuration via comma-separated or JSON list
- Validate origin URL schemas (http/https protocols, no path segments)
- Prohibit silent fallback to permissive wildcards in production environments
- Add unit test suite in cors-validator.test.ts and docs in docs/CORS_CONFIGURATION_VALIDATION.md
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.

Add CORS Configuration Validation

1 participant