Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Old Dev UI: OIDC #35048

Merged
merged 1 commit into from
Jul 27, 2023
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 @@ -11,19 +11,13 @@
import io.quarkus.deployment.Capability;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.builditem.ConfigurationBuildItem;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.devconsole.runtime.spi.DevConsolePostHandler;
import io.quarkus.devconsole.spi.DevConsoleRouteBuildItem;
import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem;
import io.quarkus.devconsole.spi.DevConsoleTemplateInfoBuildItem;
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.devui.spi.page.Page;
import io.quarkus.oidc.runtime.OidcConfigPropertySupplier;
import io.quarkus.oidc.runtime.devui.OidcDevUiRecorder;
import io.quarkus.oidc.runtime.devui.OidcDevUiRpcSvcPropertiesBean;
import io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem;

public abstract class AbstractDevConsoleProcessor {
public abstract class AbstractDevUIProcessor {
protected static final String CONFIG_PREFIX = "quarkus.oidc.";
protected static final String CLIENT_ID_CONFIG_KEY = CONFIG_PREFIX + "client-id";
protected static final String CLIENT_SECRET_CONFIG_KEY = CONFIG_PREFIX + "credentials.secret";
Expand All @@ -33,68 +27,6 @@ public abstract class AbstractDevConsoleProcessor {
protected static final String POST_LOGOUT_URI_PARAM_CONFIG_KEY = CONFIG_PREFIX + "logout.post-logout-uri-param";
protected static final String SCOPES_KEY = CONFIG_PREFIX + "authentication.scopes";

protected void produceDevConsoleTemplateItems(Capabilities capabilities,
BuildProducer<DevConsoleTemplateInfoBuildItem> devConsoleTemplate,
BuildProducer<DevConsoleRuntimeTemplateInfoBuildItem> devConsoleRuntimeInfo,
CurateOutcomeBuildItem curateOutcomeBuildItem,
String oidcProviderName,
String oidcApplicationType,
String oidcGrantType,
String authorizationUrl,
String tokenUrl,
String logoutUrl,
boolean introspectionIsAvailable) {
if (oidcProviderName != null) {
devConsoleTemplate.produce(new DevConsoleTemplateInfoBuildItem("oidcProviderName", oidcProviderName));
}
devConsoleTemplate.produce(new DevConsoleTemplateInfoBuildItem("oidcApplicationType", oidcApplicationType));
devConsoleTemplate.produce(new DevConsoleTemplateInfoBuildItem("oidcGrantType", oidcGrantType));

if (capabilities.isPresent(Capability.SMALLRYE_OPENAPI)) {
devConsoleTemplate.produce(new DevConsoleTemplateInfoBuildItem("swaggerIsAvailable", true));
}
if (capabilities.isPresent(Capability.SMALLRYE_GRAPHQL)) {
devConsoleTemplate.produce(new DevConsoleTemplateInfoBuildItem("graphqlIsAvailable", true));
}
devConsoleTemplate.produce(new DevConsoleTemplateInfoBuildItem("introspectionIsAvailable", introspectionIsAvailable));

devConsoleRuntimeInfo.produce(
new DevConsoleRuntimeTemplateInfoBuildItem("clientId",
new OidcConfigPropertySupplier(CLIENT_ID_CONFIG_KEY), this.getClass(), curateOutcomeBuildItem));
devConsoleRuntimeInfo.produce(
new DevConsoleRuntimeTemplateInfoBuildItem("clientSecret",
new OidcConfigPropertySupplier(CLIENT_SECRET_CONFIG_KEY, ""), this.getClass(), curateOutcomeBuildItem));
devConsoleRuntimeInfo.produce(
new DevConsoleRuntimeTemplateInfoBuildItem("authorizationUrl",
new OidcConfigPropertySupplier(AUTHORIZATION_PATH_CONFIG_KEY, authorizationUrl, true), this.getClass(),
curateOutcomeBuildItem));
devConsoleRuntimeInfo.produce(
new DevConsoleRuntimeTemplateInfoBuildItem("tokenUrl",
new OidcConfigPropertySupplier(TOKEN_PATH_CONFIG_KEY, tokenUrl, true), this.getClass(),
curateOutcomeBuildItem));
devConsoleRuntimeInfo.produce(
new DevConsoleRuntimeTemplateInfoBuildItem("logoutUrl",
new OidcConfigPropertySupplier(END_SESSION_PATH_CONFIG_KEY, logoutUrl, true), this.getClass(),
curateOutcomeBuildItem));
devConsoleRuntimeInfo.produce(
new DevConsoleRuntimeTemplateInfoBuildItem("postLogoutUriParam",
new OidcConfigPropertySupplier(POST_LOGOUT_URI_PARAM_CONFIG_KEY), this.getClass(),
curateOutcomeBuildItem));
devConsoleRuntimeInfo.produce(
new DevConsoleRuntimeTemplateInfoBuildItem("scopes",
new OidcConfigPropertySupplier(SCOPES_KEY), this.getClass(), curateOutcomeBuildItem));

}

protected void produceDevConsoleRouteItems(BuildProducer<DevConsoleRouteBuildItem> devConsoleRoute,
DevConsolePostHandler testServiceWithToken,
DevConsolePostHandler exchangeCodeForTokens,
DevConsolePostHandler passwordClientCredHandler) {
devConsoleRoute.produce(new DevConsoleRouteBuildItem("testServiceWithToken", "POST", testServiceWithToken));
devConsoleRoute.produce(new DevConsoleRouteBuildItem("exchangeCodeForTokens", "POST", exchangeCodeForTokens));
devConsoleRoute.produce(new DevConsoleRouteBuildItem("testService", "POST", passwordClientCredHandler));
}

protected static CardPageBuildItem createProviderWebComponent(OidcDevUiRecorder recorder,
Capabilities capabilities,
String oidcProviderName,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
import io.quarkus.deployment.builditem.ConfigurationBuildItem;
import io.quarkus.deployment.builditem.CuratedApplicationShutdownBuildItem;
import io.quarkus.deployment.builditem.RuntimeConfigSetupCompleteBuildItem;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.devconsole.spi.DevConsoleRouteBuildItem;
import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem;
import io.quarkus.devconsole.spi.DevConsoleTemplateInfoBuildItem;
import io.quarkus.devui.spi.JsonRPCProvidersBuildItem;
import io.quarkus.devui.spi.page.CardPageBuildItem;
import io.quarkus.oidc.OidcTenantConfig;
Expand All @@ -41,9 +37,9 @@
import io.vertx.mutiny.ext.web.client.HttpResponse;
import io.vertx.mutiny.ext.web.client.WebClient;

public class OidcDevConsoleProcessor extends AbstractDevConsoleProcessor {
public class OidcDevUIProcessor extends AbstractDevUIProcessor {
static volatile Vertx vertxInstance;
private static final Logger LOG = Logger.getLogger(OidcDevConsoleProcessor.class);
private static final Logger LOG = Logger.getLogger(OidcDevUIProcessor.class);

private static final String TENANT_ENABLED_CONFIG_KEY = CONFIG_PREFIX + "tenant-enabled";
private static final String DISCOVERY_ENABLED_CONFIG_KEY = CONFIG_PREFIX + "discovery-enabled";
Expand All @@ -63,11 +59,8 @@ public class OidcDevConsoleProcessor extends AbstractDevConsoleProcessor {
@Record(ExecutionTime.RUNTIME_INIT)
@BuildStep(onlyIf = IsDevelopment.class)
@Consume(RuntimeConfigSetupCompleteBuildItem.class)
void prepareOidcDevConsole(BuildProducer<DevConsoleTemplateInfoBuildItem> devConsoleInfo,
BuildProducer<DevConsoleRuntimeTemplateInfoBuildItem> devConsoleRuntimeInfo,
CuratedApplicationShutdownBuildItem closeBuildItem,
BuildProducer<DevConsoleRouteBuildItem> devConsoleRoute,
Capabilities capabilities, CurateOutcomeBuildItem curateOutcomeBuildItem,
void prepareOidcDevConsole(CuratedApplicationShutdownBuildItem closeBuildItem,
Capabilities capabilities,
BuildProducer<SyntheticBeanBuildItem> syntheticBeanBuildItemBuildProducer,
NonApplicationRootPathBuildItem nonApplicationRootPathBuildItem,
BuildProducer<CardPageBuildItem> cardPageProducer,
Expand Down Expand Up @@ -107,35 +100,8 @@ public void run() {
}
}
String providerName = tryToGetProviderName(authServerUrl);
if (KEYCLOAK.equals(providerName)) {
devConsoleInfo.produce(new DevConsoleTemplateInfoBuildItem("keycloakAdminUrl",
authServerUrl.substring(0, authServerUrl.indexOf("/realms/"))));
}
boolean metadataNotNull = metadata != null;

// old DEV UI
produceDevConsoleTemplateItems(capabilities,
devConsoleInfo,
devConsoleRuntimeInfo,
curateOutcomeBuildItem,
providerName,
getApplicationType(providerConfig),
oidcConfig.devui.grant.type.isPresent() ? oidcConfig.devui.grant.type.get().getGrantType() : "code",
metadataNotNull ? metadata.getString("authorization_endpoint") : null,
metadataNotNull ? metadata.getString("token_endpoint") : null,
metadataNotNull ? metadata.getString("end_session_endpoint") : null,
metadataNotNull
? (metadata.containsKey("introspection_endpoint") || metadata.containsKey("userinfo_endpoint"))
: checkProviderUserInfoRequired(providerConfig));

produceDevConsoleRouteItems(devConsoleRoute,
new OidcTestServiceHandler(vertxInstance, oidcConfig.devui.webClientTimeout),
new OidcAuthorizationCodePostHandler(vertxInstance, oidcConfig.devui.webClientTimeout,
oidcConfig.devui.grantOptions),
new OidcPasswordClientCredHandler(vertxInstance, oidcConfig.devui.webClientTimeout,
oidcConfig.devui.grantOptions));

// new DEV UI
final String keycloakAdminUrl;
if (KEYCLOAK.equals(providerName)) {
keycloakAdminUrl = authServerUrl.substring(0, authServerUrl.indexOf("/realms/"));
Expand Down

This file was deleted.

This file was deleted.

Loading