forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
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 quarkusio#13573 from stuartwdouglas/13559
Fix potential hang if exception is thrown from authenticator
- Loading branch information
Showing
4 changed files
with
88 additions
and
9 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
47 changes: 47 additions & 0 deletions
47
...ployment/src/test/java/io/quarkus/vertx/http/security/FailedIdentityProviderTestCase.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,47 @@ | ||
package io.quarkus.vertx.http.security; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class FailedIdentityProviderTestCase { | ||
|
||
private static final String APP_PROPS = "" + | ||
"quarkus.http.auth.basic=true\n" + | ||
"quarkus.http.auth.policy.r1.roles-allowed=admin\n" + | ||
"quarkus.http.auth.permission.roles1.paths=/admin\n" + | ||
"quarkus.http.auth.permission.roles1.policy=r1\n"; | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest().setArchiveProducer(new Supplier<JavaArchive>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(FailingIdentityProvider.class, | ||
PathHandler.class) | ||
.addAsResource(new StringAsset(APP_PROPS), "application.properties"); | ||
} | ||
}); | ||
|
||
@Test | ||
public void testBasicBasedAuthSuccess() { | ||
RestAssured | ||
.given() | ||
.auth().preemptive().basic("admin", "admin") | ||
.redirects().follow(false) | ||
.when() | ||
.get("/admin") | ||
.then() | ||
.assertThat() | ||
.statusCode(401); | ||
|
||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...http/deployment/src/test/java/io/quarkus/vertx/http/security/FailingIdentityProvider.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,24 @@ | ||
package io.quarkus.vertx.http.security; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import io.quarkus.security.AuthenticationFailedException; | ||
import io.quarkus.security.identity.AuthenticationRequestContext; | ||
import io.quarkus.security.identity.IdentityProvider; | ||
import io.quarkus.security.identity.SecurityIdentity; | ||
import io.quarkus.security.identity.request.UsernamePasswordAuthenticationRequest; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@Singleton | ||
public class FailingIdentityProvider implements IdentityProvider<UsernamePasswordAuthenticationRequest> { | ||
@Override | ||
public Class<UsernamePasswordAuthenticationRequest> getRequestType() { | ||
return UsernamePasswordAuthenticationRequest.class; | ||
} | ||
|
||
@Override | ||
public Uni<SecurityIdentity> authenticate(UsernamePasswordAuthenticationRequest request, | ||
AuthenticationRequestContext context) { | ||
throw new AuthenticationFailedException("FAILED"); | ||
} | ||
} |
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