Ver Fonte

增加写权限验证

xiwa há 3 anos atrás
pai
commit
ec6532e7c5

+ 4 - 1
.DS_Store

@@ -54,7 +54,10 @@ public class KeycloakSecurityConfig extends KeycloakWebSecurityConfigurerAdapter
         http
         http
                 .authorizeRequests()
                 .authorizeRequests()
                 .antMatchers("/*.html", "/favicon.ico","/v2/api-docs", "/webjars/**", "/swagger-resources/**", "/*.js").permitAll()
                 .antMatchers("/*.html", "/favicon.ico","/v2/api-docs", "/webjars/**", "/swagger-resources/**", "/*.js").permitAll()
-                .antMatchers("/user/registerCheck", "/user/registerConfirm").permitAll()
+                .antMatchers("/**/save*").hasRole("iot_write")
+                .antMatchers("/**/del*").hasRole("iot_write")
+                .antMatchers("/**/add*").hasRole("iot_write")
+                .antMatchers("/**/clear*").hasRole("iot_write")
                 .antMatchers("/**").hasAnyRole(systemRole)
                 .antMatchers("/**").hasAnyRole(systemRole)
                 .antMatchers("/api/**").hasAnyRole("iot_client_user")
                 .antMatchers("/api/**").hasAnyRole("iot_client_user")
                 .and().csrf().disable();
                 .and().csrf().disable();

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

@@ -84,10 +84,11 @@ public class DeviceController {
 
 
     @GetMapping("/{deviceId}/children")
     @GetMapping("/{deviceId}/children")
     public List<DeviceInfo> getChildren(@PathVariable("deviceId") String deviceId) {
     public List<DeviceInfo> getChildren(@PathVariable("deviceId") String deviceId) {
-        return deviceRepository.findAll(Example.of(DeviceInfo.builder()
-                .parentId(deviceId)
-                .uid(AuthUtil.getUserId())
-                .build()));
+        return deviceRepository.findAll(Example.of(
+                dataOwnerService.wrapExample(
+                        DeviceInfo.builder()
+                                .parentId(deviceId)
+                                .build())));
     }
     }
 
 
     @GetMapping("/{deviceId}")
     @GetMapping("/{deviceId}")