-
-
Notifications
You must be signed in to change notification settings - Fork 143
chore(deps): update dependency csrf-csrf to v4 #1799
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
base: develop
Are you sure you want to change the base?
Conversation
c485412
to
d9b7e86
Compare
|
d9b7e86
to
3e10746
Compare
7333765
to
2c1517d
Compare
Edited/Blocked NotificationRenovate will not automatically rebase this PR, because it does not recognize the last commit author and assumes somebody else may have edited the PR. You can manually request rebase by checking the rebase/retry box above. |
apps/server/src/routes/index.ts
Outdated
//'validateOnReuse' set to false => if validation fails, generate a new token instead of throwing an error | ||
const csrfToken = generateCsrfToken(req, res, false, false); | ||
const csrfToken = generateCsrfToken(req, res, { | ||
overwrite: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setting overwrite: true
will cause issues to people that use the Server build and open up the interface on separate browser tabs (not Trilium internal tabs, but actual browser tabs)
it is explained in the packages README as well:
If overwrite is set to true, the function will generate a new token and cookie each time it is invoked. This behavior can potentially lead to certain complications, particularly when multiple tabs are being used to interact with your web application. In such scenarios, the creation of new cookies with every call to the function can disrupt the proper functioning of your web app across different tabs, as the changes might not be synchronised effectively (you would need to write your own synchronisation logic).
I assume you went this way because of the following?
https://github.com/Psifi-Solutions/csrf-csrf/blob/HEAD/UPGRADING.md#zero-downtime-upgrade-zdu
Deleting the existing cookie should be enough to fix that issue though (in theory -> I didn't test locally yet though).
edit:
btw: I was experiencing the exact same issue, back when I introduced csrf-csrf :-)
edit 2:
Alternative idea to fix this:
if we rename the cookie from "_csrf" to anything else, that should also "workaround" the issue.
I was anyways thinking if we maybe wanted to rename it to include "trilium" in the name anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pano9000 , I think changing the name of the cookie is the way to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :-)
This PR contains the following updates:
3.2.2
->4.0.2
Release Notes
Psifi-Solutions/csrf-csrf (csrf-csrf)
v4.0.2
Compare Source
Bug Fixes
v4.0.1
Compare Source
Bug Fixes
v4.0.0
Compare Source
⚠ BREAKING CHANGES
This list may not be an exhaustive list of breaking changes, for more information consult the version 3 -> 4 upgrade guide and the updated configuration documentation in the README.
createHmac
, the format has changed significantly, see the CSRF token format section of the upgrade guide.getSessionIdentifier
is now required and must return a unique identifier per-request (and per-session) - this is an essential part of CSRF token securitygetTokenFromRequest
renamed togetCsrfTokenFromRequest
generateToken
renamed togenerateCsrfToken
overwrite
andvalidateOnReuse
parameters forgenerateCsrfToken
have been merged into a single object parameter which also acceptscookieOptions
:generateCsrfToken(req, res, options);
validateOnReuse
is nowfalse
cookieOptions.sameSite
is nowstrict
cookieOptions.signed
is no longer available, CSRF tokens are inherently signed, this is redundantdelimiter
option removed,csrfTokenDelimiter
andmessageDelimiter
are now used for the respective purposesigned
option incookieOptions
config option removed (redundant), csrf tokens generated by csrf-csrf are inherently signedsize
config option now sets the size of the message used to construct the hmac, now defaults to32
instead of64
, this is combined with the return value ofgetSessionIdentifier
to construct the hmac payloadCsrfTokenCookieOverrides
renamed toCsrfTokenCookieOptions
CsrfTokenCreator
renamed toCsrfTokenGenerator
doubleCsrfProtection
renamed toDoubleCsrfProtection
RequestMethod
renamed toCsrfRequestMethod
CsrfIgnoredMethods
renamed toCsrfIgnoredRequestMethods
Features
3.2.2 (2025-04-24)
Bug Fixes
3.2.1 (2025-04-20)
No changes, just re-published the botched 3.2.0
Configuration
📅 Schedule: Branch creation - "before 3am" (UTC), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.