Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe request attribute containing CSP nonce #898

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/docs/guide/views/security/csp.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ That's it! After applying the above configuration, HTTP responses might include
Content-Security-Policy: default-src https: self:; script-src 'nonce-4ze2IRazk4Yu/j5K6SEzjA';
```

The nonce value can be accessed on the server as a request attribute named `cspNonce`. This is the value to use
in the `nonce` attribute on `script` and related tags. For example (adapt as appropriate for your template language):

```html
graemerocher marked this conversation as resolved.
Show resolved Hide resolved
<script type="text/javascript" src="/path/to/script.js" nonce="${cspNonce}" />
```

Inline scripts which aren't otherwise whitelisted will be declined for execution, unless CSP is operating in report-only
mode. Inline scripts can be whitelisted with the syntax:

Expand Down