Merge branch 'feature/vc-progress' of github.com:thingsboard/thingsboard into feature/vc-progress
This commit is contained in:
		
						commit
						0cfaf3c6ef
					
				@ -15,9 +15,11 @@
 | 
			
		||||
 */
 | 
			
		||||
package org.thingsboard.server.config;
 | 
			
		||||
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.context.annotation.Lazy;
 | 
			
		||||
import org.springframework.security.authentication.BadCredentialsException;
 | 
			
		||||
import org.springframework.security.core.Authentication;
 | 
			
		||||
import org.springframework.security.core.context.SecurityContextHolder;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
@ -41,6 +43,7 @@ import java.util.Map;
 | 
			
		||||
import java.util.concurrent.ConcurrentHashMap;
 | 
			
		||||
import java.util.concurrent.ConcurrentMap;
 | 
			
		||||
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Component
 | 
			
		||||
public class RateLimitProcessingFilter extends GenericFilterBean {
 | 
			
		||||
 | 
			
		||||
@ -58,7 +61,13 @@ public class RateLimitProcessingFilter extends GenericFilterBean {
 | 
			
		||||
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
 | 
			
		||||
        SecurityUser user = getCurrentUser();
 | 
			
		||||
        if (user != null && !user.isSystemAdmin()) {
 | 
			
		||||
            var profileConfiguration = tenantProfileCache.get(user.getTenantId()).getDefaultProfileConfiguration();
 | 
			
		||||
            var profile = tenantProfileCache.get(user.getTenantId());
 | 
			
		||||
            if (profile == null) {
 | 
			
		||||
                log.debug("[{}] Failed to lookup tenant profile", user.getTenantId());
 | 
			
		||||
                errorResponseHandler.handle(new BadCredentialsException("Failed to lookup tenant profile"), (HttpServletResponse) response);
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            var profileConfiguration = profile.getDefaultProfileConfiguration();
 | 
			
		||||
            if (!checkRateLimits(user.getTenantId(), profileConfiguration.getTenantServerRestLimitsConfiguration(), perTenantLimits, response)) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@ -226,11 +226,7 @@ public class AlarmController extends BaseController {
 | 
			
		||||
        TimePageLink pageLink = createTimePageLink(pageSize, page, textSearch, sortProperty, sortOrder, startTime, endTime);
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            if (getCurrentUser().isCustomerUser()) {
 | 
			
		||||
                return checkNotNull(alarmService.findCustomerAlarms(getCurrentUser().getTenantId(), getCurrentUser().getCustomerId(), new AlarmQuery(entityId, pageLink, alarmSearchStatus, alarmStatus, fetchOriginator)).get());
 | 
			
		||||
            } else {
 | 
			
		||||
                return checkNotNull(alarmService.findAlarms(getCurrentUser().getTenantId(), new AlarmQuery(entityId, pageLink, alarmSearchStatus, alarmStatus, fetchOriginator)).get());
 | 
			
		||||
            }
 | 
			
		||||
            return checkNotNull(alarmService.findAlarms(getCurrentUser().getTenantId(), new AlarmQuery(entityId, pageLink, alarmSearchStatus, alarmStatus, fetchOriginator)).get());
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw handleException(e);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -63,7 +63,7 @@ public class SmsTwoFaProvider extends OtpBasedTwoFaProvider<SmsTwoFaProviderConf
 | 
			
		||||
    @Override
 | 
			
		||||
    public void check(TenantId tenantId) throws ThingsboardException {
 | 
			
		||||
        if (!smsService.isConfigured(tenantId)) {
 | 
			
		||||
            throw new ThingsboardException("SMS service in not configured", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
 | 
			
		||||
            throw new ThingsboardException("SMS service is not configured", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -559,6 +559,9 @@ public class ExportImportServiceSqlTest extends BaseExportImportServiceTest {
 | 
			
		||||
        assertThat(exportedDashboard.getAssignedCustomers()).hasOnlyOneElementSatisfying(shortCustomerInfo -> {
 | 
			
		||||
            assertThat(shortCustomerInfo.getCustomerId()).isEqualTo(customer.getId());
 | 
			
		||||
        });
 | 
			
		||||
        String exportedEntityAliasAssetId = exportedDashboard.getConfiguration().get("entityAliases").elements().next()
 | 
			
		||||
                .get("filter").get("entityList").elements().next().asText();
 | 
			
		||||
        assertThat(exportedEntityAliasAssetId).isEqualTo(asset.getId().toString());
 | 
			
		||||
 | 
			
		||||
        DeviceProfile exportedDeviceProfile = (DeviceProfile) exportEntity(tenantAdmin2, (DeviceProfileId) ids.get(deviceProfile.getId())).getEntity();
 | 
			
		||||
        assertThat(exportedDeviceProfile.getDefaultRuleChainId()).isEqualTo(ruleChain.getId());
 | 
			
		||||
@ -571,6 +574,12 @@ public class ExportImportServiceSqlTest extends BaseExportImportServiceTest {
 | 
			
		||||
        EntityView exportedEntityView = (EntityView) exportEntity(tenantAdmin2, (EntityViewId) ids.get(entityView.getId())).getEntity();
 | 
			
		||||
        assertThat(exportedEntityView.getCustomerId()).isEqualTo(customer.getId());
 | 
			
		||||
        assertThat(exportedEntityView.getEntityId()).isEqualTo(device.getId());
 | 
			
		||||
 | 
			
		||||
        deviceProfile.setDefaultDashboardId(null);
 | 
			
		||||
        deviceProfileService.saveDeviceProfile(deviceProfile);
 | 
			
		||||
        DeviceProfile importedDeviceProfile = deviceProfileService.findDeviceProfileById(tenantId2, (DeviceProfileId) ids.get(deviceProfile.getId()));
 | 
			
		||||
        importedDeviceProfile.setDefaultDashboardId(null);
 | 
			
		||||
        deviceProfileService.saveDeviceProfile(importedDeviceProfile);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user