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

Add convenience functions for secure headers like Content-Security-Policy #5

Open
RoyalIcing opened this issue Sep 21, 2021 · 0 comments

Comments

@RoyalIcing
Copy link
Contributor

RoyalIcing commented Sep 21, 2021

Could be something that accepts a generator function to help make a gnarly header like:
Content-Security-Policy: default-src 'self'; img-src *; media-src *; style-src 'self' 'unsafe-hashes' 'unsafe-inline' https://unpkg.com; script-src 'self'

function* ContentSecurityPolicy() {
  yield src.default('self');
  yield src.img(src.unsafeAny);
  yield src.media(src.unsafeAny);
  yield src.style('self', 'unsafe-hashes', 'unsafe-inline', new URL('https://unpkg.com'));
  yield src.script('self');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant