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

Removing CSRF token throughout the form #268

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

EdwinGuzman
Copy link
Member

Description

Removes CSRF token initialization and verification for username, address, and the final form submission.

NOTE: Vercel never worked so that check can be ignored.

Motivation and Context

@charmingduchess noticed we weren't really using CSRF properly in this app.
Additionally, this issue is blocking testing the app on QA which is a problem because devops updated the RDS DB's postgres version. We cannot test and verify that their update is working if we cannot submit the form.

This works for me locally.

How Has This Been Tested?

Ran this app and the Card Creator API locally. The CC API points to the QA environment which hits the QA database.

Checklist:

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Copy link

vercel bot commented Mar 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nypl-library-card-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 14, 2025 7:19pm

Copy link

@samanthaandrews samanthaandrews left a comment

Choose a reason for hiding this comment

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

🚀


try {
const response = await callPatronAPI(data, createPatronUrl, appObj);
console.log("resonse", response);

Choose a reason for hiding this comment

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

nit: remove stray console.log()

@@ -16,7 +16,7 @@ jest.mock("crypto", () => {
};
});

describe("validateCsrfToken", () => {
describe.skip("validateCsrfToken", () => {

Choose a reason for hiding this comment

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

should we remove this test?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I was debating keeping it or not but I'll just remove.

Copy link
Contributor

@mwbenowitz mwbenowitz left a comment

Choose a reason for hiding this comment

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

Just one question, but very possible I just missed part of this PR.

One thing that's been bothering me with this is: why CSRF here, it feels like a misaligned use of the standard. I think what we really need in the API is a CORS check? Perhaps that's already happening, but I'm just trying to wrap my head around what exactly we want to see here.

@@ -60,7 +60,6 @@ const AddressContainer: React.FC = () => {
.post("/library-card/api/address", {
address: homeAddress,
isWorkAddress: false,
csrfToken,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see this being checked/parsed anywhere. Does that happen automatically in the HTTP client?

Also, just to be sure, this argument/parameter isn't required by the endpoint? Don't want anything to crash because this suddenly isn't being passed

Copy link
Member Author

Choose a reason for hiding this comment

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

It's parsed in a backend utility function.

This might be a moot point and I think I'll end up closing this PR to keep CSRF set. @nonword @charmingduchess can you give more details on why we should keep it in the app?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with Mike! If there is something obvious to replace it with, I think it would make sense to.

@EdwinGuzman EdwinGuzman requested a review from nonword March 13, 2025 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants