Package io.jmix.superset
Interface SupersetTokenManager
- All Known Implementing Classes:
SupersetTokenManagerImpl
public interface SupersetTokenManager
Provides Superset tokens management: access token, CSRF token (if is enabled). It stores tokens and cares about
refreshing tokens if it is needed.
-
Method Summary
Modifier and TypeMethodDescriptionThe access token is available after Spring context refresh when a "login" request is sent to Superset.Depends onSupersetProperties.isCsrfProtectionEnabled()application property.The refresh token is available after Spring context refresh when a "login" request is sent to Superset.voidRefreshes an access token.voidDepends onSupersetProperties.isCsrfProtectionEnabled()application property.
-
Method Details
-
refreshAccessToken
void refreshAccessToken()Refreshes an access token. It sends a "login" request for the first time and then sends "refresh" requests. A refresh request is sent only when the difference between expiration time and current time is less than or equal to one minute.This method is managed by
SupersetTokenScheduleConfigurer. The Spring scheduler is configured to invoke this method withSupersetProperties.getAccessTokenRefreshSchedule()delay. -
getAccessToken
The access token is available after Spring context refresh when a "login" request is sent to Superset.- Returns:
- access token or
nullif it's not initialized
-
getRefreshToken
The refresh token is available after Spring context refresh when a "login" request is sent to Superset.- Returns:
- refresh token or
nullif it's not initialized
-
refreshCsrfToken
void refreshCsrfToken()Depends onSupersetProperties.isCsrfProtectionEnabled()application property. If it's enabled a request will be sent to get a new CSRF token. Then thegetCsrfToken()method will return new CSRF token.This method is managed by
SupersetTokenScheduleConfigurer. The Spring scheduler is configured to invoke this method withSupersetProperties.getCsrfTokenRefreshSchedule()delay.Note, that CSRF token does not encode the expiration time so the schedule delay duration is configured almost equal to a default value of CSRF token expiration in Superset (WTF_CSRF_TIME_LIMIT property). If the value of expiration time is changed in Superset, the
SupersetProperties.getCsrfTokenRefreshSchedule()should be changed too. -
getCsrfToken
Depends onSupersetProperties.isCsrfProtectionEnabled()application property. If it's enabled a CSRF token will be fetched on Spring context refresh. Otherwise, no CSRF token will be fetched and method will returnnull.- Returns:
- a CSRF token or
nullif CSRF protection is disabled
-