[Design Proposal] Configurable CORS for Agent APIs via API Platform Policy #913
AnoshanJ
started this conversation in
Design Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
CORS for deployed agent APIs is hardcoded in the
agent-apiComponentType as a Kubernetes Gateway APItype: CORSfilter on the external HTTPRoute, with a single allowed origin (http://localhost:3000) baked into the platform definition.This creates two problems:
api-key-auth) are managed. The two layers are inconsistent.User Stories
localhost:3000) to production (my-app.example.com) without asking a platform operator.api-key-authso all per-API security settings are managed in one consistent place.Existing Solutions
http://localhost:3000as the only allowed origin.gateway-controllersCORS policy: The WSO2 API Platform already ships acorsv1.0.1 policy that handles CORS at the policy-engine layer, supports per-API origin lists, methods, headers, credentials, and max-age — the same mechanism used byapi-key-authtoday. See gateway-controllers/policies/cors.Proposed Solution
Overview
Move CORS from the ComponentType HTTPRoute filter to the API Platform Gateway
corsv1.0.1 policy, attached via theapi-configurationtrait'spoliciesarray. ExposeallowedOriginsas a user-configurable field in the deployment drawer with the current defaults preserved.Design
corspolicy is added to theRestApiCRD'sspec.policiesarray (alongsideapi-key-auth) on every agent deployapi-configurationtrait patch is extended to also remove the HTTPRoute CORS filter when attaching — making each agent's transition from old filter to new policy atomic at deploy timeallowedOrigins: ["http://localhost:3000"], standard methods and headers — no change in behavior out of the boxallowedOriginsin the deployment drawer; stored per-environment inagent_configsDB tableDeployAgentRequestAPI is extended with acorsConfigfield (reusing the existingspec.CORSConfigmodel)Open Questions
Milestones
corspolicy toapi-configurationtrait; extend trait patch to remove HTTPRoute CORS filter atomicallycorsConfig.allowedOriginsper-deployment: DB column, API field, service logicDependencies:
corsv1.0.1 policy must be installed and registered on the API Platform Gateway.Related: #901
Beta Was this translation helpful? Give feedback.
All reactions