|
|
|
@ -76,6 +76,7 @@ public class ApiKeyController extends BaseController { |
|
|
|
SecurityUser securityUser = getCurrentUser(); |
|
|
|
apiKeyInfo.setTenantId(securityUser.getTenantId()); |
|
|
|
checkEntity(apiKeyInfo.getId(), apiKeyInfo, Resource.API_KEY); |
|
|
|
checkUserId(apiKeyInfo.getUserId(), Operation.WRITE); |
|
|
|
return checkNotNull(apiKeyService.saveApiKey(securityUser.getTenantId(), apiKeyInfo)); |
|
|
|
} |
|
|
|
|
|
|
|
@ -101,6 +102,7 @@ public class ApiKeyController extends BaseController { |
|
|
|
PageLink pageLink = createPageLink(pageSize, page, textSearch, sortProperty, sortOrder); |
|
|
|
UserId userId = new UserId(toUUID(userIdStr)); |
|
|
|
accessControlService.checkPermission(securityUser, Resource.API_KEY, Operation.READ); |
|
|
|
checkUserId(userId, Operation.READ); |
|
|
|
return apiKeyService.findApiKeysByUserId(securityUser.getTenantId(), userId, pageLink); |
|
|
|
} |
|
|
|
|
|
|
|
@ -117,6 +119,7 @@ public class ApiKeyController extends BaseController { |
|
|
|
@RequestBody Optional<String> description) throws Exception { |
|
|
|
ApiKeyId apiKeyId = new ApiKeyId(id); |
|
|
|
ApiKey apiKey = checkApiKeyId(apiKeyId, Operation.WRITE); |
|
|
|
checkUserId(apiKey.getUserId(), Operation.WRITE); |
|
|
|
apiKey.setDescription(description.orElse(null)); |
|
|
|
return apiKeyService.saveApiKey(apiKey.getTenantId(), apiKey); |
|
|
|
} |
|
|
|
@ -132,6 +135,7 @@ public class ApiKeyController extends BaseController { |
|
|
|
@PathVariable(value = "enabledValue") Boolean enabledValue) throws ThingsboardException { |
|
|
|
ApiKeyId apiKeyId = new ApiKeyId(id); |
|
|
|
ApiKey apiKey = checkApiKeyId(apiKeyId, Operation.WRITE); |
|
|
|
checkUserId(apiKey.getUserId(), Operation.WRITE); |
|
|
|
apiKey.setEnabled(enabledValue); |
|
|
|
return apiKeyService.saveApiKey(apiKey.getTenantId(), apiKey); |
|
|
|
} |
|
|
|
@ -143,6 +147,7 @@ public class ApiKeyController extends BaseController { |
|
|
|
public void deleteApiKey(@PathVariable UUID id) throws ThingsboardException { |
|
|
|
ApiKeyId apiKeyId = new ApiKeyId(id); |
|
|
|
ApiKey apiKey = checkApiKeyId(apiKeyId, Operation.DELETE); |
|
|
|
checkUserId(apiKey.getUserId(), Operation.WRITE); |
|
|
|
apiKeyService.deleteApiKey(apiKey.getTenantId(), apiKey, false); |
|
|
|
} |
|
|
|
|
|
|
|
|