CORS Configuration

The server can be configured to use CORS - Cross-Origin Resource Sharing (CORS),

Summary of CORS

CORS is a browser security feature that restricts web pages from making requests to a different domain than the one that served the web page. This prevents malicious websites from accessing sensitive data from other sites.

Key Concepts

  • Origin: Defined by the protocol (e.g., http, https), domain (e.g., example.com), and port (e.g., :80, :443). Two URLs have the same origin only if all three components match exactly.

  • Cross-Origin Request: A request made from a script running on one origin to a resource on a different origin.

  • Preflight Request (OPTIONS): For certain “complex” requests (e.g., using HTTP methods other than GET, HEAD, or POST with certain content types), the browser sends a preliminary OPTIONS request to the server to check if the actual request is allowed.

  • HTTP Headers: CORS relies on specific HTTP headers exchanged between the browser and the server.

How CORS Works (Simplified)

  1. The browser makes a cross-origin request.

  2. The server responds with CORS-related headers.

  3. The browser checks these headers.

  4. If the headers indicate that the request is allowed based on the origin, method, and headers, the browser allows the response to be processed by the client-side script. Otherwise, the browser blocks the request or the processing of the response.

Why is CORS Important?

CORS is a crucial security mechanism that helps protect users from cross-site scripting (XSS) and other malicious attacks by preventing unauthorized access to resources.

CORS within Plugin Server

The plugin server uses a middleware to control CORS headers. If enabled the OPTIONS request for the preflight check by browsers is handled and if the connecting host is in the origin_url list the request can be satisfied.

Configuration of CORS

CORS is implemented in the plugin server with a few configuration key,value pairs under [CORS}

Key

Value/Usage

enabled

bool:true Enable cors

origin_url

list:https://host1.domain1.tld https://host2.domain2.tld

The minimal requirement is for enabled to be true and origin url to be populated.