Skip to content

Commit

Permalink
Merge pull request #37819 from michalvavrik/feature/fix-oidc-event-fi…
Browse files Browse the repository at this point in the history
…red-before-config-ready

Fix OIDC Security event fired before runtime config ready in Arc
  • Loading branch information
sberyozkin committed Dec 18, 2023
2 parents d190632 + 17c9b47 commit 235b7f3
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.function.Function;
import java.util.function.Supplier;

import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
import org.jose4j.jwk.JsonWebKey;
import org.jose4j.jwk.PublicJsonWebKey;
Expand Down Expand Up @@ -46,7 +47,6 @@
import io.quarkus.security.identity.AuthenticationRequestContext;
import io.quarkus.security.identity.SecurityIdentity;
import io.quarkus.security.identity.request.TokenAuthenticationRequest;
import io.quarkus.security.runtime.SecurityConfig;
import io.quarkus.security.spi.runtime.BlockingSecurityExecutor;
import io.quarkus.security.spi.runtime.MethodDescription;
import io.quarkus.security.spi.runtime.SecurityEventHelper;
Expand All @@ -64,6 +64,7 @@
public class OidcRecorder {

private static final Logger LOG = Logger.getLogger(OidcRecorder.class);
private static final String SECURITY_EVENTS_ENABLED_CONFIG_KEY = "quarkus.security.events.enabled";

private static final Map<String, TenantConfigContext> dynamicTenantsConfig = new ConcurrentHashMap<>();
private static final Set<String> tenantsExpectingServerAvailableEvents = ConcurrentHashMap.newKeySet();
Expand Down Expand Up @@ -559,7 +560,7 @@ private static boolean shouldFireOidcServerAvailableEvent(String tenantId) {
}

private static boolean fireOidcServerEvent(String authServerUrl, SecurityEvent.Type eventType) {
if (Arc.container().instance(SecurityConfig.class).get().events().enabled()) {
if (ConfigProvider.getConfig().getOptionalValue(SECURITY_EVENTS_ENABLED_CONFIG_KEY, boolean.class).orElse(true)) {
SecurityEventHelper.fire(
Arc.container().beanManager().getEvent().select(SecurityEvent.class),
new SecurityEvent(eventType, Map.of(AUTH_SERVER_URL, authServerUrl)));
Expand Down

0 comments on commit 235b7f3

Please sign in to comment.