Adding @TbCoreComponent to the 2FA services to fix rule-engine msa
This commit is contained in:
parent
8020bafd08
commit
d4bf9dd5d9
@ -42,6 +42,7 @@ import org.springframework.web.filter.CorsFilter;
|
||||
import org.thingsboard.server.dao.audit.AuditLogLevelFilter;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2Configuration;
|
||||
import org.thingsboard.server.exception.ThingsboardErrorResponseHandler;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.auth.jwt.JwtAuthenticationProvider;
|
||||
import org.thingsboard.server.service.security.auth.jwt.JwtTokenAuthenticationProcessingFilter;
|
||||
import org.thingsboard.server.service.security.auth.jwt.RefreshTokenAuthenticationProvider;
|
||||
@ -61,6 +62,7 @@ import java.util.List;
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled=true)
|
||||
@Order(SecurityProperties.BASIC_AUTH_ORDER)
|
||||
@TbCoreComponent
|
||||
public class ThingsboardSecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||
|
||||
public static final String JWT_TOKEN_HEADER_PARAM = "X-Authorization";
|
||||
@ -241,8 +243,4 @@ public class ThingsboardSecurityConfiguration extends WebSecurityConfigurerAdapt
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuditLogLevelFilter auditLogLevelFilter(@Autowired AuditLogLevelProperties auditLogLevelProperties) {
|
||||
return new AuditLogLevelFilter(auditLogLevelProperties.getMask());
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.thingsboard.server.dao.audit.AuditLogLevelFilter;
|
||||
import org.thingsboard.server.dao.audit.AuditLogLevelProperties;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ -28,6 +29,8 @@ public class ThingsboardInstallConfiguration {
|
||||
|
||||
@Bean
|
||||
public AuditLogLevelFilter emptyAuditLogLevelFilter() {
|
||||
return new AuditLogLevelFilter(new HashMap<>());
|
||||
var props = new AuditLogLevelProperties();
|
||||
props.setMask(new HashMap<>());
|
||||
return new AuditLogLevelFilter(props);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@ import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2Registration;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2User;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -34,6 +35,7 @@ import java.util.Map;
|
||||
|
||||
@Service(value = "appleOAuth2ClientMapper")
|
||||
@Slf4j
|
||||
@TbCoreComponent
|
||||
public class AppleOAuth2ClientMapper extends AbstractOAuth2ClientMapper implements OAuth2ClientMapper {
|
||||
|
||||
private static final String USER = "user";
|
||||
|
||||
@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2Registration;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2User;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -28,6 +29,7 @@ import java.util.Map;
|
||||
|
||||
@Service(value = "basicOAuth2ClientMapper")
|
||||
@Slf4j
|
||||
@TbCoreComponent
|
||||
public class BasicOAuth2ClientMapper extends AbstractOAuth2ClientMapper implements OAuth2ClientMapper {
|
||||
|
||||
@Override
|
||||
|
||||
@ -28,6 +28,7 @@ import org.thingsboard.server.common.data.oauth2.OAuth2CustomMapperConfig;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2Registration;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2User;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@ -35,6 +36,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@Service(value = "customOAuth2ClientMapper")
|
||||
@Slf4j
|
||||
@TbCoreComponent
|
||||
public class CustomOAuth2ClientMapper extends AbstractOAuth2ClientMapper implements OAuth2ClientMapper {
|
||||
private static final String PROVIDER_ACCESS_TOKEN = "provider-access-token";
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.oauth2.OAuth2MapperConfig;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2Registration;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2Configuration;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2User;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -36,6 +37,7 @@ import java.util.Optional;
|
||||
|
||||
@Service(value = "githubOAuth2ClientMapper")
|
||||
@Slf4j
|
||||
@TbCoreComponent
|
||||
public class GithubOAuth2ClientMapper extends AbstractOAuth2ClientMapper implements OAuth2ClientMapper {
|
||||
private static final String EMAIL_URL_KEY = "emailUrl";
|
||||
|
||||
|
||||
@ -20,9 +20,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.oauth2.MapperType;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@TbCoreComponent
|
||||
public class OAuth2ClientMapperProvider {
|
||||
|
||||
@Autowired
|
||||
|
||||
@ -25,6 +25,7 @@ import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.id.CustomerId;
|
||||
import org.thingsboard.server.common.data.id.EntityId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.system.SystemSecurityService;
|
||||
import org.thingsboard.server.utils.MiscUtils;
|
||||
|
||||
@ -35,6 +36,7 @@ import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@TbCoreComponent
|
||||
@Component(value = "oauth2AuthenticationFailureHandler")
|
||||
public class Oauth2AuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.oauth2.OAuth2Registration;
|
||||
import org.thingsboard.server.common.data.security.model.JwtToken;
|
||||
import org.thingsboard.server.dao.oauth2.OAuth2Service;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRepository;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
import org.thingsboard.server.service.security.model.token.JwtTokenFactory;
|
||||
@ -45,6 +46,7 @@ import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@Component(value = "oauth2AuthenticationSuccessHandler")
|
||||
@TbCoreComponent
|
||||
public class Oauth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
|
||||
|
||||
private final JwtTokenFactory tokenFactory;
|
||||
|
||||
@ -38,6 +38,7 @@ import org.thingsboard.server.common.data.security.Authority;
|
||||
import org.thingsboard.server.common.data.security.UserCredentials;
|
||||
import org.thingsboard.server.dao.customer.CustomerService;
|
||||
import org.thingsboard.server.dao.user.UserService;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.auth.MfaAuthenticationToken;
|
||||
import org.thingsboard.server.service.security.auth.mfa.TwoFactorAuthService;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
@ -49,6 +50,7 @@ import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@TbCoreComponent
|
||||
public class RestAuthenticationProvider implements AuthenticationProvider {
|
||||
|
||||
private final SystemSecurityService systemSecurityService;
|
||||
|
||||
@ -55,6 +55,7 @@ import org.thingsboard.server.dao.settings.AdminSettingsService;
|
||||
import org.thingsboard.server.dao.user.UserService;
|
||||
import org.thingsboard.server.dao.user.UserServiceImpl;
|
||||
import org.thingsboard.server.common.data.security.model.mfa.PlatformTwoFaSettings;
|
||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||
import org.thingsboard.server.service.security.auth.rest.RestAuthenticationDetails;
|
||||
import org.thingsboard.server.service.security.exception.UserPasswordExpiredException;
|
||||
import org.thingsboard.server.service.security.model.SecurityUser;
|
||||
@ -72,6 +73,7 @@ import static org.thingsboard.server.common.data.CacheConstants.SECURITY_SETTING
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@TbCoreComponent
|
||||
public class DefaultSystemSecurityService implements SystemSecurityService {
|
||||
|
||||
@Autowired
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.thingsboard.server.dao.audit;
|
||||
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.audit.ActionType;
|
||||
|
||||
@ -22,11 +24,14 @@ import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(prefix = "audit-log", value = "enabled", havingValue = "true")
|
||||
public class AuditLogLevelFilter {
|
||||
|
||||
private Map<EntityType, AuditLogLevelMask> entityTypeMask = new HashMap<>();
|
||||
|
||||
public AuditLogLevelFilter(Map<String, String> mask) {
|
||||
public AuditLogLevelFilter(AuditLogLevelProperties auditLogLevelProperties) {
|
||||
Map<String, String> mask = auditLogLevelProperties.getMask();
|
||||
entityTypeMask.clear();
|
||||
mask.forEach((entityTypeStr, logLevelMaskStr) -> {
|
||||
EntityType entityType = EntityType.valueOf(entityTypeStr.toUpperCase(Locale.ENGLISH));
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.config;
|
||||
package org.thingsboard.server.dao.audit;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -25,6 +25,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
|
||||
@ -49,6 +49,7 @@ import org.thingsboard.server.dao.alarm.AlarmService;
|
||||
import org.thingsboard.server.dao.asset.AssetService;
|
||||
import org.thingsboard.server.dao.audit.AuditLogLevelFilter;
|
||||
import org.thingsboard.server.dao.audit.AuditLogLevelMask;
|
||||
import org.thingsboard.server.dao.audit.AuditLogLevelProperties;
|
||||
import org.thingsboard.server.dao.component.ComponentDescriptorService;
|
||||
import org.thingsboard.server.dao.customer.CustomerService;
|
||||
import org.thingsboard.server.dao.dashboard.DashboardService;
|
||||
@ -218,7 +219,9 @@ public abstract class AbstractServiceTest {
|
||||
for (EntityType entityType : EntityType.values()) {
|
||||
mask.put(entityType.name().toLowerCase(), AuditLogLevelMask.RW.name());
|
||||
}
|
||||
return new AuditLogLevelFilter(mask);
|
||||
var props = new AuditLogLevelProperties();
|
||||
props.setMask(mask);
|
||||
return new AuditLogLevelFilter(props);
|
||||
}
|
||||
|
||||
protected DeviceProfile createDeviceProfile(TenantId tenantId, String name) {
|
||||
|
||||
1
docker/.gitignore
vendored
1
docker/.gitignore
vendored
@ -5,4 +5,5 @@ tb-node/db/**
|
||||
tb-node/postgres/**
|
||||
tb-node/cassandra/**
|
||||
tb-transports/*/log
|
||||
docker/tb-vc-executor/log/**
|
||||
!.env
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user