Merge pull request #10271 from thingsboard/fix/rule-engine-jwt-settings
Fix JWT settings updating for Rule Engines
This commit is contained in:
commit
ada75cbfde
@ -32,8 +32,6 @@ import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@ -52,13 +50,12 @@ import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.rule.engine.api.MailService;
|
||||
import org.thingsboard.rule.engine.api.SmsService;
|
||||
import org.thingsboard.server.common.data.AdminSettings;
|
||||
import org.thingsboard.server.common.data.FeaturesInfo;
|
||||
import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.FeaturesInfo;
|
||||
import org.thingsboard.server.common.data.FeaturesInfo;
|
||||
import org.thingsboard.server.common.data.SystemInfo;
|
||||
import org.thingsboard.server.common.data.UpdateMessage;
|
||||
import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
|
||||
import org.thingsboard.server.common.data.audit.ActionType;
|
||||
import org.thingsboard.server.common.data.exception.ThingsboardErrorCode;
|
||||
import org.thingsboard.server.common.data.exception.ThingsboardException;
|
||||
import org.thingsboard.server.common.data.id.CustomerId;
|
||||
import org.thingsboard.server.common.data.id.EntityId;
|
||||
@ -74,8 +71,8 @@ import org.thingsboard.server.common.data.sync.vc.VcUtils;
|
||||
import org.thingsboard.server.dao.audit.AuditLogService;
|
||||
import org.thingsboard.server.dao.settings.AdminSettingsService;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.auth.oauth2.CookieUtils;
|
||||
import org.thingsboard.server.service.security.auth.jwt.settings.JwtSettingsService;
|
||||
import org.thingsboard.server.service.security.auth.oauth2.CookieUtils;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
import org.thingsboard.server.service.security.model.token.JwtTokenFactory;
|
||||
import org.thingsboard.server.service.security.permission.Operation;
|
||||
@ -93,7 +90,6 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.thingsboard.server.controller.ControllerConstants.*;
|
||||
import static org.thingsboard.server.controller.ControllerConstants.SYSTEM_AUTHORITY_PARAGRAPH;
|
||||
import static org.thingsboard.server.controller.ControllerConstants.TENANT_AUTHORITY_PARAGRAPH;
|
||||
|
||||
@ -113,9 +109,7 @@ public class AdminController extends BaseController {
|
||||
private final SmsService smsService;
|
||||
private final AdminSettingsService adminSettingsService;
|
||||
private final SystemSecurityService systemSecurityService;
|
||||
@Lazy
|
||||
private final JwtSettingsService jwtSettingsService;
|
||||
@Lazy
|
||||
private final JwtTokenFactory tokenFactory;
|
||||
private final EntitiesVersionControlService versionControlService;
|
||||
private final TbAutoCommitSettingsService autoCommitSettingsService;
|
||||
|
||||
@ -171,7 +171,7 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
|
||||
GitVersionControlQueueService vcQueueService,
|
||||
PartitionService partitionService,
|
||||
ApplicationEventPublisher eventPublisher,
|
||||
Optional<JwtSettingsService> jwtSettingsService,
|
||||
JwtSettingsService jwtSettingsService,
|
||||
NotificationSchedulerService notificationSchedulerService,
|
||||
NotificationRuleProcessor notificationRuleProcessor,
|
||||
TbImageService imageService) {
|
||||
|
||||
@ -54,6 +54,7 @@ import org.thingsboard.server.service.queue.processing.AbstractConsumerService;
|
||||
import org.thingsboard.server.service.queue.ruleengine.TbRuleEngineConsumerContext;
|
||||
import org.thingsboard.server.service.queue.ruleengine.TbRuleEngineQueueConsumerManager;
|
||||
import org.thingsboard.server.service.rpc.TbRuleEngineDeviceRpcService;
|
||||
import org.thingsboard.server.service.security.auth.jwt.settings.JwtSettingsService;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
@ -85,9 +86,11 @@ public class DefaultTbRuleEngineConsumerService extends AbstractConsumerService<
|
||||
TbAssetProfileCache assetProfileCache,
|
||||
TbTenantProfileCache tenantProfileCache,
|
||||
TbApiUsageStateService apiUsageStateService,
|
||||
PartitionService partitionService, ApplicationEventPublisher eventPublisher) {
|
||||
PartitionService partitionService,
|
||||
ApplicationEventPublisher eventPublisher,
|
||||
JwtSettingsService jwtSettingsService) {
|
||||
super(actorContext, encodingService, tenantProfileCache, deviceProfileCache, assetProfileCache, apiUsageStateService, partitionService,
|
||||
eventPublisher, tbRuleEngineQueueFactory.createToRuleEngineNotificationsMsgConsumer(), Optional.empty());
|
||||
eventPublisher, tbRuleEngineQueueFactory.createToRuleEngineNotificationsMsgConsumer(), jwtSettingsService);
|
||||
this.ctx = ctx;
|
||||
this.tbDeviceRpcService = tbDeviceRpcService;
|
||||
this.queueService = queueService;
|
||||
|
||||
@ -49,7 +49,6 @@ import org.thingsboard.server.service.security.auth.jwt.settings.JwtSettingsServ
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@ -75,14 +74,14 @@ public abstract class AbstractConsumerService<N extends com.google.protobuf.Gene
|
||||
protected final ApplicationEventPublisher eventPublisher;
|
||||
|
||||
protected final TbQueueConsumer<TbProtoQueueMsg<N>> nfConsumer;
|
||||
protected final Optional<JwtSettingsService> jwtSettingsService;
|
||||
protected final JwtSettingsService jwtSettingsService;
|
||||
|
||||
|
||||
public AbstractConsumerService(ActorSystemContext actorContext, DataDecodingEncodingService encodingService,
|
||||
TbTenantProfileCache tenantProfileCache, TbDeviceProfileCache deviceProfileCache,
|
||||
TbAssetProfileCache assetProfileCache, TbApiUsageStateService apiUsageStateService,
|
||||
PartitionService partitionService, ApplicationEventPublisher eventPublisher,
|
||||
TbQueueConsumer<TbProtoQueueMsg<N>> nfConsumer, Optional<JwtSettingsService> jwtSettingsService) {
|
||||
TbQueueConsumer<TbProtoQueueMsg<N>> nfConsumer, JwtSettingsService jwtSettingsService) {
|
||||
this.actorContext = actorContext;
|
||||
this.encodingService = encodingService;
|
||||
this.tenantProfileCache = tenantProfileCache;
|
||||
@ -181,7 +180,7 @@ public abstract class AbstractConsumerService<N extends com.google.protobuf.Gene
|
||||
}
|
||||
} else if (EntityType.TENANT.equals(componentLifecycleMsg.getEntityId().getEntityType())) {
|
||||
if (TenantId.SYS_TENANT_ID.equals(tenantId)) {
|
||||
jwtSettingsService.ifPresent(JwtSettingsService::reloadJwtSettings);
|
||||
jwtSettingsService.reloadJwtSettings();
|
||||
return;
|
||||
} else {
|
||||
tenantProfileCache.evict(tenantId);
|
||||
|
||||
@ -19,7 +19,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.rule.engine.api.NotificationCenter;
|
||||
@ -42,9 +41,7 @@ import java.util.Optional;
|
||||
@Slf4j
|
||||
public class DefaultJwtSettingsService implements JwtSettingsService {
|
||||
|
||||
@Lazy
|
||||
private final AdminSettingsService adminSettingsService;
|
||||
@Lazy
|
||||
private final Optional<TbClusterService> tbClusterService;
|
||||
private final Optional<NotificationCenter> notificationCenter;
|
||||
private final JwtSettingsValidator jwtSettingsValidator;
|
||||
@ -107,11 +104,13 @@ public class DefaultJwtSettingsService implements JwtSettingsService {
|
||||
|
||||
@Override
|
||||
public JwtSettings reloadJwtSettings() {
|
||||
log.trace("Executing reloadJwtSettings");
|
||||
return getJwtSettings(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JwtSettings getJwtSettings() {
|
||||
log.trace("Executing getJwtSettings");
|
||||
return getJwtSettings(false);
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@ import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
import org.thingsboard.server.service.security.model.UserPrincipal;
|
||||
import org.thingsboard.server.service.security.model.token.AccessJwtToken;
|
||||
import org.thingsboard.server.service.security.model.token.JwtTokenFactory;
|
||||
import org.thingsboard.server.service.security.model.token.RawAccessJwtToken;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user