Secured NodeService, added role 'NODE_MANAGEMENT'

This commit is contained in:
Andrey Terentev 2024-03-25 11:48:44 +07:00 committed by Andrey Terentev
parent 91ae8d4cf1
commit 11ca677f65
2 changed files with 6 additions and 1 deletions

View File

@ -3,7 +3,9 @@ package ru.dragonestia.picker.model;
import org.springframework.security.core.GrantedAuthority;
public enum Permission implements GrantedAuthority {
ADMIN;
ADMIN, // account management
NODE_MANAGEMENT, // create and remove nodes
;
@Override
public String getAuthority() {

View File

@ -1,5 +1,6 @@
package ru.dragonestia.picker.service;
import org.springframework.security.access.prepost.PreAuthorize;
import ru.dragonestia.picker.api.exception.InvalidNodeIdentifierException;
import ru.dragonestia.picker.api.exception.NodeAlreadyExistException;
import ru.dragonestia.picker.api.model.node.NodeDetails;
@ -12,8 +13,10 @@ import java.util.Set;
public interface NodeService {
@PreAuthorize("hasRole('NODE_MANAGEMENT')")
void create(Node node) throws InvalidNodeIdentifierException, NodeAlreadyExistException;
@PreAuthorize("hasRole('NODE_MANAGEMENT')")
void remove(Node node);
List<Node> all();