-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve Sec. Identity in RESTEasy Reactive when Proactive Auth disabled
f ix #23547 for RESTEasy Reactive cases (e.g. the issue reproducer)
- Loading branch information
1 parent
2ef790c
commit 2415439
Showing
5 changed files
with
92 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
import io.smallrye.common.annotation.NonBlocking; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, [email protected] | ||
*/ | ||
|
@@ -24,4 +26,12 @@ public String admin() { | |
return "admin"; | ||
} | ||
|
||
@NonBlocking | ||
@Path("/admin/non-blocking") | ||
@RolesAllowed("admin") | ||
@GET | ||
public String adminNonBlocking() { | ||
return "admin"; | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...s/resteasy/reactive/server/test/security/SecurityChecksWithDisabledProactiveAuthTest.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,48 @@ | ||
package io.quarkus.resteasy.reactive.server.test.security; | ||
|
||
import org.hamcrest.Matchers; | ||
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 SecurityChecksWithDisabledProactiveAuthTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest app = new QuarkusUnitTest() | ||
.overrideConfigKey("quarkus.http.auth.proactive", "false") | ||
.withApplicationRoot((jar) -> jar.addClasses(RolesAllowedResource.class, TestIdentityProvider.class, | ||
TestIdentityController.class)); | ||
|
||
@BeforeAll | ||
public static void setupUsers() { | ||
TestIdentityController.resetRoles() | ||
.add("admin", "admin", "admin") | ||
.add("user", "user", "user"); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
// security identity in 'Quarkus - Security - Runtime' is resolved | ||
RestAssured | ||
.given() | ||
.auth().basic("admin", "admin") | ||
.get("/roles/admin/non-blocking") | ||
.then() | ||
.statusCode(200) | ||
.body(Matchers.is("admin")); | ||
|
||
// security check is applied | ||
RestAssured | ||
.given() | ||
.auth().basic("user", "user") | ||
.get("/roles/admin/non-blocking") | ||
.then() | ||
.statusCode(403); | ||
} | ||
|
||
} |
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
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
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