mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-04-25 17:25:57 +03:00
[PR #6433] Make JWT token refresh optional #3781
Labels
No labels
SSO
Third party
better for forum
bug
bug
documentation
duplicate
enhancement
future Vault
future Vault
future Vault
good first issue
help wanted
low priority
notes
pull-request
question
troubleshooting
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vaultwarden#3781
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/dani-garcia/vaultwarden/pull/6433
Author: @Momi-V
Created: 11/3/2025
Status: 🔄 Open
Base:
main← Head:auth-renew📝 Commits (10+)
1f2c2cfAdd option to disable refresh token renewal830d395Add logic to make token renew optionalbd06258Add Clone trait to TokenWrapper enumcc90430Reuse original claims struct for refresh token renewal19cce48pass original refresh_claim into renewal functionb4f5581Pass correct type5a90dbcAdd optional parameter existing_refresh_claims to AuthTokens2515d46Add optional parameter existing_refresh_claims to AuthTokens99f061dAdd Clone trait to RefreshJwtClaims struct78bd39eClone refresh_claims.sub📊 Changes
4 files changed (+28 additions, -10 deletions)
View changed files
📝
src/api/identity.rs(+1 -1)📝
src/auth.rs(+21 -7)📝
src/config.rs(+4 -0)📝
src/sso.rs(+2 -2)📄 Description
This implements a config option
disable_refresh_token_renewal, that doesn't do refresh token renewal unless a full auth is performed.Goal:
Only renew the JWT token that allows PIN unlock, bypassing 2FA, etc. if a "full authentication" is performed. This makes things like "require 2FA once every 30/90 days" possible
Rationale:
Currently it's only possible to require periodic reauthentication by setting clients to log-out instead of lock. This is inconvenient since it breaks PIN, offline functionality and requires full reauthentication for every unlock. The current lock behavior on the other hand only requires reauth if a client hasn't connected in 30/90 days, since the token is renewed even on a reduced login that used that same token. This means it effectively never expires, if the client just uses it's existing token more than once a month.
Logic:
If the new option is
falsethe old logic is used (always renew the token). If a normal Password/SSO login is performed the old logic is used.If the option is
truethe JWT isn't renewed in the_refresh_logincode path, leaving it to expire and force a full auth after 30/90 daysCode:
Having
refresh_claims.sub.clone()andSome(&refresh_claims)in the same call isn't amazing, but seems like the simplest way to implement this logic without a refactor to overloadAuthToken::newinto 2 separate, yet almost identical functions.Progress:
Compiled and running, but not yet tested to actually behave as expected (currently ongoing).
Feedback welcome
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.