You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
enh(aspectj): honor annotations on interfaces, superclasses and composed annotations - #2974
This enhancement lets the AspectJ aspect find Shiro annotations through the class hierarchy, as the other integrations do since #2917. Before, it only matched annotations written directly on the executed method or its class, so annotations on interface methods, overridden superclass methods and composed annotations were not picked up.
The aspect now matches every application method and lets AnnotationHierarchy decide, with the result cached per method and class. Shiro's own classes are excluded.
Added tests for each annotation placement. DummyServiceTest no longer sets a global SecurityManager, so the tests can run in parallel.
Following this checklist to help us incorporate your contribution quickly and easily:
Make sure there is a GitHub issue filed
for the change (usually before you start working on it). Trivial changes like typos do not
require a GitHub issue. Your pull request should address just this issue, without pulling in other changes.
Format the pull request title like [#XXX] - Fixes bug in SessionManager,
where you replace #XXX with the appropriate GitHub issue. Best practice
is to use the GitHub issue title in the pull request title and in the first line of the commit message.
Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
add fixes #XXX if merging the PR should close a related issue.
Run mvn verify to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
Committers: Make sure a milestone is set on the PR
Committers: Use "Squash and Merge" to combine all commits into one when merging a PR when appropriate.
Trivial changes like typos do not require a GitHub issue (javadoc, comments...).
In this case, just format the pull request title like [DOC] - Add javadoc in SessionManager.
If your pull request is about ~20 lines of code you don't need to sign an Individual Contributor License Agreement
if you are unsure please ask on the developers list.
To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
lprimak
changed the title
bugfix(aspectj): honor annotations on interfaces, superclasses and composed annotations
enh(aspectj): honor annotations on interfaces, superclasses and composed annotations
Nov 25, 2026
I tested the reported AspectJ hierarchy scenarios against this branch (lprimak:aspectj-interface-methods, commit 44b3995).
Before this PR, using shiro-aspectj 3.0.2 with compile-time weaving:
interface method annotated @RequiresRoles("admin"), implementation not re-annotated -> method executed with no authorization check (returned the protected value);
implementation method directly annotated @RequiresRoles("admin") -> correctly threw UnauthorizedException (control, proving weaving works).
With this PR's changes (broad execution(* (..)) && !within(org.apache.shiro..) pointcut + AnnotationHierarchy.findAnnotation() gate), the interface-annotated case is now correctly intercepted and throws UnauthorizedException. The new HierarchyAspectTest also covers interface methods, overridden superclass methods, subclass methods of annotated bases, composed annotations, and static methods of annotated types.
I can confirm this PR fixes the AspectJ gap. From my side the change is correct and ready to merge.
Note: I do not consider JSR-250 support part of this fix; as noted in the security-model discussion, @RolesAllowed/@PermitAll/@Denyall have never been supported by this aspect, so that is a separate feature request.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This enhancement lets the AspectJ aspect find Shiro annotations through the class hierarchy, as the other integrations do since #2917. Before, it only matched annotations written directly on the executed method or its class, so annotations on interface methods, overridden superclass methods and composed annotations were not picked up.
AnnotationHierarchydecide, with the result cached per method and class. Shiro's own classes are excluded.DummyServiceTestno longer sets a globalSecurityManager, so the tests can run in parallel.Following this checklist to help us incorporate your contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a GitHub issue. Your pull request should address just this issue, without pulling in other changes.
[#XXX] - Fixes bug in SessionManager,where you replace
#XXXwith the appropriate GitHub issue. Best practiceis to use the GitHub issue title in the pull request title and in the first line of the commit message.
fixes #XXXif merging the PR should close a related issue.mvn verifyto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.Trivial changes like typos do not require a GitHub issue (javadoc, comments...).
In this case, just format the pull request title like
[DOC] - Add javadoc in SessionManager.If this is your first contribution, you have to read the Contribution Guidelines
If your pull request is about ~20 lines of code you don't need to sign an Individual Contributor License Agreement
if you are unsure please ask on the developers list.
To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.