-
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.
OpenAPI: Always run OpenIDConnectSecurityFilter at runtime
Signed-off-by: Michael Edgar <[email protected]>
- Loading branch information
Showing
9 changed files
with
228 additions
and
199 deletions.
There are no files selected for viewing
300 changes: 141 additions & 159 deletions
300
...oyment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java
Large diffs are not rendered by default.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
...ent/src/test/java/io/quarkus/smallrye/openapi/test/jaxrs/OIDCSecurityAutoAddTestTest.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,31 @@ | ||
package io.quarkus.smallrye.openapi.test.jaxrs; | ||
|
||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.builder.Version; | ||
import io.quarkus.maven.dependency.Dependency; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
class OIDCSecurityAutoAddTestTest extends OIDCSecurityTestBase { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(OpenApiResource.class, ResourceBean.class) | ||
.addAsResource( | ||
new StringAsset("" | ||
+ "quarkus.smallrye-openapi.security-scheme-name=OIDCCompanyAuthentication\n" | ||
+ "quarkus.smallrye-openapi.security-scheme-description=OIDC Authentication\n" | ||
+ "quarkus.smallrye-openapi.oidc-open-id-connect-url=BUILD-TIME-OVERRIDDEN\n" | ||
+ "quarkus.http.auth.permission.\"oidc\".policy=authenticated\n" | ||
+ "quarkus.http.auth.permission.\"oidc\".paths=/resource/*\n" | ||
+ "quarkus.oidc.auth-server-url=BUILD-TIME-OVERRIDDEN\n" | ||
+ "quarkus.devservices.enabled=false"), | ||
"application.properties")) | ||
.setForcedDependencies(List.of( | ||
Dependency.of("io.quarkus", "quarkus-oidc", Version.getVersion()))) | ||
.overrideRuntimeConfigKey("quarkus.oidc.auth-server-url", "http://localhost:8081/auth/realms/OpenAPIOIDC"); | ||
} |
24 changes: 24 additions & 0 deletions
24
...deployment/src/test/java/io/quarkus/smallrye/openapi/test/jaxrs/OIDCSecurityTestBase.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.smallrye.openapi.test.jaxrs; | ||
|
||
import static org.hamcrest.Matchers.allOf; | ||
import static org.hamcrest.Matchers.hasEntry; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.restassured.RestAssured; | ||
|
||
abstract class OIDCSecurityTestBase { | ||
|
||
@Test | ||
void testOIDCAuthentication() { | ||
RestAssured.given().header("Accept", "application/json") | ||
.when().get("/q/openapi") | ||
.then().body("components.securitySchemes.OIDCCompanyAuthentication", | ||
allOf( | ||
hasEntry("type", "openIdConnect"), | ||
hasEntry("description", "OIDC Authentication"), | ||
hasEntry("openIdConnectUrl", | ||
"http://localhost:8081/auth/realms/OpenAPIOIDC/.well-known/openid-configuration"))); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,9 @@ | |
*/ | ||
int priority() default 1; | ||
|
||
static enum RunStage { | ||
enum RunStage { | ||
BUILD, | ||
RUN, | ||
BOTH | ||
} | ||
} | ||
} |
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
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