增加写权限验证

V0.5.x
xiwa 2022-03-07 16:30:33 +08:00
parent a2e0fecb39
commit ec6532e7c5
4 changed files with 9 additions and 5 deletions

0
.DS_Store vendored Normal file → Executable file
View File

0
device-server/mqtt-client-simulator/.DS_Store vendored Normal file → Executable file
View File

View File

@ -54,7 +54,10 @@ public class KeycloakSecurityConfig extends KeycloakWebSecurityConfigurerAdapter
http
.authorizeRequests()
.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("/api/**").hasAnyRole("iot_client_user")
.and().csrf().disable();

View File

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