feat(auth): add CSRF token generation and validation#14
Merged
halvaradop merged 5 commits intomasterfrom Nov 25, 2025
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces full support for CSRF (Cross-Site Request Forgery) tokens across the authentication flows.
CSRF tokens are cryptographically strong, randomized, and unpredictable values designed to protect users from unauthorized actions attempted by attackers. These tokens ensure that critical operations, especially those triggered via
POST,DELETE, orPATCHrequests, cannot be executed without explicit user intent.By validating CSRF tokens, the library prevents attackers from forcing users to perform unwanted actions such as signing out or modifying account data.
CSRF Token Management
To support secure generation and validation of CSRF tokens, a new endpoint has been introduced:
/csrfTokenThis endpoint is responsible for issuing and verifying CSRF tokens:
These tokens are then used internally by routes that require strong CSRF protection.
Endpoints Using CSRF Tokens
/callback/:oauthGenerates the CSRF token for the authenticated session after a successful OAuth callback.
/signOutValidates the CSRF token before revoking the active session.