zapier / prom-aggregation-gateway

An aggregating push gateway for Prometheus
Mozilla Public License 2.0
116 stars 26 forks source link

Add CORS header support on metrics PUT/POST. #60

Closed triluch closed 1 year ago

triluch commented 1 year ago

In the scenario where prom-aggregation-gateway is exposed to external client that writes metrics (so, browser for example) it should support adding CORS header (Access-Control-Allow-Origin) also on PUT/POST requests. This adds another layer of security (incorrect origins will be rejected) and allows matching origins to read the response from the gateway - browser client can confirm that metrics were indeed sent correctly.

Also added few simple router tests for GET and PUT with both failed and successful CORS.

Fixes https://github.com/zapier/prom-aggregation-gateway/issues/58