spring-projects / spring-projects/spring-security
UniqueSecurityAnnotationScanner should consider annotation on target class level as fallback
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
public abstract class AbstractController {
@GetMapping("/get")
public String get() {
return "OK";
}
}
@RestController
@Secured("USER")
public class DemoController extends AbstractController {
/*
public String get() {
return super.get();
}
*/
}
demoController.get() is not protected by @Secured("USER"), we have to redefine it again.
I tried to fix it by adding
annotations = findClosestClassAnnotations(targetClass, new HashSet<>());
if (!annotations.isEmpty()) {
return annotations;
}
after
https://github.com/spring-projects/spring-security/blob/b9f3a28678af525e70cd5aa00abc816163cdb4fe/core/src/main/java/org/springframework/security/core/annotation/UniqueSecurityAnnotationScanner.java#L159-L162
but it broken GH-15352.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in core/src/main/java/org/springframework/security/core/annotation/UniqueSecurityAnnotationScanner.java around lines 159-162 and trace how annotations are resolved for the target class. Reproduce the AbstractController/DemoController case, then verify that class-level fallback protection works without regressing GH-15352.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authorization, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100