Browse Source

Clear security settings cache on upgrade

pull/11578/head
ViacheslavKlimov 2 years ago
parent
commit
a246032e54
  1. 6
      application/src/main/java/org/thingsboard/server/controller/AuthController.java
  2. 5
      application/src/main/java/org/thingsboard/server/service/install/update/DefaultCacheCleanupService.java

6
application/src/main/java/org/thingsboard/server/controller/AuthController.java

@ -31,8 +31,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.thingsboard.rule.engine.api.MailService;
import org.thingsboard.server.cache.limits.RateLimitService;
@ -86,8 +84,7 @@ public class AuthController extends BaseController {
notes = "Get the information about the User which credentials are used to perform this REST API call.")
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@GetMapping(value = "/auth/user")
public @ResponseBody
User getUser() throws ThingsboardException {
public User getUser() throws ThingsboardException {
SecurityUser securityUser = getCurrentUser();
return userService.findUserById(securityUser.getTenantId(), securityUser.getId());
}
@ -96,7 +93,6 @@ public class AuthController extends BaseController {
notes = "Special API call to record the 'logout' of the user to the Audit Logs. Since platform uses [JWT](https://jwt.io/), the actual logout is the procedure of clearing the [JWT](https://jwt.io/) token on the client side. ")
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@PostMapping(value = "/auth/logout")
@ResponseStatus(value = HttpStatus.OK)
public void logout(HttpServletRequest request) throws ThingsboardException {
logLogoutAction(request);
}

5
application/src/main/java/org/thingsboard/server/service/install/update/DefaultCacheCleanupService.java

@ -61,6 +61,10 @@ public class DefaultCacheCleanupService implements CacheCleanupService {
log.info("Clearing cache to upgrade from version 3.6.4 to 3.7.0");
clearAll();
break;
case "3.7.0":
log.info("Clearing cache to upgrade from version 3.7.0 to 3.7.1");
clearCacheByName(SECURITY_SETTINGS_CACHE);
break;
default:
//Do nothing, since cache cleanup is optional.
}
@ -88,4 +92,5 @@ public class DefaultCacheCleanupService implements CacheCleanupService {
}
cacheManager.getCacheNames().forEach(this::clearCacheByName);
}
}

Loading…
Cancel
Save