Browse Source

权限问题修复

xiwa 3 years ago
parent
commit
aa7be02b37

+ 5 - 5
manager/src/main/java/cc/iotkit/manager/config/KeycloakSecurityConfig.java

@@ -56,11 +56,11 @@ public class KeycloakSecurityConfig extends KeycloakWebSecurityConfigurerAdapter
                 .antMatchers("/*.html", "/favicon.ico","/v2/api-docs", "/webjars/**", "/swagger-resources/**", "/*.js").permitAll()
                 .antMatchers("/api/**").hasRole("iot_client_user")
                 .antMatchers("/aligenieDevice/invoke/**").hasRole("iot_client_user")
-                .antMatchers("/**/save*").hasRole("iot_write")
-                .antMatchers("/**/del*").hasRole("iot_write")
-                .antMatchers("/**/add*").hasRole("iot_write")
-                .antMatchers("/**/clear*").hasRole("iot_write")
-                .antMatchers("/**/set*").hasRole("iot_write")
+                .antMatchers("/**/save*/**").hasRole("iot_write")
+                .antMatchers("/**/del*/**").hasRole("iot_write")
+                .antMatchers("/**/add*/**").hasRole("iot_write")
+                .antMatchers("/**/clear*/**").hasRole("iot_write")
+                .antMatchers("/**/set*/**").hasRole("iot_write")
                 .antMatchers("/**").hasAnyRole(systemRole)
                 .and().csrf().disable();
     }

+ 1 - 1
manager/src/main/java/cc/iotkit/manager/controller/DeviceController.java

@@ -136,7 +136,7 @@ public class DeviceController {
                         .build())).orElse(new DeviceInfo()));
     }
 
-    @DeleteMapping("/{deviceId}")
+    @PostMapping("/{deviceId}/delete")
     public void deleteDevice(@PathVariable("deviceId") String deviceId) {
         deviceId = getDetail(deviceId).getDeviceId();
         deviceRepository.deleteById(deviceId);

+ 1 - 1
manager/src/main/java/cc/iotkit/manager/controller/ProductController.java

@@ -75,7 +75,7 @@ public class ProductController {
         thingModelRepository.save(new ThingModel(productKey, productKey, JsonUtil.parse(model, ThingModel.Model.class)));
     }
 
-    @DeleteMapping("/thingModel/{productKey}")
+    @PostMapping("/thingModel/{productKey}/delete")
     public void deleteThingModel(String productKey) {
         productKey = getProduct(productKey).getId();
         thingModelRepository.deleteById(productKey);

+ 1 - 2
manager/src/main/java/cc/iotkit/manager/controller/ProtocolController.java

@@ -137,7 +137,7 @@ public class ProtocolController {
     public void saveComponentScript(
             @PathVariable("id") String id,
             @RequestBody String script) {
-        ProtocolComponent oldComponent = getAndCheckComponent(id);
+        getAndCheckComponent(id);
         try {
             Path path = componentConfig.getComponentFilePath(id);
             File file = path.resolve(ProtocolComponent.SCRIPT_FILE_NAME).toFile();
@@ -145,7 +145,6 @@ public class ProtocolController {
             FileUtils.writeStringToFile(file, script, "UTF-8", false);
 
             componentManager.deRegister(id);
-            protocolComponentRepository.save(oldComponent);
         } catch (Throwable e) {
             throw new BizException("save protocol component script error", e);
         }

+ 0 - 0
model/src/main/java/cc/iotkit/model/alert/AlertConfig.java