Add a Content Security Policy builder
Content Security policies can be a long and complex string. Is it worth creating a simple function/struct/builder to make constructing these easier, and in a less error prone way? Something like:
secure.Options{
ContentSecurityPolicy: secure.ContentSecurityPolicy{
DefaultSrc: ["self"],
ScriptSrc: ["self", "www.google-analytics.com"]
}
}
I think that would be a good idea. For backswards compatibility, I wonder if we can do something like:
cspOptions := secure.ContentSecurityPolicyOptions{
DefaultSrc: ["self"],
ScriptSrc: ["self", "www.google-analytics.com"]
}
secure.Options{
ContentSecurityPolicy: cspOptions.Compile() // or .String()?
}
Yes, .String() sounds better for backwards compatibility. And then other people could possibly reuse that aspect of the library if they wish.
While I don't have a lot of free time, is be happy to contribute this.
I guess this is still available? If so, I would like to help :slightly_smiling_face:
I guess this is still available? If so, I would like to help 🙂
No one is currently working on this, so any help would be greatly appreciated!
Resolved by https://github.com/unrolled/secure/pull/86