1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
use HashMap;
/// Main configuration struct for the Shield middleware
///
/// This struct contains configuration for all security headers that can be set by the Shield middleware.
/// Each field represents a different security feature and can be individually configured or disabled.
/// All security features use secure defaults when using `ShieldConfig::default()`.
///
/// ## Field Overview
///
/// * `content_security_policy` - Controls CSP header generation and directives
/// * `hsts` - Configures HTTP Strict Transport Security behavior
/// * `frameguard` - Controls X-Frame-Options header for clickjacking protection
/// * `no_sniff` - Enables X-Content-Type-Options: nosniff header
/// * `xss_filter` - Configures X-XSS-Protection header (legacy)
/// * `referrer_policy` - Controls Referrer-Policy header for privacy
/// * `dns_prefetch_control` - Manages X-DNS-Prefetch-Control header
/// * `ie_no_open` - Sets X-Download-Options: noopen for IE protection
/// * `hide_powered_by` - Removes X-Powered-By header to hide server info
/// * `permissions_policy` - Configures Permissions-Policy for browser features
/// * `cross_origin_opener_policy` - Sets Cross-Origin-Opener-Policy header
/// * `cross_origin_resource_policy` - Sets Cross-Origin-Resource-Policy header
/// * `cross_origin_embedder_policy` - Sets Cross-Origin-Embedder-Policy header
/// * `origin_agent_cluster` - Controls Origin-Agent-Cluster header
/// * `cross_domain_policy` - Sets X-Permitted-Cross-Domain-Policies header
/// HTTP Strict Transport Security (HSTS) configuration
///
/// HSTS forces browsers to use HTTPS connections and prevents protocol downgrade attacks.
/// Once a browser receives an HSTS header, it will refuse to connect to the server over HTTP
/// for the specified duration, providing protection against man-in-the-middle attacks.
///
/// ## Security Benefits
///
/// * **Prevents protocol downgrade attacks** - Blocks HTTP connections after first HTTPS visit
/// * **Mitigates SSL stripping** - Protects against attacks that try to downgrade to HTTP
/// * **Improves user privacy** - Ensures all connections are encrypted
/// * **Reduces attack surface** - Eliminates HTTP as a potential attack vector
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the HSTS header (default: true)
/// * `max_age` - How long browsers should enforce HTTPS in seconds (default: 1 year)
/// * `include_subdomains` - Whether HSTS applies to all subdomains (default: true)
/// * `preload` - Whether to indicate the site should be included in browser preload lists (default: false)
///
/// ## Important Notes
///
/// * **HTTPS required** - HSTS headers are ignored when served over HTTP
/// * **Long-term commitment** - Setting a long max_age creates a long-term commitment to HTTPS
/// * **Preload considerations** - Enabling preload requires manual submission to browser vendors
/// * **Subdomain impact** - `include_subdomains` affects all current and future subdomains
/// X-Frame-Options (Frameguard) configuration
///
/// The X-Frame-Options header prevents clickjacking attacks by controlling whether
/// the current page can be embedded within frames, iframes, embeds, or objects on other websites.
/// This header is crucial for preventing UI redressing attacks where malicious sites
/// overlay transparent frames to trick users into clicking on hidden elements.
///
/// ## Protection Modes
///
/// * **DENY** - Never allow the page to be framed (most secure, default)
/// * **SAMEORIGIN** - Only allow framing from the same origin
/// * **ALLOW-FROM** - Only allow framing from a specific domain (requires domain parameter)
///
/// ## Security Considerations
///
/// * **DENY is most secure** - Provides complete protection against clickjacking
/// * **SAMEORIGIN for internal frames** - Use when you need to frame your own content
/// * **ALLOW-FROM for partners** - Use only for trusted partner domains
/// * **Modern alternative** - Consider using CSP frame-ancestors directive instead
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the X-Frame-Options header (default: true)
/// * `action` - The framing policy: "deny", "sameorigin", or "allow-from" (default: "deny")
/// * `domain` - Specific domain for "allow-from" action (required when action is "allow-from")
/// X-Content-Type-Options configuration
///
/// The X-Content-Type-Options header prevents MIME type sniffing attacks by instructing
/// browsers to strictly follow the Content-Type header rather than trying to guess
/// the content type based on file content. This prevents malicious files from being
/// executed when they're disguised as safe content types.
///
/// ## Security Benefits
///
/// * **Prevents MIME confusion attacks** - Stops browsers from executing malicious content
/// * **Enforces Content-Type headers** - Ensures proper content type handling
/// * **Reduces attack surface** - Eliminates content sniffing as an attack vector
/// * **Simple and effective** - Single value provides comprehensive protection
///
/// ## How It Works
///
/// When `nosniff` is set, browsers will:
/// * Refuse to execute scripts if Content-Type is not a JavaScript MIME type
/// * Refuse to apply stylesheets if Content-Type is not `text/css`
/// * Not try to guess content types for other resources
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the X-Content-Type-Options: nosniff header (default: true)
/// X-XSS-Protection configuration
///
/// The X-XSS-Protection header enables and configures the browser's built-in XSS filter.
/// **Note: This header is deprecated in modern browsers** as Content Security Policy
/// provides superior XSS protection. However, it's included for legacy browser support.
///
/// ## Deprecation Notice
///
/// Modern browsers have removed or disabled XSS filtering due to:
/// * **Security vulnerabilities** - The filter itself could be exploited
/// * **False positives** - Legitimate content was sometimes blocked
/// * **Better alternatives** - CSP provides more robust XSS protection
///
/// ## Legacy Support
///
/// This header is maintained for:
/// * **Older browsers** - Browsers that don't support modern CSP features
/// * **Defense in depth** - Additional layer of protection alongside CSP
/// * **Compatibility** - Applications that haven't migrated to CSP-only protection
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the X-XSS-Protection header (default: true)
/// * `mode` - Protection mode: "block" or "filter" (default: "block")
/// * `report_uri` - Optional URI for violation reporting
///
/// ## Recommendation
///
/// Use Content Security Policy instead of relying on X-XSS-Protection for new applications.
/// This header should be considered a legacy compatibility feature.
/// Referrer-Policy configuration
///
/// The Referrer-Policy header controls how much referrer information is included
/// when navigating from your site to other sites. This helps protect user privacy
/// and prevents sensitive information in URLs from being leaked to third parties.
///
/// ## Privacy Benefits
///
/// * **Protects sensitive URLs** - Prevents leaking URLs containing tokens or personal data
/// * **Reduces tracking** - Limits the ability of sites to track user navigation patterns
/// * **Improves user privacy** - Gives users more control over their browsing information
/// * **Prevents information disclosure** - Stops accidental leaking of internal URLs
///
/// ## Policy Options
///
/// * **no-referrer** - Never send referrer information
/// * **no-referrer-when-downgrade** - Send referrer for HTTPS→HTTPS, not HTTPS→HTTP (default)
/// * **origin** - Only send the origin, not the full URL
/// * **origin-when-cross-origin** - Send full URL for same-origin, origin only for cross-origin
/// * **same-origin** - Only send referrer for same-origin requests
/// * **strict-origin** - Send origin only, and only for HTTPS→HTTPS
/// * **strict-origin-when-cross-origin** - Full URL same-origin, origin cross-origin, respect HTTPS
/// * **unsafe-url** - Always send full referrer (not recommended)
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the Referrer-Policy header (default: true)
/// * `policy` - The referrer policy to use (default: "no-referrer-when-downgrade")
/// X-DNS-Prefetch-Control configuration
///
/// The X-DNS-Prefetch-Control header controls DNS prefetching behavior in browsers.
/// DNS prefetching allows browsers to resolve domain names before they're actually needed,
/// improving perceived performance but potentially impacting user privacy.
///
/// ## Privacy vs Performance Trade-off
///
/// **Allowing DNS prefetching:**
/// * **Performance benefit** - Faster loading of external resources
/// * **Privacy cost** - DNS queries reveal user browsing patterns
/// * **Bandwidth usage** - Additional DNS queries consume bandwidth
///
/// **Disabling DNS prefetching:**
/// * **Privacy benefit** - Reduces DNS query leakage
/// * **Performance cost** - Slower loading of external resources
/// * **Bandwidth saving** - Fewer unnecessary DNS queries
///
/// ## Default Behavior
///
/// By default, this middleware **disables** DNS prefetching (`allow: false`) to prioritize
/// user privacy over performance. This is appropriate for most privacy-conscious applications.
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the X-DNS-Prefetch-Control header (default: true)
/// * `allow` - Whether to allow DNS prefetching (default: false for privacy)
/// X-Download-Options configuration for Internet Explorer
///
/// The X-Download-Options header is specific to Internet Explorer and prevents IE
/// from executing downloaded files in the context of your site. When set to "noopen",
/// IE will not show the "Open" button in the download dialog, forcing users to save
/// files to disk before opening them.
///
/// ## Security Benefits
///
/// * **Prevents execution in site context** - Downloaded files can't execute with site privileges
/// * **Reduces malware risk** - Forces users to explicitly save and open files
/// * **Protects against drive-by downloads** - Prevents automatic execution of malicious files
/// * **Legacy IE protection** - Specifically addresses IE security vulnerabilities
///
/// ## Modern Relevance
///
/// This header is primarily relevant for:
/// * **Legacy IE support** - Organizations still supporting Internet Explorer
/// * **Comprehensive security** - Defense-in-depth strategies
/// * **File download applications** - Sites that frequently serve downloadable files
/// * **Minimal overhead** - No performance cost for modern browsers (ignored)
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the X-Download-Options: noopen header (default: true)
///
/// ## Note
///
/// Modern browsers ignore this header, but including it provides protection for legacy IE users
/// with minimal overhead.
/// X-Powered-By header removal configuration
///
/// The HidePoweredBy feature removes the X-Powered-By header from HTTP responses.
/// This header typically reveals information about the server technology stack,
/// which can be useful for attackers performing reconnaissance.
///
/// ## Security Through Obscurity
///
/// While not a primary security measure, hiding server information:
/// * **Reduces attack surface discovery** - Attackers have less information about your stack
/// * **Prevents targeted attacks** - Makes it harder to identify specific vulnerabilities
/// * **Improves operational security** - Reduces information disclosure
/// * **Industry best practice** - Commonly recommended security hardening step
///
/// ## Information Disclosure Prevention
///
/// Common X-Powered-By headers reveal:
/// * **Server technology** - "Express", "ASP.NET", "PHP", etc.
/// * **Version information** - Specific versions of frameworks
/// * **Technology stack** - Programming languages and frameworks used
///
/// ## Configuration Options
///
/// * `enabled` - Whether to remove X-Powered-By headers (default: true)
///
/// ## Implementation Note
///
/// When enabled, this feature removes any existing X-Powered-By header that might be
/// set by the application framework or server. The removal happens during response
/// processing, ensuring no powered-by information is leaked.
/// Permissions-Policy configuration
///
/// The Permissions-Policy header (formerly Feature-Policy) controls which browser features
/// and APIs can be used in the current document and any embedded frames. This provides
/// fine-grained control over powerful browser capabilities that could be abused if
/// accessed without permission.
///
/// ## Controllable Features
///
/// Common browser features that can be controlled:
/// * **camera** - Access to camera devices
/// * **microphone** - Access to microphone devices
/// * **geolocation** - Access to location information
/// * **payment** - Access to Payment Request API
/// * **usb** - Access to USB devices
/// * **bluetooth** - Access to Bluetooth devices
/// * **accelerometer** - Access to device motion sensors
/// * **gyroscope** - Access to device orientation sensors
/// * **magnetometer** - Access to magnetometer sensors
/// * **fullscreen** - Ability to enter fullscreen mode
/// * **picture-in-picture** - Picture-in-picture video capability
///
/// ## Allowlist Values
///
/// For each feature, you can specify an allowlist:
/// * **Empty list** `()` - Completely disable the feature
/// * **"self"** - Allow only for the current origin
/// * **Specific origins** - Allow for listed origins only
/// * **"\*"** - Allow for all origins (not recommended)
///
/// ## Default Configuration
///
/// The default configuration disables high-risk features:
/// * **camera** - Disabled (empty allowlist)
/// * **microphone** - Disabled (empty allowlist)
/// * **geolocation** - Allowed for same origin only
/// * **payment** - Disabled (empty allowlist)
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the Permissions-Policy header (default: true)
/// * `features` - HashMap of feature names to allowlist vectors
///
/// ## Security Benefits
///
/// * **Prevents feature abuse** - Malicious scripts can't access dangerous APIs
/// * **Reduces attack surface** - Disables unnecessary browser capabilities
/// * **Protects user privacy** - Controls access to sensitive device features
/// * **Granular control** - Different policies for different features
/// Cross-Origin-Opener-Policy configuration
///
/// The Cross-Origin-Opener-Policy (COOP) header allows you to ensure that a top-level
/// document does not share a browsing context group with cross-origin documents.
/// This provides protection against cross-origin attacks that rely on having a
/// reference to your window object.
///
/// ## Security Benefits
///
/// * **Prevents window object access** - Cross-origin pages can't access your window
/// * **Protects against Spectre** - Helps isolate sensitive content in separate processes
/// * **Reduces attack surface** - Limits cross-origin interactions
/// * **Enables advanced security features** - Required for some security-sensitive APIs
///
/// ## Policy Options
///
/// * **SameOrigin** - Isolate from cross-origin documents (most secure, default)
/// * **SameOriginAllowPopups** - Isolate but allow popups to maintain references
/// * **UnsafeNone** - No isolation (least secure, legacy compatibility)
///
/// ## Compatibility Considerations
///
/// * **Breaking changes** - May break legitimate cross-origin interactions
/// * **Popup compatibility** - SameOrigin policy may break popup functionality
/// * **iframe interactions** - May affect cross-origin iframe communication
/// * **Third-party integrations** - May require adjustment for payment processors, etc.
///
/// ## Default Configuration
///
/// The default is `SameOrigin` for maximum security. Consider `SameOriginAllowPopups`
/// if your application uses popups for authentication or payments.
/// Cross-Origin-Resource-Policy configuration
///
/// The Cross-Origin-Resource-Policy (CORP) header allows you to control which
/// websites can embed your resources (images, scripts, stylesheets, etc.) as subresources.
/// This provides protection against side-channel attacks like Spectre by controlling
/// cross-origin resource access at the network level.
///
/// ## Security Benefits
///
/// * **Prevents resource inclusion attacks** - Controls which sites can embed your resources
/// * **Protects against side-channel attacks** - Helps mitigate Spectre-class vulnerabilities
/// * **Reduces data leakage** - Prevents unauthorized cross-origin resource access
/// * **Complements CORS** - Provides additional layer beyond CORS policy
///
/// ## Policy Options
///
/// * **SameOrigin** - Only allow same-origin resource inclusion (most secure, default)
/// * **SameSite** - Allow same-site resource inclusion (includes subdomains)
/// * **CrossOrigin** - Allow cross-origin resource inclusion (least secure)
///
/// ## Use Cases
///
/// * **SameOrigin** - Internal applications, admin panels, sensitive content
/// * **SameSite** - Multi-subdomain applications with shared resources
/// * **CrossOrigin** - Public APIs, CDN resources, embeddable widgets
///
/// ## Compatibility Notes
///
/// * **May break CDN usage** - SameOrigin policy blocks legitimate cross-origin embedding
/// * **Image/media sharing** - Consider CrossOrigin for publicly shareable media
/// * **API endpoints** - APIs typically need CrossOrigin policy
/// * **Widget/embed services** - Embeddable content requires CrossOrigin
/// Content Security Policy configuration
///
/// Content Security Policy (CSP) is the most powerful security header available,
/// providing comprehensive protection against XSS attacks, data injection, and
/// other code injection vulnerabilities. CSP works by defining a whitelist of
/// trusted sources for various types of content.
///
/// ## How CSP Works
///
/// CSP uses directives to control resource loading:
/// * **default-src** - Fallback for other directives
/// * **script-src** - Controls JavaScript execution
/// * **style-src** - Controls CSS loading and inline styles
/// * **img-src** - Controls image loading
/// * **font-src** - Controls font loading
/// * **connect-src** - Controls AJAX, WebSocket, EventSource connections
/// * **media-src** - Controls audio and video loading
/// * **object-src** - Controls plugins (Flash, Java, etc.)
/// * **frame-src** - Controls iframe sources
/// * **worker-src** - Controls web workers and service workers
/// * **manifest-src** - Controls web app manifest loading
///
/// ## Common Source Values
///
/// * **'self'** - Same origin as the document
/// * **'unsafe-inline'** - Allow inline scripts/styles (not recommended)
/// * **'unsafe-eval'** - Allow eval() and similar (not recommended)
/// * **'none'** - Block all sources
/// * **https:** - Allow any HTTPS source
/// * **data:** - Allow data: URIs
/// * **blob:** - Allow blob: URIs
/// * **Specific domains** - https://example.com, https://cdn.jsdelivr.net
/// * **'nonce-<value>'** - Allow resources with matching nonce attribute
/// * **'sha256-<hash>'** - Allow resources matching specific hash
///
/// ## Security Benefits
///
/// * **XSS prevention** - Primary defense against cross-site scripting
/// * **Data injection protection** - Prevents malicious resource loading
/// * **Clickjacking mitigation** - frame-ancestors directive controls embedding
/// * **Mixed content prevention** - Enforces HTTPS-only resource loading
/// * **Exfiltration prevention** - Controls where data can be sent
///
/// ## Default Configuration
///
/// The default CSP is restrictive but functional for most web applications:
/// * **default-src 'self'** - Only allow same-origin resources by default
/// * **script-src 'self'** - Only allow same-origin scripts
/// * **style-src 'self' 'unsafe-inline'** - Same-origin styles plus inline (necessary for many apps)
/// * **img-src 'self' data: https:** - Same-origin images, data URIs, and HTTPS images
/// * **object-src 'none'** - Block all plugins and embedded objects
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include CSP header (default: true)
/// * `directives` - HashMap of directive names to source values
/// * `report_only` - Whether to use report-only mode for testing (default: false)
///
/// ## Testing and Deployment
///
/// 1. **Start with report-only mode** - Set `report_only: true` to test without breaking functionality
/// 2. **Monitor violations** - Set up violation reporting to catch policy issues
/// 3. **Gradually tighten policy** - Remove 'unsafe-inline' and 'unsafe-eval' when possible
/// 4. **Use nonces or hashes** - For inline scripts/styles that can't be moved to external files
/// 5. **Deploy enforcement** - Set `report_only: false` when confident in policy
/// Cross-Origin-Embedder-Policy configuration
///
/// The Cross-Origin-Embedder-Policy (COEP) header allows you to prevent a document
/// from loading any cross-origin resources that don't explicitly grant permission.
/// This enables powerful browser features like SharedArrayBuffer by ensuring that
/// all cross-origin resources are loaded with explicit consent.
///
/// ## Security and Performance Benefits
///
/// * **Enables SharedArrayBuffer** - Required for high-performance web applications
/// * **Prevents data leakage** - Ensures explicit consent for cross-origin resources
/// * **Improves process isolation** - Helps browser implement stronger security boundaries
/// * **Enables precise timing APIs** - Required for performance.now() with high resolution
///
/// ## Policy Options
///
/// * **RequireCorp** - Require Cross-Origin-Resource-Policy header on all cross-origin resources
/// * **UnsafeNone** - No requirements (default, maintains compatibility)
///
/// ## Compatibility Impact
///
/// **RequireCorp policy may break:**
/// * **Third-party images** - Without proper CORP headers
/// * **External stylesheets** - From CDNs without CORP headers
/// * **Embedded content** - Widgets, ads, social media embeds
/// * **API responses** - Cross-origin API calls without CORP
///
/// ## Migration Strategy
///
/// 1. **Audit cross-origin resources** - Identify all external resources
/// 2. **Add CORP headers** - Ensure external resources have proper headers
/// 3. **Test thoroughly** - Verify all functionality works with COEP enabled
/// 4. **Enable incrementally** - Start with non-critical pages
///
/// ## Default Configuration
///
/// Default is `UnsafeNone` to maintain compatibility. Only enable `RequireCorp`
/// if you need SharedArrayBuffer or high-resolution timing APIs and have ensured
/// all cross-origin resources have appropriate CORP headers.
/// Origin-Agent-Cluster configuration
///
/// The Origin-Agent-Cluster header requests that the browser place the current
/// document in an origin-keyed agent cluster. This provides additional process
/// isolation by ensuring that documents from different origins are placed in
/// separate agent clusters, improving security and enabling certain performance
/// optimizations.
///
/// ## Security Benefits
///
/// * **Process isolation** - Better separation between different origins
/// * **Reduces side-channel attacks** - Harder for malicious sites to infer information
/// * **Improves memory safety** - Separate memory spaces for different origins
/// * **Future-proofs security** - Enables stronger isolation features as browsers evolve
///
/// ## Performance Implications
///
/// * **Memory overhead** - Each agent cluster requires separate resources
/// * **Slower cross-origin communication** - May impact legitimate cross-origin interactions
/// * **Browser optimization** - May enable better browser optimizations for single-origin content
///
/// ## When to Enable
///
/// Enable Origin-Agent-Cluster when:
/// * **Security is paramount** - High-value applications requiring maximum isolation
/// * **Single-origin applications** - Apps that don't heavily interact with other origins
/// * **Memory is not constrained** - Systems that can handle additional memory overhead
/// * **Modern browser targets** - Applications targeting browsers with good OAC support
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include the Origin-Agent-Cluster: ?1 header (default: true)
///
/// ## Browser Support
///
/// This is a relatively new header with growing browser support. It's safe to enable
/// as unsupporting browsers will simply ignore it.
/// Cross-Domain Policy configuration
///
/// The X-Permitted-Cross-Domain-Policies header controls whether Adobe Flash Player
/// and Adobe Reader can load content from your domain via cross-domain policy files.
/// While Flash is largely obsolete, this header is still relevant for legacy content
/// and provides defense-in-depth security.
///
/// ## Legacy Technology Context
///
/// This header was primarily important for:
/// * **Adobe Flash Player** - Now deprecated and removed from most browsers
/// * **Adobe Reader** - Legacy PDF handling in browsers
/// * **Silverlight** - Microsoft's Flash alternative, also deprecated
///
/// ## Policy Options
///
/// * **none** - Prohibit all cross-domain policy files (most secure, default)
/// * **master-only** - Only allow master cross-domain policy file
/// * **by-content-type** - Allow cross-domain policy files served with appropriate content type
/// * **by-ftp-filename** - Allow files named crossdomain.xml via FTP
/// * **all** - Allow all cross-domain policy files (least secure)
///
/// ## Security Benefits
///
/// * **Prevents Flash-based attacks** - Even for legacy Flash content
/// * **Reduces attack surface** - Blocks potential vector for old vulnerabilities
/// * **Defense in depth** - Additional security layer with minimal overhead
/// * **Compliance** - May be required for certain security standards
///
/// ## Default Configuration
///
/// Default policy is "none" which provides maximum security by completely
/// disabling cross-domain policy files. This is appropriate for modern
/// web applications that don't use legacy Flash/Silverlight content.
///
/// ## Configuration Options
///
/// * `enabled` - Whether to include X-Permitted-Cross-Domain-Policies header (default: true)
/// * `policy` - The cross-domain policy: "none", "master-only", etc. (default: "none")