Skip to content

Refresh auth token if user is actively using the Atlas UI#3002

Merged
chrisknoll merged 2 commits intoOHDSI:masterfrom
uc-cdis:fix/refresh_auth_token
Mar 24, 2025
Merged

Refresh auth token if user is actively using the Atlas UI#3002
chrisknoll merged 2 commits intoOHDSI:masterfrom
uc-cdis:fix/refresh_auth_token

Conversation

@pieterlukasse
Copy link
Contributor

Addresses #3001

Adds new listeners that detect user activity and refresh auth token if user is actively using the Atlas UI.

@chrisknoll
Copy link
Collaborator

Thanks for the contribution. I've done a little work looking at the refresh token mechanics.

It seems that we don't need to refresh the token until the timeout has elapsed on the session token. I think you'll find in the codebase where we do a check to see if the refresh token is about to expire, then it will use the refresh token to reset the timeout.

I think this block of code captures the logic:

			if (authApi.authProvider() === authApi.AUTH_PROVIDERS.IAP) {
				return authApi.loadUserInfo();
			} else if (appConfig.userAuthenticationEnabled && authApi.token() != null && this.timeToExpire() < appConfig.refreshTokenThreshold) {
				return authApi.refreshToken();
			}
			return Promise.resolve();

Instead of refreshing the token on every 30 user interactions (which is actually a crazy amount of refreshing if we are signaliing off each mouse move event), maybe we shoudl just simply check to see if the refreshToken is about to expire...if it is, then we can refresh the token.

@pieterlukasse
Copy link
Contributor Author

great catch @chrisknoll . I've updated the code according to your suggestion. Please take a look.

@chrisknoll chrisknoll merged commit a96ebc6 into OHDSI:master Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants