Repository navigation
Description
Summary
As we were discussing about the design of jwt token's refresh and expiration interval, we found that Texera does not have a security measure to reduce the risk of account hijacking. We want to add a security mechanism to enforce users to re-login periodically to avoid unauthorized access to users' data.
Context
Our current design of the system allows users to have fresh token by setting the token refresh interval to token expiration time - 1, which means that when a user's session is about to end, the browser will invoke the backend to issue a fresh token to keep the user authenticated (PR #3703 ). And when a user is not interacting with Texera for a certain amount of time that exceeds the token expiration time, the token will become invalid and the user will have to login again.
In PR #3731 we are separating the configurable variables and setting the expiration time to be 7 days. But considering security of the system, we should make sure that users should not always be logged in even if they are constantly active on the system -- A mechanism needs to be introduced so that users are periodically logged out no matter of the token's state.
Proposed Mechanism
We decided to implement re-authentication to the system. Many apps use this mechanism to ensure users are not always logged in. For example, Gmail logs users out every few days to let users re-authenticate. We want to use the same mechanism to forcefully log users out when the system hits the re-authentication time interval. Adding this mechanism will make sure that every user is logged out if they hit the re-authentication time, even if their tokens are valid. We came up with two designs:
Design 1
Introduce a new configurable variable to control the re-authentication time interval. The proposed configurable variable is different from the active threshold and token expiration time variables (see PR #3731) and should be added to auth.conf.
Design 2
Remove the token refresh interval. Since the token refresh interval is set to token expiration time - 1, we can simply set the token expiration time to 7 days and remove the token refresh interval. That way users will always need to re-authenticate after 7 days as there is no more token refresh mechanism.
Activity
chenlica commentedon Sep 16, 2025
Between these two designs, I prefer the first one. Any objections?
aicam commentedon Sep 16, 2025
I believe Design 1 is redundant
Sentiaus commentedon Sep 23, 2025
I don't think Design 1 is necessarily redundant. If you have users who are constantly active, it would probably be better to keep them logged in, and force a sign out once every 2 weeks to a month for security reasons.
I do think it's less effective if the token refresh is long. So would probably want to change the refresh to a shorter interval (24 or 48 hours) in this case.
I do think it's effective if the re-auth is dynamic. For example, with a token refresh of 24 hours, setting admin re-auth to 72 hours, while user re-auth is 168 hours.
Would be a bit complicated though logic wise, will try to create a pr for design 1.
chenlica commentedon Sep 23, 2025
@Sentiaus Thanks for the comments. We had an internal discussion about the two designs and came up with a solution. @jaeyun0503 : please chime in with our decision. It will be good for @Sentiaus to verify our decision.
jaeyun0503 commentedon Sep 24, 2025
Yes. We had an internal discussion on this Issue and we decided to go with Design 2 and use three PRs to address this and Issue #3738:
For the context of Bullet points 2 and 3, you can take a look at #3738 as we explained the reason behind the issue.
Sentiaus commentedon Sep 24, 2025
Sounds good! Think the second design sounds better for the scope, and will simplify the approach to PRs 2 and 3.
Sentiaus commentedon Sep 24, 2025
One thing I noticed, is that the
logoutfunction inauth.service.tsproperly deletes the user token and unsubscribes the expiration time, but does not trigger userChange like the comment says it does.Additionally the
changeUserfunction that does exist inuser.service.tsdoes not navigate the user away but actually only happens inuser-icon.component.ts:I believe this is fine, but definitely a negative UX when the user has been signed out due to token expiration, as they are not actually able to tell that they have been signed out.
jaeyun0503 commentedon Sep 24, 2025
Thanks for the comment. We will take a look into the code and address your comments.
feat(auth): removed token refresh functionality (#3765)
feat(auth): removed token refresh functionality (apache#3765)
feat(auth): removed token refresh functionality (apache#3765)
Yicong-Huang commentedon Jul 30, 2026
Revisiting this topic, I’m curious about the specific security concern with the refresh-token approach. If a new access token is issued only when the user’s account is still active in the system, wouldn’t this allow us to immediately stop token renewal after the account is disabled or revoked?
This would preserve long-running sessions for active users while still allowing the system to terminate access centrally when necessary. Is the remaining concern that a stolen refresh token could continue to be used indefinitely as long as the account remains active? If so, could refresh-token rotation, revocation, and an absolute session lifetime address that risk without requiring every user to log in again periodically?
chenlica commentedon Aug 2, 2026
@Neilk1021 @aglinxinyuan : as you two are extending user authentication, can you revisit this old topic?
aglinxinyuan commentedon Aug 2, 2026
I think current design is good enough.