权限问题修复

V0.5.x
xiwa 2022-04-21 09:04:07 +08:00
parent 35bdd1b7fc
commit aa7be02b37
13 changed files with 8 additions and 9 deletions

View File

@ -56,11 +56,11 @@ public class KeycloakSecurityConfig extends KeycloakWebSecurityConfigurerAdapter
.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("/api/**").hasRole("iot_client_user") .antMatchers("/api/**").hasRole("iot_client_user")
.antMatchers("/aligenieDevice/invoke/**").hasRole("iot_client_user") .antMatchers("/aligenieDevice/invoke/**").hasRole("iot_client_user")
.antMatchers("/**/save*").hasRole("iot_write") .antMatchers("/**/save*/**").hasRole("iot_write")
.antMatchers("/**/del*").hasRole("iot_write") .antMatchers("/**/del*/**").hasRole("iot_write")
.antMatchers("/**/add*").hasRole("iot_write") .antMatchers("/**/add*/**").hasRole("iot_write")
.antMatchers("/**/clear*").hasRole("iot_write") .antMatchers("/**/clear*/**").hasRole("iot_write")
.antMatchers("/**/set*").hasRole("iot_write") .antMatchers("/**/set*/**").hasRole("iot_write")
.antMatchers("/**").hasAnyRole(systemRole) .antMatchers("/**").hasAnyRole(systemRole)
.and().csrf().disable(); .and().csrf().disable();
} }

View File

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

View File

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

View File

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

View File

View File

View File

View File

View File

View File