-
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.
Merge pull request #28505 from sberyozkin/silent_jwt_auth_mechanism
Support a silent mode for JWTAuthMechanism
- Loading branch information
Showing
5 changed files
with
78 additions
and
1 deletion.
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
32 changes: 32 additions & 0 deletions
32
extensions/smallrye-jwt/deployment/src/test/java/io/quarkus/jwt/test/SilentModeUnitTest.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,32 @@ | ||
package io.quarkus.jwt.test; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class SilentModeUnitTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClass(DefaultGroupsEndpoint.class) | ||
.addAsResource("publicKey.pem") | ||
.addAsResource("applicationJwtFormAuth.properties", "application.properties")); | ||
|
||
@Test | ||
public void testFormChallengeWithoutAuthorizationHeader() { | ||
RestAssured.given().redirects().follow(false) | ||
.get("/endp/echo") | ||
.then().assertThat().statusCode(302); | ||
} | ||
|
||
@Test | ||
public void testJwtChallengeWithAuthorizationHeader() { | ||
RestAssured.given().auth() | ||
.oauth2("123") | ||
.get("/endp/routingContext") | ||
.then().assertThat().statusCode(401); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
extensions/smallrye-jwt/deployment/src/test/resources/applicationJwtFormAuth.properties
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,13 @@ | ||
mp.jwt.verify.publickey.location=/publicKey.pem | ||
mp.jwt.verify.issuer=https://server.example.com | ||
quarkus.smallrye-jwt.enabled=true | ||
|
||
quarkus.smallrye-jwt.silent=true | ||
|
||
quarkus.http.auth.form.enabled=true | ||
quarkus.http.auth.form.login-page=login | ||
quarkus.http.auth.form.landing-page=landing | ||
quarkus.security.users.embedded.enabled=true | ||
quarkus.security.users.embedded.plain-text=true | ||
quarkus.security.users.embedded.users.alice=alice | ||
quarkus.security.users.embedded.roles.alice=admin |
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