Skip to content

0.3.0

Compare
Choose a tag to compare
@0xTim 0xTim released this 31 Mar 07:48
· 137 commits to master since this release

Vapor Security Headers 0.3.0

The release adds the ability to set page specific Content Security Policies to allow you to enable different content only when needed rather than on a whole site basis.

To add a specific CSP to a request, create a separate ContentSecurityPolicyConfiguration and then add it to the request. For example, inside a route handler, you could do:

let pageSpecificCSPVaue = "default-src 'none'; script-src https://comments.disqus.com;"
let pageSpecificCSP = ContentSecurityPolicyConfiguration(value: pageSpecificCSPValue)
request.contentSecurityPolicy = pageSpecificCSP