wundergraph / cosmo

The open-source solution to building, maintaining, and collaborating on GraphQL Federation at Scale. The alternative to Apollo Studio and GraphOS.
https://cosmo-docs.wundergraph.com/
Apache License 2.0
623 stars 91 forks source link

Cors AllowWildcard never set - Wildcard origins not taken into account #879

Open YassineElbouchaibi opened 1 month ago

YassineElbouchaibi commented 1 month ago

router v0.92.3

Description

Using only a config.yaml to setup the router, it is impossible to make use of wildcards in cors.allow_origins as AllowWildcard is never set and therefore parseWildcardRules() doesn't pickup any rules.

Steps to Reproduce

Start a router with the following in the config:

cors:
  allow_origins: [http://*]
  allow_headers: ["*"]
  allow_credentials: true

Use chrome to make a fetch request to your router and you will get 403 Forbidden in the OPTIONS request.

Expected Result

OPTIONS request should go through

Actual Result

403 Forbidden in the OPTIONS request

Useful links

Using only a config.yaml to setup the router, it is impossible to make use of wildcards in cors.allow_origins as AllowWildcard is never set and therefore parseWildcardRules() doesn't pickup any rules.

Steps to Reproduce

Start a router with the following in the config:

cors:
  allow_origins: [http://*]
  allow_headers: ["*"]
  allow_credentials: true

Use chrome to make a fetch request to your router and you will get 403 Forbidden in the OPTIONS request.

Expected Result

OPTIONS request should go through

Actual Result

403 Forbidden in the OPTIONS request

Useful links

Config

version: '1'

dev_mode: true
router_config_path: config.json
graph:
  token: ''

listen_addr: 0.0.0.0:3002

graphql_path: '/'

headers:
  all:
    request:
      - op: 'propagate'
        named: authorization
      - op: 'propagate'
        named: Cookie
      - op: 'propagate'
        named: origin

cors:
  allow_origins: [http://*]
  allow_headers: ["*"]
  allow_credentials: true

telemetry:          
  prometheus:
    enabled: false # Side node: disabling prometheus doesn't work too
github-actions[bot] commented 1 month ago

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible. The roadmap is driven by our customers and we have to prioritize issues that are important to them. You can influence the priority by becoming a customer. Please contact us here.