@@ -15,12 +15,10 @@ fn cors_safe_security_headers() -> Vec<HeaderField> {
1515 // Prevents the page from being displayed in a frame, iframe, embed or object
1616 // This helps prevent clickjacking attacks
1717 ( "X-Frame-Options" . to_string( ) , "DENY" . to_string( ) ) ,
18-
1918 // X-Content-Type-Options: nosniff
2019 // Prevents browsers from MIME-sniffing the content type
2120 // Forces browsers to respect the declared Content-Type header
2221 ( "X-Content-Type-Options" . to_string( ) , "nosniff" . to_string( ) ) ,
23-
2422 // Strict-Transport-Security (HSTS)
2523 // Forces browsers to use HTTPS for all future requests to this domain
2624 // max-age=31536000: Valid for 1 year (365 days)
@@ -29,12 +27,10 @@ fn cors_safe_security_headers() -> Vec<HeaderField> {
2927 "Strict-Transport-Security" . to_string( ) ,
3028 "max-age=31536000 ; includeSubDomains" . to_string( ) ,
3129 ) ,
32-
3330 // Referrer-Policy: same-origin
3431 // Controls how much referrer information is sent with requests
3532 // same-origin: Only send referrer to same-origin requests
3633 ( "Referrer-Policy" . to_string( ) , "same-origin" . to_string( ) ) ,
37-
3834 // Content-Security-Policy: default-src 'none'
3935 // Minimal CSP for OPTIONS - blocks all content since no scripts should execute
4036 (
@@ -187,20 +183,17 @@ pub fn security_headers(
187183 // Prevents the page from being displayed in a frame, iframe, embed or object
188184 // This is a legacy header, also enforced by CSP frame-ancestors directive
189185 ( "X-Frame-Options" . to_string( ) , "DENY" . to_string( ) ) ,
190-
191186 // X-Content-Type-Options: nosniff
192187 // Prevents browsers from MIME-sniffing a response away from the declared content-type
193188 // Reduces risk of drive-by downloads and serves as defense against MIME confusion attacks
194189 ( "X-Content-Type-Options" . to_string( ) , "nosniff" . to_string( ) ) ,
195-
196190 // Content-Security-Policy (CSP)
197191 // Comprehensive policy to prevent XSS attacks and data injection
198192 // See content_security_policy_header() function for detailed explanation
199193 (
200194 "Content-Security-Policy" . to_string( ) ,
201195 content_security_policy_header( integrity_hashes, maybe_related_origins) ,
202196 ) ,
203-
204197 // Strict-Transport-Security (HSTS)
205198 // Forces browsers to use HTTPS for all future requests to this domain
206199 // max-age=31536000: Valid for 1 year (31,536,000 seconds)
@@ -209,13 +202,11 @@ pub fn security_headers(
209202 "Strict-Transport-Security" . to_string( ) ,
210203 "max-age=31536000 ; includeSubDomains" . to_string( ) ,
211204 ) ,
212-
213205 // Referrer-Policy: same-origin
214206 // Controls how much referrer information is sent with outgoing requests
215207 // same-origin: Only send referrer to same-origin requests (no cross-origin leakage)
216208 // Note: "no-referrer" would be more strict but breaks local dev deployment
217209 ( "Referrer-Policy" . to_string( ) , "same-origin" . to_string( ) ) ,
218-
219210 // Permissions-Policy (formerly Feature-Policy)
220211 // Controls which browser features and APIs can be used
221212 // Most permissions are denied by default, with specific exceptions:
0 commit comments