Secured AccountService

This commit is contained in:
Andrey Terentev 2024-03-25 11:45:53 +07:00 committed by Andrey Terentev
parent 103607bbbc
commit 91ae8d4cf1

View File

@ -1,6 +1,7 @@
package ru.dragonestia.picker.service; package ru.dragonestia.picker.service;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import ru.dragonestia.picker.model.Account; import ru.dragonestia.picker.model.Account;
@ -8,9 +9,12 @@ import java.util.Collection;
public interface AccountService extends UserDetailsService { public interface AccountService extends UserDetailsService {
@PreAuthorize("hasRole('ADMIN')")
@NotNull Account createNewAccount(@NotNull String username, @NotNull String password); @NotNull Account createNewAccount(@NotNull String username, @NotNull String password);
@PreAuthorize("hasRole('ADMIN')")
@NotNull Collection<Account> allAccounts(); @NotNull Collection<Account> allAccounts();
@PreAuthorize("hasRole('ADMIN')")
void removeAccount(@NotNull Account account); void removeAccount(@NotNull Account account);
} }