forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Smallrye Config property expression expansion for @RolesAllowed values
closes: quarkusio#25245
- Loading branch information
1 parent
d573d17
commit 8badc44
Showing
16 changed files
with
639 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
44 changes: 44 additions & 0 deletions
44
...quarkus/resteasy/reactive/server/test/security/LazyAuthRolesAllowedConfigExpTestCase.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.resteasy.reactive.server.test.security; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.security.test.utils.TestIdentityController; | ||
import io.quarkus.security.test.utils.TestIdentityProvider; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class LazyAuthRolesAllowedConfigExpTestCase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(RolesAllowedResource.class, UserResource.class, | ||
TestIdentityProvider.class, | ||
TestIdentityController.class, | ||
SecurityOverrideFilter.class) | ||
.addAsResource(new StringAsset("quarkus.http.auth.proactive=false\n" + | ||
"admin-config-property=admin\n"), "application.properties")); | ||
|
||
@BeforeAll | ||
public static void setupUsers() { | ||
TestIdentityController.resetRoles() | ||
.add("admin", "admin", "admin") | ||
.add("user", "user", "user"); | ||
} | ||
|
||
@Test | ||
public void testRolesAllowedConfigExp() { | ||
RestAssured.given() | ||
.header("user", "admin") | ||
.header("role", "admin") | ||
.get("/roles/admin-config-exp") | ||
.then() | ||
.statusCode(200) | ||
.body(Matchers.equalTo("admin-config-exp")); | ||
} | ||
|
||
} |
This file contains 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
14 changes: 14 additions & 0 deletions
14
...main/java/io/quarkus/security/deployment/ConfigExpRolesAllowedSecurityCheckBuildItem.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.security.deployment; | ||
|
||
import io.quarkus.builder.item.SimpleBuildItem; | ||
import io.quarkus.security.runtime.interceptor.check.SupplierRolesAllowedCheck; | ||
|
||
/** | ||
* Marker build item that is used to indicate that there are {@link SupplierRolesAllowedCheck}s whose roles | ||
* contains config expressions that should be resolved at runtime. | ||
*/ | ||
public final class ConfigExpRolesAllowedSecurityCheckBuildItem extends SimpleBuildItem { | ||
|
||
ConfigExpRolesAllowedSecurityCheckBuildItem() { | ||
} | ||
} |
This file contains 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
Oops, something went wrong.