Skip to content

Commit

Permalink
Fix OidcBuildStep#findSecurityEventObservers()
Browse files Browse the repository at this point in the history
- this build step should consume RuntimeConfigSetupCompleteBuildItem
because DefaultTenantConfigResolver injects a runtime config property
- resolves quarkusio#26236
  • Loading branch information
mkouba committed Jun 22, 2022
1 parent 5aac1c4 commit b43a7be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ private static Consumer<BuildChainBuilder> loadStepsFromClass(Class<?> clazz,
methodParamFns.add((bc, bri) -> bc.consume(buildItemClass));
} else if (isAnEmptyBuildItemConsumer(parameterType)) {
throw reportError(parameter,
"Cannot consume an empty build item, use @Produce(class) on the build step method instead");
"Cannot consume an empty build item, use @Consume(class) on the build step method instead");
} else if (isAnEmptyBuildItemProducer(parameterType)) {
throw reportError(parameter,
"Cannot produce an empty build item, use @Produce(class) on the build step method instead");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.oidc.deployment;

import java.util.Collection;
import java.util.function.BooleanSupplier;

import javax.inject.Singleton;
Expand All @@ -9,20 +8,19 @@
import org.jboss.jandex.DotName;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.SynthesisFinishedBuildItem;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.arc.deployment.ValidationPhaseBuildItem;
import io.quarkus.arc.deployment.ValidationPhaseBuildItem.ValidationErrorBuildItem;
import io.quarkus.arc.processor.BuildExtension;
import io.quarkus.arc.processor.ObserverInfo;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Capability;
import io.quarkus.deployment.Feature;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.Consume;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.RuntimeConfigSetupCompleteBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.oidc.SecurityEvent;
import io.quarkus.oidc.TokenIntrospectionCache;
Expand Down Expand Up @@ -128,16 +126,16 @@ public SyntheticBeanBuildItem setup(
.done();
}

// Note that DefaultTenantConfigResolver injects quarkus.http.proxy.enable-forwarded-prefix
@Consume(RuntimeConfigSetupCompleteBuildItem.class)
@BuildStep(onlyIf = IsEnabled.class)
@Record(ExecutionTime.RUNTIME_INIT)
public ValidationErrorBuildItem findSecurityEventObservers(
public void findSecurityEventObservers(
OidcRecorder recorder,
ValidationPhaseBuildItem validationPhase) {
Collection<ObserverInfo> observers = validationPhase.getContext().get(BuildExtension.Key.OBSERVERS);
boolean isSecurityEventObserved = observers.stream()
SynthesisFinishedBuildItem synthesisFinished) {
boolean isSecurityEventObserved = synthesisFinished.getObservers().stream()
.anyMatch(observer -> observer.asObserver().getObservedType().name().equals(DOTNAME_SECURITY_EVENT));
recorder.setSecurityEventObserved(isSecurityEventObserved);
return new ValidationErrorBuildItem();
}

public static class IsEnabled implements BooleanSupplier {
Expand Down

0 comments on commit b43a7be

Please sign in to comment.