Skip to content

Commit 4ed0502

Browse files
Fix #824 - Introduce a separated OIDC module to hold security dependencies (#872) (#874)
* Fix #824 - Introduce a separated OIDC module to hold security dependencies * Fix parent module --------- Signed-off-by: Ricardo Zanini <[email protected]> Co-authored-by: Ricardo Zanini <[email protected]>
1 parent 111db2a commit 4ed0502

File tree

21 files changed

+249
-230
lines changed

21 files changed

+249
-230
lines changed

client/deployment/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
<artifactId>quarkus-openapi-generator</artifactId>
3737
<version>${project.version}</version>
3838
</dependency>
39+
<dependency>
40+
<groupId>io.quarkiverse.openapi.generator</groupId>
41+
<artifactId>quarkus-openapi-generator-oidc</artifactId>
42+
<version>${project.version}</version>
43+
</dependency>
3944
<!-- Forces swagger-parser version to avoid conflict with Quarkus.
4045
This is needed while org.openapitools:openapi-generator doesn't use swagger-parser 2.1.13 or greater -->
4146
<dependency>

client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/GeneratorProcessor.java

Lines changed: 72 additions & 136 deletions
Large diffs are not rendered by default.

client/deployment/src/test/java/io/quarkiverse/openapi/generator/deployment/authentication/OpenApiSpecProviderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
import io.quarkiverse.openapi.generator.markers.ApiKeyAuthenticationMarker;
1818
import io.quarkiverse.openapi.generator.markers.BasicAuthenticationMarker;
1919
import io.quarkiverse.openapi.generator.markers.OauthAuthenticationMarker;
20+
import io.quarkiverse.openapi.generator.oidc.providers.OAuth2AuthenticationProvider;
2021
import io.quarkiverse.openapi.generator.providers.ApiKeyAuthenticationProvider;
2122
import io.quarkiverse.openapi.generator.providers.AuthProvider;
2223
import io.quarkiverse.openapi.generator.providers.BasicAuthenticationProvider;
2324
import io.quarkiverse.openapi.generator.providers.CompositeAuthenticationProvider;
24-
import io.quarkiverse.openapi.generator.providers.OAuth2AuthenticationProvider;
2525
import io.quarkus.test.QuarkusUnitTest;
2626

2727
public class OpenApiSpecProviderTest {

client/integration-tests/enum-unexpected/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<modelVersion>4.0.0</modelVersion>
99

1010
<artifactId>quarkus-openapi-generator-it-enum-unexpected</artifactId>
11-
<name>Quarkus - Openapi Generator - Integration Tests - Enum Unexpected</name>
11+
<name>Quarkus - Openapi Generator - Integration Tests - Client - Enum Unexpected</name>
1212
<description>Example project for OpenAPI with enum unexpected value</description>
1313

1414
<dependencies>

client/integration-tests/polymorphism/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<modelVersion>4.0.0</modelVersion>
99

1010
<artifactId>quarkus-openapi-generator-it-polymorphism</artifactId>
11-
<name>Quarkus - Openapi Generator - Integration Tests - Polymorphism</name>
11+
<name>Quarkus - Openapi Generator - Integration Tests - Client - Polymorphism</name>
1212

1313
<dependencies>
1414
<dependency>

client/integration-tests/pom.xml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
<artifactId>quarkus-openapi-generator-it-generation-input</artifactId>
5757
<version>${project.version}</version>
5858
</dependency>
59+
<dependency>
60+
<groupId>io.quarkiverse.openapi.generator</groupId>
61+
<artifactId>quarkus-openapi-generator-oidc</artifactId>
62+
<version>${project.version}</version>
63+
</dependency>
5964
</dependencies>
6065
</dependencyManagement>
6166
<profiles>
@@ -69,14 +74,6 @@
6974
<groupId>io.quarkus</groupId>
7075
<artifactId>quarkus-resteasy-client-jackson</artifactId>
7176
</dependency>
72-
<dependency>
73-
<groupId>io.quarkus</groupId>
74-
<artifactId>quarkus-resteasy-client-oidc-filter</artifactId>
75-
</dependency>
76-
<dependency>
77-
<groupId>io.quarkus</groupId>
78-
<artifactId>quarkus-resteasy-multipart</artifactId>
79-
</dependency>
8077
</dependencies>
8178
<build>
8279
<plugins>
@@ -104,10 +101,6 @@
104101
<groupId>io.quarkus</groupId>
105102
<artifactId>quarkus-rest-client-jackson</artifactId>
106103
</dependency>
107-
<dependency>
108-
<groupId>io.quarkus</groupId>
109-
<artifactId>quarkus-rest-client-oidc-filter</artifactId>
110-
</dependency>
111104
<dependency>
112105
<groupId>jakarta.validation</groupId>
113106
<artifactId>jakarta.validation-api</artifactId>

client/integration-tests/security/pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
<groupId>io.quarkiverse.openapi.generator</groupId>
1717
<artifactId>quarkus-openapi-generator</artifactId>
1818
</dependency>
19+
<dependency>
20+
<groupId>io.quarkiverse.openapi.generator</groupId>
21+
<artifactId>quarkus-openapi-generator-oidc</artifactId>
22+
</dependency>
1923
<dependency>
2024
<groupId>io.quarkus</groupId>
2125
<artifactId>quarkus-junit5</artifactId>
@@ -91,5 +95,30 @@
9195
<quarkus.package.type>native</quarkus.package.type>
9296
</properties>
9397
</profile>
98+
<profile>
99+
<id>resteasy-reactive</id>
100+
<dependencies>
101+
<dependency>
102+
<groupId>io.quarkus</groupId>
103+
<artifactId>quarkus-rest-client-oidc-filter</artifactId>
104+
</dependency>
105+
</dependencies>
106+
</profile>
107+
<profile>
108+
<id>resteasy-classic</id>
109+
<activation>
110+
<activeByDefault>true</activeByDefault>
111+
</activation>
112+
<dependencies>
113+
<dependency>
114+
<groupId>io.quarkus</groupId>
115+
<artifactId>quarkus-resteasy-client-oidc-filter</artifactId>
116+
</dependency>
117+
<dependency>
118+
<groupId>io.quarkus</groupId>
119+
<artifactId>quarkus-resteasy-multipart</artifactId>
120+
</dependency>
121+
</dependencies>
122+
</profile>
94123
</profiles>
95124
</project>

client/integration-tests/security/src/test/java/io/quarkiverse/openapi/generator/it/security/TokenPropagationExternalServicesMock.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
import jakarta.ws.rs.core.HttpHeaders;
1616

17+
import org.slf4j.Logger;
18+
import org.slf4j.LoggerFactory;
19+
1720
import com.github.tomakehurst.wiremock.WireMockServer;
1821

1922
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
@@ -25,18 +28,25 @@ public class TokenPropagationExternalServicesMock implements QuarkusTestResource
2528
public static final String SERVICE3_AUTHORIZATION_TOKEN = "SERVICE3_AUTHORIZATION_TOKEN";
2629
public static final String SERVICE4_HEADER_TO_PROPAGATE = "SERVICE4_HEADER_TO_PROPAGATE";
2730
public static final String SERVICE4_AUTHORIZATION_TOKEN = "SERVICE4_AUTHORIZATION_TOKEN";
28-
29-
private static final String BEARER = "Bearer ";
30-
3131
public static final String TOKEN_PROPAGATION_EXTERNAL_SERVICE_MOCK_URL = "propagation-external-service-mock.url";
32-
32+
private static final String BEARER = "Bearer ";
33+
private static final Logger LOGGER = LoggerFactory.getLogger(TokenPropagationExternalServicesMock.class);
3334
private WireMockServer wireMockServer;
3435

36+
private static void stubForExternalService(String tokenPropagationExternalServiceUrl, String authorizationToken) {
37+
stubFor(post(tokenPropagationExternalServiceUrl)
38+
.withHeader(HttpHeaders.AUTHORIZATION, equalTo(BEARER + authorizationToken))
39+
.willReturn(aResponse()
40+
.withHeader(CONTENT_TYPE, APPLICATION_JSON)
41+
.withBody("{}")));
42+
}
43+
3544
@Override
3645
public Map<String, String> start() {
3746
wireMockServer = new WireMockServer(options().dynamicPort());
3847
wireMockServer.start();
3948
configureFor(wireMockServer.port());
49+
LOGGER.info("Mocked Server started at {}", wireMockServer.baseUrl());
4050

4151
// stub the token-propagation-external-service1 invocation with the expected token
4252
stubForExternalService("/token-propagation-external-service1/executeQuery1", AUTHORIZATION_TOKEN);
@@ -58,14 +68,6 @@ public Map<String, String> start() {
5868
return Map.of(TOKEN_PROPAGATION_EXTERNAL_SERVICE_MOCK_URL, wireMockServer.baseUrl());
5969
}
6070

61-
private static void stubForExternalService(String tokenPropagationExternalServiceUrl, String authorizationToken) {
62-
stubFor(post(tokenPropagationExternalServiceUrl)
63-
.withHeader(HttpHeaders.AUTHORIZATION, equalTo(BEARER + authorizationToken))
64-
.willReturn(aResponse()
65-
.withHeader(CONTENT_TYPE, APPLICATION_JSON)
66-
.withBody("{}")));
67-
}
68-
6971
@Override
7072
public void stop() {
7173
if (wireMockServer != null) {

client/integration-tests/without-oidc/pom.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<parent>
4-
<artifactId>quarkus-openapi-generator-parent</artifactId>
4+
<artifactId>quarkus-openapi-generator-integration-tests</artifactId>
55
<groupId>io.quarkiverse.openapi.generator</groupId>
66
<version>3.0.0-SNAPSHOT</version>
7-
<relativePath>../../../pom.xml</relativePath>
87
</parent>
98
<modelVersion>4.0.0</modelVersion>
109

@@ -19,7 +18,7 @@
1918
</dependency>
2019
<dependency>
2120
<groupId>io.quarkus</groupId>
22-
<artifactId>quarkus-rest-client-jackson</artifactId>
21+
<artifactId>quarkus-hibernate-validator</artifactId>
2322
</dependency>
2423
<dependency>
2524
<groupId>org.assertj</groupId>
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
quarkus.rest-client.quarkus_simple_openapi_yaml.url=http://localhost:8080
2-
3-
quarkus.keycloak.devservices.enabled=false

0 commit comments

Comments
 (0)