Skip to content

Figure out a consistent strategy for inheritance of security annotations #51406

@FroMage

Description

@FroMage

Description

In https://github.com/quarkusio/quarkus/pull/50987/files#r2524146520 we raised the issue that CDI says that interceptors are not applied to super-type methods (at least that's how I understood it).

To put the topic in a simple example, this is about cases like:

public interface NotSecured {
 public void abstractMethod();
 public default void defaultMethod() {}
}

@Authenticated
public interface Secured extends NotSecured {
}

This applies to JAX-RS methods (for methods with implementations) but also Jakarta Data repositories where abstract methods are auto-implemented by Hibernate, or REST with Panache, and other parts of Quarkus where extensions give you default classes which you can then secure via subclasses.

The intuitive thing for users is that once you add a security annotation on a class, you secure every single one of its methods, even the inherited ones. Otherwise you must re-define overrides that do nothing, or delegate up, and make sure you never miss one.

@michalvavrik mentionned this being discussed in the past in at least:

And said:

having class-level annotations inherited on parent/subclasses goes against how I personally read https://jakarta.ee/specifications/annotations/3.0/annotations-spec-3.0#general-guidelines-for-inheritance-of-annotations for example:

Class-level annotations only affect the class they annotate and its members, that is, its methods and fields. They never affect a member declared by a superclass, even if it is not hidden or overridden by the class in question.

We should have a discussion about this, see if this only applies to security annotations or other annotations too, and decide if we need to change our current implementation and behaviour for better consistency.

CC @michalvavrik @mkouba @gavinking @yrodiere @geoand

Implementation ideas

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions