You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
closes#512
## All PRs:
* [x] Has tests
* [x] Documentation updated
## Adding a new header (Reporting-Endpoints)
**Is the header supported by any user agent?*
Yes - Chrome 116+, Edge 116+, Opera 102+ (via Reporting API)
**What does it do?**
Defines HTTP reporting endpoints for CSP violations and other
security/performance reports using the HTTP Reporting API
**What are the valid values?**
Comma-separated pairs of [name="url"] where url must be HTTPS (e.g.,
csp-violations="https://example.com/reports")
**Where does the specification live?**
[MDN
Reporting-Endpoints](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Reporting-Endpoints)
and [MDN report-to
directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/report-to)
## Adding a new CSP directive (report-to)
**Is the directive supported by any user agent?**
Yes - Chrome 69+, Edge 79+, Firefox 110+, Safari 15.1+
**What does it do?**
Specifies a named reporting endpoint (defined via Reporting-Endpoints
header) where CSP violations should be reported, replacing or
complementing report-uri
**What are the valid values?**
A single string endpoint name (e.g., report-to csp-violations), must
match a name defined in the Reporting-Endpoints header
---------
Co-authored-by: Kylie Stradley <kyfast@users.noreply.github.com>
SecureHeaders supports both the legacy `report-uri` and the modern `report-to` directives for CSP violation reporting:
108
+
109
+
#### report-uri (Legacy)
110
+
The `report-uri` directive sends violations to a URL endpoint. It's widely supported but limited to POST requests with JSON payloads.
111
+
112
+
```ruby
113
+
config.csp = {
114
+
default_src:%w('self'),
115
+
report_uri:%w(https://example.com/csp-report)
116
+
}
117
+
```
118
+
119
+
#### report-to (Modern)
120
+
The `report-to` directive specifies a named reporting endpoint defined in the `Reporting-Endpoints` header. This enables more flexible reporting through the HTTP Reporting API standard.
121
+
122
+
```ruby
123
+
config.csp = {
124
+
default_src:%w('self'),
125
+
report_to:"csp-endpoint"
126
+
}
127
+
128
+
config.reporting_endpoints = {
129
+
"csp-endpoint": "https://example.com/reports"
130
+
}
131
+
```
132
+
133
+
**Recommendation:** Use both `report-uri` and `report-to` for maximum compatibility while transitioning to the modern approach.
134
+
94
135
### Deprecated Configuration Values
95
136
*`block_all_mixed_content` - this value is deprecated in favor of `upgrade_insecure_requests`. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/block-all-mixed-content for more information.
0 commit comments