diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderDescriptor.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderDescriptor.java index 5992027a3fd..6fa301fb760 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderDescriptor.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderDescriptor.java @@ -49,7 +49,7 @@ public class WebAuthProviderDescriptor extends AbstractDescriptor { private final Map> metaParameters = new HashMap<>(); private SMAuthProvider instance; private final DBPImage icon; - private final Map configurationParameters = new LinkedHashMap<>(); + private final Map configurationParameters = new LinkedHashMap<>(); private final List credentialProfiles = new ArrayList<>(); private final boolean configurable; private final boolean trusted; @@ -72,7 +72,7 @@ public WebAuthProviderDescriptor(IConfigurationElement cfg) { String category = propGroup.getAttribute(PropertyDescriptor.ATTR_LABEL); IConfigurationElement[] propElements = propGroup.getChildren(PropertyDescriptor.TAG_PROPERTY); for (IConfigurationElement prop : propElements) { - PropertyDescriptor propertyDescriptor = new PropertyDescriptor(category, prop); + WebAuthProviderProperty propertyDescriptor = new WebAuthProviderProperty(category, prop); configurationParameters.put(CommonUtils.toString(propertyDescriptor.getId()), propertyDescriptor); } } @@ -130,7 +130,7 @@ public boolean isRequired() { return isRequired; } - public List getConfigurationParameters() { + public List getConfigurationParameters() { return new ArrayList<>(configurationParameters.values()); } diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderProperty.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderProperty.java new file mode 100644 index 00000000000..e755acae3d9 --- /dev/null +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderProperty.java @@ -0,0 +1,36 @@ +/* + * DBeaver - Universal Database Manager + * Copyright (C) 2010-2024 DBeaver Corp and others + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.cloudbeaver.registry; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.jkiss.code.NotNull; +import org.jkiss.dbeaver.model.impl.PropertyDescriptor; + +public class WebAuthProviderProperty extends PropertyDescriptor { + private final String[] requiredFeatures; + + public WebAuthProviderProperty(String category, IConfigurationElement config) { + super(category, config); + String featuresAttr = config.getAttribute("requiredFeatures"); + this.requiredFeatures = featuresAttr == null ? new String[0] : featuresAttr.split(","); + } + + @NotNull + public String[] getRequiredFeatures() { + return requiredFeatures; + } +} diff --git a/server/bundles/io.cloudbeaver.service.admin/src/io/cloudbeaver/service/admin/impl/WebServiceAdmin.java b/server/bundles/io.cloudbeaver.service.admin/src/io/cloudbeaver/service/admin/impl/WebServiceAdmin.java index 3097e4020bd..9be0a2321ba 100644 --- a/server/bundles/io.cloudbeaver.service.admin/src/io/cloudbeaver/service/admin/impl/WebServiceAdmin.java +++ b/server/bundles/io.cloudbeaver.service.admin/src/io/cloudbeaver/service/admin/impl/WebServiceAdmin.java @@ -404,11 +404,20 @@ public List listAuthProviderConfigurationParameters(@NotNull We if (authProvider == null) { throw new DBWebException("Invalid provider ID " + providerId); } + var application = CBApplication.getInstance(); return authProvider.getConfigurationParameters().stream().filter(p -> { - if (p.hasFeature("distributed")) { - return CBApplication.getInstance().isDistributed(); + boolean allFeaturesEnabled = true; + for (String feature : p.getRequiredFeatures()) { + if (feature.equals("distributed")) { + allFeaturesEnabled = CBApplication.getInstance().isDistributed(); + } else { + allFeaturesEnabled = application.getAppConfiguration().isFeatureEnabled(feature); + } + if (!allFeaturesEnabled) { + break; + } } - return true; + return allFeaturesEnabled; }).map(p -> new WebPropertyInfo(webSession, p)).collect(Collectors.toList()); }