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

feat: make CSRF protection stable #11021

Merged
merged 11 commits into from
May 22, 2024
Merged

feat: make CSRF protection stable #11021

merged 11 commits into from
May 22, 2024

Conversation

ematipico
Copy link
Member

Changes

This PR makes CSRF protection stable. As for now, we decided to not implement a cookie strategy because it requires a strategy that isn't very Astro-y.

The configuration has been changed, and it was make less deep:

export default defineConfig({
-  experimental: {
-    security: {
-      csrfProtection: {
-        origin: true
-      }
-    }
-  },
+  security: {
+    checkOrigin: true
+  }
})

Testing

The current tests should pass.

Docs

/cc @withastro/maintainers-docs for feedback!

Copy link

changeset-bot bot commented May 13, 2024

🦋 Changeset detected

Latest commit: d6402dd

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr A PR that includes documentation for review semver: minor Change triggers a `minor` release labels May 13, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@ematipico ematipico added this to the 4.9.0 milestone May 13, 2024
@matthewp
Copy link
Contributor

In addition to unflagging the RFC should be updated to account for the fact that we're not going to be doing the cookie check for now. You could either remove that section or move it to the alternative ideas section: withastro/roadmap#879

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Just a quick thought here for the docs, @ematipico !

Also, wondering whether we might want to link here from any other docs pages like our "Authentication" guide as a "thing to consider enabling".

Is there any reason why someone might have authentication on their Astro site and NOT want this set?

packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Copy link
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

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

Blocked pending the call for consensus passing.

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Other than a more detailed changeset for this unflagged feature, just a couple of quick suggestions for the actual docs to take a look at! (Note, one earlier comment was updated based on feedback).

.changeset/chatty-experts-smell.md Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
ematipico and others added 3 commits May 20, 2024 11:58
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@ematipico
Copy link
Member Author

Just a quick thought here for the docs, @ematipico !

Also, wondering whether we might want to link here from any other docs pages like our "Authentication" guide as a "thing to consider enabling".

Is there any reason why someone might have authentication on their Astro site and NOT want this set?

If users are using SSR and plan to expose some endpoints that should be reachable from external domains (e.g. posting a form), then they should not enable this feature, otherwise all requests coming from external domains will be blocked.

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

This looks great! A few minor tweaks, and checking closely, I think we need to move up the JSDoc content to the "Top-level Options" section.

Otherwise, ready to go!

.changeset/chatty-experts-smell.md Outdated Show resolved Hide resolved
.changeset/chatty-experts-smell.md Outdated Show resolved Hide resolved
@@ -1686,6 +1686,47 @@ export interface AstroUserConfig {
*/
legacy?: object;

/**
* @docs
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be moved much higher up in the file? It loos like this will now appear under "Legacy Flags" in the sidebar.

This is a top-level option, right? So it should probably move up maybe between scopedStyleStrategy and vite? These aren't in alphabetical order, but manually by common usage first, and then whenever just seems right. I think just above vite makes sense, but open to suggestions if you don't like that!

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

ematipico and others added 3 commits May 20, 2024 13:59
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Great! I left two tiny fixes in comments, but I am happy to consider this good to go! 🥳

@ematipico ematipico merged commit 2d4c8fa into main May 22, 2024
5 checks passed
@ematipico ematipico deleted the feat/unflag-check-origin branch May 22, 2024 11:10
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@astrobot-houston astrobot-houston mentioned this pull request May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr A PR that includes documentation for review pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants