Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,10 @@ void produceCompositeProviders(AuthenticationRecorder recorder, List<AuthProvide
@BuildStep
@Record(ExecutionTime.STATIC_INIT)
void produceOauthAuthentication(CombinedIndexBuildItem beanArchiveBuildItem,
BuildProducer<AuthProviderBuildItem> authenticationProviders, BuildProducer<SyntheticBeanBuildItem> beanProducer,
BuildProducer<AuthProviderBuildItem> authenticationProviders,
BuildProducer<SyntheticBeanBuildItem> beanProducer,
OidcAuthenticationRecorder oidcRecorder) {

if (!isClassPresentAtRuntime(ABSTRACT_TOKEN_PRODUCER)) {
LOGGER.debug("{} class not found in runtime, skipping OAuth bean generation", ABSTRACT_TOKEN_PRODUCER);
return;
}
LOGGER.debug("{} class found in runtime, producing OAuth bean generation", ABSTRACT_TOKEN_PRODUCER);
Collection<AnnotationInstance> authenticationMarkers = beanArchiveBuildItem.getIndex()
.getAnnotationsWithRepeatable(OAUTH_AUTHENTICATION_MARKER, beanArchiveBuildItem.getIndex())
.stream()
Expand All @@ -145,6 +141,24 @@ void produceOauthAuthentication(CombinedIndexBuildItem beanArchiveBuildItem,
(existing, duplicate) -> existing))
.values();

if (!isClassPresentAtRuntime(ABSTRACT_TOKEN_PRODUCER)) {
if (!authenticationMarkers.isEmpty()) {
throw new IllegalStateException(
"OAuth2 flows detected in spec(s) " +
authenticationMarkers.stream()
.map(m -> m.value("openApiSpecId").asString())
.distinct()
.collect(Collectors.joining(", "))
+
" but quarkus-openapi-generator-oidc and quarkus-rest-client-oidc-filter or quarkus-oidc-client-reactive-filter are not on the classpath. "
+
"Please add those dependencies to your project. See https://docs.quarkiverse.io/quarkus-openapi-generator/dev/client.html#_oauth2_authentication");
}
LOGGER.debug("{} class not found in runtime, skipping OAuth bean generation", ABSTRACT_TOKEN_PRODUCER);
return;
}
LOGGER.debug("{} class found in runtime, producing OAuth bean generation", ABSTRACT_TOKEN_PRODUCER);

Map<String, List<AnnotationInstance>> operationsBySpec = getOperationsBySpec(beanArchiveBuildItem);

for (AnnotationInstance authenticationMarker : authenticationMarkers) {
Expand Down
25 changes: 25 additions & 0 deletions client/integration-tests/generation-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
<groupId>io.quarkiverse.openapi.generator</groupId>
<artifactId>quarkus-openapi-generator</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.openapi.generator</groupId>
<artifactId>quarkus-openapi-generator-oidc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.openapi.generator</groupId>
<artifactId>quarkus-openapi-generator-it-generation-input</artifactId>
Expand Down Expand Up @@ -92,5 +96,26 @@
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
<profile>
<id>resteasy-classic</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-client-oidc-filter</artifactId>
</dependency>
</dependencies>
</profile>
<profile>
<id>resteasy-reactive</id>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-oidc-filter</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>