Skip to content

Separate the jwt token expiration time and active threshold #3730

Closed

Description

@jaeyun0503

Context (Issue)

After the PR #3625 was merged, many users have been experiencing frequent log out. Before the PR was introduced, the expiration time for a jwt token was set to two days. But our current design sets both the jwt token expiration time and the active threshold (a threshold to determine if a user is active or not) variable to the configurable variable expiration-in-minutes in auth.conf, which is on default set to 15 minutes.

Proposed Solution

For a better user experience, we should separate these two variables so that admins can see which users were active during the last 15 minutes (active threshold), while users do not get frequently logged out of the Texera system. We can introduce a new variable in the auth.conf solely for the active threshold variable, and by doing this we would be able to ensure that users do not get logged out frequently while we can also keep track of users' activeness. Currently we are leaning towards setting the token expiration time to 2 days.

Mechanism of jwt token Renewal and Expiration

When a user is active (interacting with Texera), every http request will use the user's jwt token to communicate with the backend server to first validate the token. As long as the token is valid/fresh, the http request will go through and the user is allowed to do actions on Texera.
There are two things to mention here: Token expiration time and Token renewal time. Token expiration time marks the time when the jwt token will expire -- Say the token expiration time is set to two days, if a user has been inactive for two days, the token will expire and when the user attempts to use the expired jwt token to do actions on Texera, the backend system will log the user out and let them login again. Token renewal time is a set time where the user's browser explicitly calls the backend to refresh the user's token to get a fresh token. It is usually set to a time prior to the token expiration time to avoid active users from being logged out. In our current implementation the refresh time is set to expiration time - 1, so whenever the token is about to expire, as long as the user is on the Texera page, the browser will attempt to get the fresh token by talking to the backend, allowing users to use Texera system without having troubles with automatic log out.

Mechanism of tracking user's activeness

Users' activeness is tracked by updating the last active timestamp whenever a user sends a valid http request. We have a user_last_active_time table in the database to store a user's last active timestamp. In our jwtAuthFilter, we implemented a sql statement to update user's last active time whenever they send a valid http request, and in the admin dashboard we would use the current timestamp subtracted by every user's last active time to compare with the active threshold to determine a user is active or not.

auth.conf code screenshot

Image

Active threshold active_window screenshot

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions