xp-forge / frontend

Web frontends
1 stars 1 forks source link

Security headers #30

Closed thekid closed 1 year ago

thekid commented 1 year ago

Idea

Add a web.frontend.SecurityHeaders API to cover all of: X-Content-Type-Options ✅, Content-Security-Policy, X-Frame-Options, Referrer-Policy and Permissions-Policy, e.g. as follows:

new SecurityHeaders(
  csp: "default-src 'none'; ...",
  framing: 'DENY',  // or: ALLOW, SAMEORIGIN, ALLOW-FROM [URL]
  referrers: 'no-referrer-when-downgrade', // or: strict-origin, origin-when-cross-origin, etcetera 
  permissions: '...'
);

See https://securityheaders.com/?q=https%3A%2F%2Fdialog.sloppy.zone%2F

Inspired by

thekid commented 1 year ago

X-Content-Type-Options: nosniff was added in https://github.com/xp-forge/frontend/releases/tag/v2.1.0

thekid commented 1 year ago

Sensible defaults