Skip to content

Resolve generic overrides exactly in SecureAnnotationsInterceptor - #3679

Merged
coheigea merged 1 commit into
mainfrom
coheigea/SecureAnnotationsInterceptor-generic
Nov 4, 2026
Merged

coheigea merged 1 commit into
mainfrom
coheigea/SecureAnnotationsInterceptor-generic

Conversation

@coheigea

@coheigea coheigea commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

When no rule applied to a method's signature, every role annotation
recorded for its name applied. A method implementing a generic
interface method, whose erased signature differs, therefore needed the
roles of every method with the same name, an unannotated overload
needed the roles of its annotated overloads, and an implementation's
class-level @RolesAllowed, which applies to its own signature, hid the
method-level @RolesAllowed of the generic interface method.

As in OAuthScopesFilter and ClaimsAuthorizingInterceptor, the generic
parameter types of the superclass and interface methods are now
resolved against the class's type arguments
(ReflectionUtil.getGenericallyOverriddenMethods), so a method also gets
the rules of exactly the generic methods it overrides, and the
name-based fallback is only used for methods which are not part of the
secured object.

@ffang

ffang commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Thanks @coheigea, LGTM. Matching a method only to the generic methods it actually overrides, as OAuthScopesFilter and ClaimsAuthorizingInterceptor already do, fixes a real gap: an implementation's class-level @RolesAllowed no longer hides the method-level @RolesAllowed of the generic interface method. Core tests pass with -Psourcecheck, and all six new tests fail against the current interceptor.

Just one Nit: getGenericallyOverriddenMethods rebuilds the type-argument map of the whole class hierarchy for every method, and findRoles calls it for every class in the hierarchy. It only runs at setup, so it doesn't matter much, though the map could be computed once per class.

@coheigea
coheigea merged commit 5948451 into main Nov 4, 2026
5 checks passed
@coheigea
coheigea deleted the coheigea/SecureAnnotationsInterceptor-generic branch November 4, 2026 15:26
coheigea added a commit that referenced this pull request Nov 4, 2026
coheigea added a commit that referenced this pull request Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants