mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-1356 Default user metas
This commit is contained in:
@@ -158,7 +158,7 @@ extend type Query {
|
||||
|
||||
#### User profile
|
||||
|
||||
saveUserMetaParameter(id: ID!, displayName: String!, description: String, required: Boolean!): Boolean!
|
||||
saveUserMetaParameter(id: ID!, displayName: String!, description: String, required: Boolean!): ObjectPropertyInfo!
|
||||
|
||||
deleteUserMetaParameter(id: ID!): Boolean!
|
||||
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ public interface DBWServiceAdmin extends DBWService {
|
||||
// User meta parameters
|
||||
|
||||
@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
|
||||
boolean saveUserMetaParameter(WebSession webSession, String id, String displayName, String description, Boolean required) throws DBWebException;
|
||||
WebPropertyInfo saveUserMetaParameter(WebSession webSession, String id, String displayName, String description, Boolean required) throws DBWebException;
|
||||
@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
|
||||
Object deleteUserMetaParameter(WebSession webSession, String id) throws DBWebException;
|
||||
@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
|
||||
|
||||
+1
-1
@@ -595,7 +595,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveUserMetaParameter(WebSession webSession, String id, String displayName, String description, Boolean required) throws DBWebException {
|
||||
public WebPropertyInfo saveUserMetaParameter(WebSession webSession, String id, String displayName, String description, Boolean required) throws DBWebException {
|
||||
throw new DBWebException("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,22 @@
|
||||
|
||||
<plugin>
|
||||
|
||||
<extension-point id="io.cloudbeaver.userProfile" name="User profiles" schema="schema/io.cloudbeaver.userProfile.exsd"/>
|
||||
|
||||
<extension point="io.cloudbeaver.service">
|
||||
<service id="auth" label="User authentication" description="User authentication services" class="io.cloudbeaver.service.auth.WebServiceBindingAuth">
|
||||
|
||||
</service>
|
||||
</extension>
|
||||
|
||||
<extension point="io.cloudbeaver.userProfile">
|
||||
<userProfileProperties>
|
||||
<propertyGroup label="Main">
|
||||
<property id="firstName" label="First Name" type="string" description="User first name"/>
|
||||
<property id="lastName" label="Last Name" type="string" description="User last name"/>
|
||||
</propertyGroup>
|
||||
</userProfileProperties>
|
||||
</extension>
|
||||
|
||||
|
||||
</plugin>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.schema plugin="io.cloudbeaver.auth" id="io.cloudbeaver.userProfile" name="User profile properties"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.element />
|
||||
</appInfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="propertyGroup"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="driver">
|
||||
<annotation>
|
||||
<documentation>
|
||||
Web service description
|
||||
</documentation>
|
||||
</annotation>
|
||||
</element>
|
||||
|
||||
|
||||
</schema>
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* DBeaver - Universal Database Manager
|
||||
* Copyright (C) 2010-2021 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.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.model.impl.PropertyDescriptor;
|
||||
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
|
||||
import org.jkiss.utils.ArrayUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class WebUserProfileRegistry {
|
||||
|
||||
private static final Log log = Log.getLog(WebUserProfileRegistry.class);
|
||||
|
||||
public static final String EXTENSION_ID = "io.cloudbeaver.userProfile"; //$NON-NLS-1$
|
||||
|
||||
private static WebUserProfileRegistry instance = null;
|
||||
private final List<DBPPropertyDescriptor> properties = new ArrayList<>();
|
||||
|
||||
public synchronized static WebUserProfileRegistry getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new WebUserProfileRegistry();
|
||||
instance.loadExtensions(Platform.getExtensionRegistry());
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private WebUserProfileRegistry() {
|
||||
}
|
||||
|
||||
public List<DBPPropertyDescriptor> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
private void loadExtensions(IExtensionRegistry registry) {
|
||||
IConfigurationElement[] extConfigs = registry.getConfigurationElementsFor(EXTENSION_ID);
|
||||
for (IConfigurationElement ext : extConfigs) {
|
||||
for (IConfigurationElement cfgElement : ext.getChildren("userProfileProperties")) {
|
||||
for (IConfigurationElement propGroup : ArrayUtils.safeArray(cfgElement.getChildren(PropertyDescriptor.TAG_PROPERTY_GROUP))) {
|
||||
properties.addAll(PropertyDescriptor.extractProperties(propGroup));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -19,6 +19,7 @@ package io.cloudbeaver.service.auth;
|
||||
import io.cloudbeaver.DBWService;
|
||||
import io.cloudbeaver.DBWebException;
|
||||
import io.cloudbeaver.WebAction;
|
||||
import io.cloudbeaver.model.WebPropertyInfo;
|
||||
import io.cloudbeaver.model.session.WebAuthInfo;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.model.user.WebAuthProviderInfo;
|
||||
@@ -55,4 +56,7 @@ public interface DBWServiceAuth extends DBWService {
|
||||
|
||||
@WebAction()
|
||||
boolean changeLocalPassword(@NotNull WebSession webSession, @NotNull String oldPassword, @NotNull String newPassword) throws DBWebException;
|
||||
|
||||
@WebAction()
|
||||
WebPropertyInfo[] listUserProfileProperties(@NotNull WebSession webSession);
|
||||
}
|
||||
|
||||
+2
@@ -56,6 +56,8 @@ public class WebServiceBindingAuth extends WebServiceBindingBase<DBWServiceAuth>
|
||||
env.getArgument("oldPassword"),
|
||||
env.getArgument("newPassword")
|
||||
))
|
||||
.dataFetcher("listUserProfileProperties",
|
||||
env -> getService(env).listUserProfileProperties(getWebSession(env)))
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
+9
@@ -23,12 +23,14 @@ import io.cloudbeaver.DBWebException;
|
||||
import io.cloudbeaver.auth.DBWAuthProvider;
|
||||
import io.cloudbeaver.auth.DBWAuthProviderExternal;
|
||||
import io.cloudbeaver.auth.provider.local.LocalAuthProvider;
|
||||
import io.cloudbeaver.model.WebPropertyInfo;
|
||||
import io.cloudbeaver.model.session.WebAuthInfo;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.model.user.WebAuthProviderInfo;
|
||||
import io.cloudbeaver.model.user.WebUser;
|
||||
import io.cloudbeaver.registry.WebAuthProviderDescriptor;
|
||||
import io.cloudbeaver.registry.WebServiceRegistry;
|
||||
import io.cloudbeaver.registry.WebUserProfileRegistry;
|
||||
import io.cloudbeaver.server.CBAppConfig;
|
||||
import io.cloudbeaver.server.CBApplication;
|
||||
import io.cloudbeaver.server.CBPlatform;
|
||||
@@ -298,4 +300,11 @@ public class WebServiceAuthImpl implements DBWServiceAuth {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebPropertyInfo[] listUserProfileProperties(@NotNull WebSession webSession) {
|
||||
return WebUserProfileRegistry.getInstance().getProperties().stream()
|
||||
.map(p -> new WebPropertyInfo(webSession, p, null))
|
||||
.toArray(WebPropertyInfo[]::new);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user