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 CSP & Cache Control headers #2478

Merged
merged 15 commits into from
May 24, 2023
Merged

Add CSP & Cache Control headers #2478

merged 15 commits into from
May 24, 2023

Conversation

himadrisingh
Copy link
Contributor

Please go the the Preview tab and select the appropriate sub-template:

@himadrisingh himadrisingh self-assigned this May 22, 2023
@himadrisingh himadrisingh marked this pull request as draft May 22, 2023 13:45
@github-actions github-actions bot temporarily deployed to production May 22, 2023 13:47 Inactive
@github-actions github-actions bot temporarily deployed to production May 22, 2023 14:02 Inactive
@github-actions github-actions bot temporarily deployed to production May 22, 2023 14:21 Inactive
@github-actions github-actions bot temporarily deployed to production May 22, 2023 14:26 Inactive
@github-actions github-actions bot temporarily deployed to production May 22, 2023 14:35 Inactive
@github-actions github-actions bot temporarily deployed to production May 22, 2023 14:41 Inactive
@github-actions github-actions bot temporarily deployed to production May 22, 2023 14:47 Inactive
@github-actions github-actions bot temporarily deployed to production May 22, 2023 14:53 Inactive
@github-actions github-actions bot temporarily deployed to production May 22, 2023 15:01 Inactive
@himadrisingh himadrisingh marked this pull request as ready for review May 22, 2023 15:09
@github-actions github-actions bot temporarily deployed to production May 22, 2023 15:15 Inactive
Copy link
Contributor

@begelundmuller begelundmuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the headers different for /* and /-/*? It's a SPA, and there are user-facing pages on both paths, so I would think everything should have the same headers?

@himadrisingh
Copy link
Contributor Author

Why are the headers different for /* and /-/*? It's a SPA, and there are user-facing pages on both paths, so I would think everything should have the same headers?

/-/* endpoints have confirm codes etc, those should be non-cached ideally. But looks like SPA doesn't validates the confirm codes.

[[headers]]
for = "/*"
[headers.values]
Content-Security-Policy = "default-src https:; script-src https: 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data: blob:"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Shouldn't we use script-src 'self'? The application shouldn't be loading remote scripts
  • Same for styles
  • Images may come from auth providers, so we need wider permissions there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

script-src are inline and we have to calculate nonce of them, which can be problematic for developers. Sometimes we use open source libraries. But defailt-src is https which gets applied to all.

netlify.toml Outdated
Permissions-Policy = "geolocation=(),midi=(),sync-xhr=(self),microphone=(),camera=(),magnetometer=(),gyroscope=(),fullscreen=(self),payment=()"
Referrer-Policy = "no-referrer"
X-Frame-Options = "SAMEORIGIN"
X-Xss-Protection = "1; mode=block"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://securityheaders.com/?q=ui.rilldata.io&followRedirects=on this doesn't require this so we can remove it.

netlify.toml Outdated
Comment on lines 12 to 19
[[headers]]
for = "/-/*"
[headers.values]
cache-control = '''
max-age=0,
no-cache,
no-store,
must-revalidate'''
Copy link
Contributor

@begelundmuller begelundmuller May 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed. The application is a SPA, so it serves static content on all routes. Any dynamic parameters in the query string will only be consumed client-side, not rendered in the content (so e.g. confirmation codes will not be cached).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, we can remove this as its not working as expected.

netlify.toml Outdated Show resolved Hide resolved
netlify.toml Outdated Show resolved Hide resolved
@himadrisingh himadrisingh merged commit e4615b9 into main May 24, 2023
@himadrisingh himadrisingh deleted the headers branch May 24, 2023 16:27
djbarnwal pushed a commit that referenced this pull request Aug 3, 2023
* Add CSP & Cache Control headers
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

Successfully merging this pull request may close these issues.

2 participants