- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 551
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
I'm using spring-data-rest to export rest endpoints for a repository. This works great but the @securityrequirement annotation does only work on the class level. I would like to give each method a different security requirement.
Example:
@RepositoryRestResource(excerptProjection = UserBasicProjection.class)
public interface UserRepository extends JpaRepository<User, Long> {
    @Override
    @IsAuthenticated
    Optional<User> findById(Long id);
    @IsAuthenticated
    Optional<User> findOneByEmailAndDeletedIsFalse(String email);
    @Override
    @IsAdmin
    Page<User> findAll(Pageable pageable);
    @IsAdmin
    List<User> findByDebtIsGreaterThan(double debt);
 
    ....
}@IsAdmin infers @SecurityRequirement(name = OAUTH2_SECURITY_SCHEME, scopes = "api_admin")
@IsAuthenticated infers @SecurityRequirement(name = OAUTH2_SECURITY_SCHEME, scopes = "api_full")
Describe the solution you'd like
The DataRestTagsService should check the actual repository method in addition to the repository type.
Line 113 in 4a25acf
| Set<io.swagger.v3.oas.annotations.security.SecurityRequirement> allSecurityTags = securityParser.getSecurityRequirementsForClass(repositoryType); | 
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request