Minor ticket refresh / role permission improvements

This commit is contained in:
AFaust 2020-02-20 01:52:34 +01:00
parent 5e7e439e19
commit 55184fe219
3 changed files with 8 additions and 6 deletions

View File

@ -555,7 +555,8 @@ public class IDMClientImpl implements InitializingBean, IDMClient
this.tokenLock.readLock().lock(); this.tokenLock.readLock().lock();
try try
{ {
if (this.token != null && (!this.token.canRefresh() || !this.token.shouldRefresh(this.deployment.getTokenMinimumTimeToLive()))) if (this.token != null && this.token.isActive()
&& (!this.token.canRefresh() || !this.token.shouldRefresh(this.deployment.getTokenMinimumTimeToLive())))
{ {
validToken = this.token.getToken(); validToken = this.token.getToken();
} }
@ -570,7 +571,7 @@ public class IDMClientImpl implements InitializingBean, IDMClient
this.tokenLock.writeLock().lock(); this.tokenLock.writeLock().lock();
try try
{ {
if (this.token != null if (this.token != null && this.token.isActive()
&& (!this.token.canRefresh() || !this.token.shouldRefresh(this.deployment.getTokenMinimumTimeToLive()))) && (!this.token.canRefresh() || !this.token.shouldRefresh(this.deployment.getTokenMinimumTimeToLive())))
{ {
validToken = this.token.getToken(); validToken = this.token.getToken();

View File

@ -32,11 +32,12 @@ function process(permissions)
{ {
// enhance permissionObj.authority to at least add displayName // enhance permissionObj.authority to at least add displayName
// may/will still look like a user in UI which only differentiates groups / users // may/will still look like a user in UI which only differentiates groups / users
// UI does not display full authority name unless we include it in the displayName (different to authority picker)
permissionObj.authority = { permissionObj.authority = {
name : authority, name : authority,
fullName : authority, fullName : authority,
shortName : authority.substring(5), shortName : authority.substring(5),
displayName : role.description || role.keycloakName displayName : (role.description || role.keycloakName) + ' (' + authority + ')'
}; };
} }
} }

View File

@ -1168,19 +1168,19 @@ public class KeycloakAuthenticationFilter implements DependencyInjectedFilter, I
// not really feasible to synchronise / lock concurrent refresh on token // not really feasible to synchronise / lock concurrent refresh on token
// not a big problem - apart from wasted CPU cycles / latency - since each concurrently refreshed token is valid // not a big problem - apart from wasted CPU cycles / latency - since each concurrently refreshed token is valid
// independently // independently
if (token == null || (token.canRefresh() && token.shouldRefresh(this.keycloakDeployment.getTokenMinimumTimeToLive()))) if (token == null || !token.isActive() || (token.canRefresh() && token.shouldRefresh(this.keycloakDeployment.getTokenMinimumTimeToLive())))
{ {
AccessTokenResponse response; AccessTokenResponse response;
try try
{ {
if (token != null) if (token != null && token.canRefresh())
{ {
LOGGER.debug("Refreshing access token for Alfresco backend resource {}", alfrescoResourceName); LOGGER.debug("Refreshing access token for Alfresco backend resource {}", alfrescoResourceName);
response = ServerRequest.invokeRefresh(this.keycloakDeployment, token.getRefreshToken()); response = ServerRequest.invokeRefresh(this.keycloakDeployment, token.getRefreshToken());
} }
else else
{ {
LOGGER.debug("Retrieving initial access token for Alfresco backend resource {}", alfrescoResourceName); LOGGER.debug("Retrieving initial / new access token for Alfresco backend resource {}", alfrescoResourceName);
response = this.getAccessToken(alfrescoResourceName, session); response = this.getAccessToken(alfrescoResourceName, session);
} }
} }