-
Notifications
You must be signed in to change notification settings - Fork 47
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
feat: csp nonce generation #115
Conversation
Pull Request Test Coverage Report for Build 623488680
💛 - Coveralls |
Pull Request Test Coverage Report for Build 623488680
💛 - Coveralls |
Pull Request Test Coverage Report for Build 624002530
💛 - Coveralls |
Opps, missed this comment #90 (comment) |
cspDirectives[styleKey] = Array.isArray(cspDirectives.styleSrc) ? cspDirectives.styleSrc : [] | ||
cspDirectives[styleKey].push('nonce-' + reply.cspNonce.style) | ||
|
||
const cspMiddleware = helmet.contentSecurityPolicy({ directives: cspDirectives, reportOnly: cspReportOnly }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the generation of this middleware outside of the hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a must for this middleware to exist inside the hook. As we are not passing the function
inside helmet.
The options for helmet.contentSecurityPolicy
is unique for every calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Go ahead and merge & release this! |
Resolve: #89
This PR aims to simplify the usage for csp nonce generation with
fastify
andhelmet
.Changes:
enableCSPNonces
FastifyReply
withcspNonce
Checklist
npm run test
andnpm run benchmark
and the Code of conduct