Skip to content

Commit 5b646dd

Browse files
MeAkibalan-agius4
andauthored
Update adev/src/content/guide/security.md
Co-authored-by: Alan Agius <alan.agius4@gmail.com>
1 parent 9111587 commit 5b646dd

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎adev/src/content/guide/security.md‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,11 @@ If you cannot generate nonces in your project, you can allow inline styles by ad
192192
Angular itself requires only these settings to function correctly.
193193
As your project grows, you may need to expand your CSP settings to accommodate extra features specific to your application.
194194

195-
#### Static hosting and CDN caching
195+
#### Static hosting without per-response nonces
196196

197-
A nonce only protects your application if every response carries a different one.
198-
When you deploy your application as prebuilt static files, for example to object storage, GitHub Pages, or a CDN that caches `index.html`, every visitor receives the same HTML.
199-
A nonce written into that HTML, whether in the `ngCspNonce` attribute or through the `CSP_NONCE` token, is the same for every visitor and does not provide the protection of a nonce.
200-
Do not hard-code a nonce in a static build.
197+
If your hosting environment or CDN can replace a placeholder token in cached HTML at the edge (for example, using SSI, ESI, or an edge function), you can build `index.html` with a placeholder in `ngCspNonce` (such as `<app ngCspNonce="__CSP_NONCE__"></app>`) and replace it with a unique nonce on each response.
201198

202-
Instead, use one of the following approaches, which don't depend on per-response values.
199+
If you deploy your application to a static host that serves `index.html` unchanged without edge transformation, do not hard-code a static nonce. Instead, use one of the following approaches:
203200

204201
**Hash the inline scripts with `autoCsp`**
205202

0 commit comments

Comments
 (0)