Skip to content

Repeating @PermissionsAllowed annotations totally disable method authentication #44185

@AlexanderUkhta

Description

@AlexanderUkhta

Describe the bug

Currently using the latest Quarkus 3.15.1.

I have my security annotations being used in the resource interface. While the method is annotated with a single @PermissionsAllowed annotation or is marked as @Authenticated - it all works fine. If the method is annotated with repeating @PermissionsAllowed, any auth or permission validation does not work (Got 200 OK on any request).

Please see my test resource with comments below:

@Path("/security_test")
interface TestResourceInterface {
    @GET
    @Path("/one")
    @PermissionsAllowed("zoneA:view")
    suspend fun one(): String     // works fine

    @GET
    @Path("/two")
    @PermissionsAllowed("zoneB:view", "zoneB:update")
    suspend fun two(): String      // works fine

    @GET
    @Path("/three")
    @PermissionsAllowed("zoneC:view")
    @PermissionsAllowed("zoneC:create")
    suspend fun three(): String      // does not work at all

    @GET
    @Path("/four")
    @Authenticated
    suspend fun four(): String       // works fine
}

If I put the @Authenticated additionally on the interface level - it all works fine. However, I can't use the @Authenticated annotation this way due to some limitations of my resource generator and because I still need to keep some api methods public.

Expected behavior

Repeating @PermissionsAllowed annotations on a method should work as multiple permissions, that all are needed to access the api method.

Actual behavior

Interface method, which is annotated with repeating @PermissionsAllowed and the interface is not marked with @Authenticated - always returns 200 OK.

How to Reproduce?

No response

Output of uname -a or ver

Darwin Kernel Version 21.6.0: Mon Jun 24 00:56:10 PDT 2024; root:xnu-8020.240.18.709.2~1/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "21.0.4" 2024-07-16 LTS OpenJDK Runtime Environment Corretto-21.0.4.7.1 (build 21.0.4+7-LTS) OpenJDK 64-Bit Server VM Corretto-21.0.4.7.1 (build 21.0.4+7-LTS, mixed mode, sharing)

Quarkus version or git rev

3.15.1

Build tool (ie. output of mvnw --version or gradlew --version)

------------------------------------------------------------ Gradle 8.6 ------------------------------------------------------------ Build time: 2024-02-02 16:47:16 UTC Revision: d55c486870a0dc6f6278f53d21381396d0741c6e Kotlin: 1.9.20 Groovy: 3.0.17 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 JVM: 18.0.2 (Amazon.com Inc. 18.0.2+9-FR) OS: Mac OS X 12.7.6 x86_64

Additional information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions