Skip to content

Commit

Permalink
Simply and clean
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Adam <[email protected]>
  • Loading branch information
PierreAdam committed Mar 7, 2024
1 parent 0d2ab46 commit 4ef9879
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.util.ClassPathUtils;
import io.quarkus.security.Authenticated;
import io.quarkus.security.PermissionsAllowed;
import io.quarkus.smallrye.openapi.OpenApiFilter;
import io.quarkus.smallrye.openapi.common.deployment.SmallRyeOpenApiConfig;
import io.quarkus.smallrye.openapi.deployment.filter.AutoRolesAllowedFilter;
Expand Down Expand Up @@ -635,12 +636,13 @@ private Map<String, List<String>> getRolesAllowedMethodReferences(OpenApiFiltere

private List<String> getPermissionsAllowedMethodReferences(
OpenApiFilteredIndexViewBuildItem indexViewBuildItem) {
return Stream.of(DotName.createSimple("io.quarkus.security.PermissionsAllowed"))
.map(e -> indexViewBuildItem.getIndex().getAnnotations(e))
.flatMap(Collection::stream)
return indexViewBuildItem.getIndex()
.getAnnotations(DotName.createSimple(PermissionsAllowed.class))
.stream()
.flatMap(SmallRyeOpenApiProcessor::getMethods)
.map(e -> JandexUtil.createUniqueMethodReference(e.getKey().declaringClass(), e.getKey()))
.collect(Collectors.toList());
.distinct()
.toList();
}

private List<String> getAuthenticatedMethodReferences(OpenApiFilteredIndexViewBuildItem indexViewBuildItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class AutoSecurityRolesAllowedTestCase {
@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClasses(ResourceBean.class, OpenApiResourceSecuredAtClassLevel.class, OpenApiResourceSecuredAtClassLevel2.class,
OpenApiResourceSecuredAtMethodLevel.class, OpenApiResourceSecuredAtMethodLevel2.class)
.addClasses(ResourceBean.class, OpenApiResourceSecuredAtClassLevel.class,
OpenApiResourceSecuredAtClassLevel2.class, OpenApiResourceSecuredAtMethodLevel.class,
OpenApiResourceSecuredAtMethodLevel2.class)
.addAsResource(
new StringAsset("quarkus.smallrye-openapi.security-scheme=jwt\n"
+ "quarkus.smallrye-openapi.security-scheme-name=JWTCompanyAuthentication\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package io.quarkus.smallrye.openapi.test.jaxrs;

import io.quarkus.security.PermissionsAllowed;
import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;
import org.eclipse.microprofile.openapi.annotations.security.SecurityRequirement;

import org.eclipse.microprofile.openapi.annotations.servers.Server;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;

import io.quarkus.security.PermissionsAllowed;

@Path("/resource3")
@Tag(name = "test")
@Server(url = "serverUrl")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.smallrye.openapi.test.jaxrs;

import io.quarkus.security.PermissionsAllowed;
import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
Expand All @@ -11,6 +10,8 @@
import org.eclipse.microprofile.openapi.annotations.servers.Server;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;

import io.quarkus.security.PermissionsAllowed;

@Path("/resource2")
@Tag(name = "test")
@Server(url = "serverUrl")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.smallrye.openapi.test.jaxrs;

import io.quarkus.security.PermissionsAllowed;
import jakarta.annotation.security.RolesAllowed;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
Expand Down

0 comments on commit 4ef9879

Please sign in to comment.