Skip to content

Conversation

@Sharath-a26
Copy link

  • A 32-bit CSRF Token will be generated when logged in. Added to both response X-CSRF-Token header and to the cookie.
  • Requests that are not authenticated i.e Login, Register etc. need not pass the token in header
  • Created a middleware CSRFMiddleWare in util to check whether cookie and header token matches.

@Sharath-a26
Copy link
Author

@Ashrockzzz2003 Please review and let me know If I need to make any changes

@Ashrockzzz2003 Ashrockzzz2003 self-requested a review October 29, 2025 17:38
@Ashrockzzz2003 Ashrockzzz2003 linked an issue Oct 29, 2025 that may be closed by this pull request
Copy link
Member

@Ashrockzzz2003 Ashrockzzz2003 left a comment

Choose a reason for hiding this comment

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

can we hide it behind a feature flag (env var)?
the other evoc services make requests to this auth and they might not work without changes there.

@Sharath-a26
Copy link
Author

Sure, so if that var is set to false, the whole CSRF is disabled. Something like that right?

@Ashrockzzz2003
Copy link
Member

Yes

@Sharath-a26
Copy link
Author

Done with that change @Ashrockzzz2003

Copy link
Member

@Ashrockzzz2003 Ashrockzzz2003 left a comment

Choose a reason for hiding this comment

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

Thanks Sharath
But you need to add csrf to controller/grpc/authenticate.go too as this is the function that'll be called via grpc by other microservices to authenticate requests.

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.

Add CSRF protection as we're using cookies!

2 participants