GetDKAN / dkan

DKAN Open Data Portal
https://dkan.readthedocs.io/en/latest/index.html
GNU General Public License v2.0
364 stars 171 forks source link

Re-open public APIs for CORS requests #3537

Open dafeder opened 3 years ago

dafeder commented 3 years ago

We were possibly too hasty with #3258 . Let's find a way to open the origin header to * for just the public endpoints.

Acceptance criteria

susisiman commented 3 years ago

This ticket is more of a best practice approach for out-of-the-box core without an API key. It will be site-specific, since everyone will have different securities or regulations around what they do. This is a low-priority ticket.

janette commented 3 years ago

for reference: on DEV and TEST envs we use development.services.yml

parameters:
  cors.config:
    enabled: true
    # Specify allowed headers, like 'x-allowed-header'.
    allowedHeaders: ['*']
    # Specify allowed request methods, specify ['*'] to allow all possible ones.
    allowedMethods: ['*']
    # Configure requests allowed from specific origins.
    allowedOrigins: ['*']
    # Sets the Access-Control-Expose-Headers header.
    exposedHeaders: false
    # Sets the Access-Control-Max-Age header.
    maxAge: false
    # Sets the Access-Control-Allow-Credentials header.

on PROD we use production.services.yml

parameters:
  cors.config:
    enabled: true
    # Specify allowed headers, like 'x-allowed-header'.
    allowedHeaders: ['x-csrf-token','authorization','content-type','accept','origin','x-requested-with', 'access-control-allow-origin','x-allowed-header','*']
    # Specify allowed request methods, specify ['*'] to allow all possible ones.
    allowedMethods: ['GET','POST']
    # Configure requests allowed from specific origins.
    allowedOrigins: [
      'https://domain1.com',
      'https://domain2.com'
    ]