iz
Clone
https://git.tahinli.com/Tahinli/iz.git
0 watching0 forksRustAGPL-3.0567.3 KiB3950aceTahinli27 days ago34 commits
| 1 | //! The security headers of every response, and the Content-Security-Policy they carry. |
| 2 | //! |
| 3 | //! The policy allows scripts and styles from the origin itself and nothing else. No page may use an |
| 4 | //! inline script, an inline style or an inline event handler: all behaviour lives in |
| 5 | //! `crates/iz-web/assets/*.js`. Changing [`CSP`] is a security change, so keep it in step with |
| 6 | //! `docs/conventions.md` section 5. |
| 7 | |
| 8 | use Cx; |
| 9 | use response_headers; |
| 10 | use ; |
| 11 | |
| 12 | /// The Content-Security-Policy of every response. |
| 13 | pub const CSP: &str = "default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; \ |
| 14 | form-action 'self'; frame-ancestors 'none'; base-uri 'none'"; |
| 15 | |
| 16 | /// One year, in seconds. Sent only when the public origin is https. |
| 17 | const HSTS: &str = "max-age=31536000"; |
| 18 | |
| 19 | /// The headers that every response carries, for an instance at `base_url`. |
| 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 | /// Adds a fixed set of headers to every response of the router. |
| 45 | /// |
| 46 | /// A header that the route already set is kept: a byte response carries its own policy. Errors take the |
| 47 | /// per-request response headers, which the router applies after the layers have run. |
| 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 |