#8 Authentication service be

This commit is contained in:
serge-rider
2020-04-28 17:54:19 +03:00
parent 41a99c80fa
commit fa1908573f
11 changed files with 189 additions and 7 deletions
@@ -15,9 +15,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.commands,
org.eclipse.core.resources,
org.apache.commons.jexl,
org.jkiss.utils,
org.jkiss.utils;visibility:=reexport,
org.jkiss.dbeaver.model;visibility:=reexport,
org.jkiss.dbeaver.model.sql,
org.jkiss.dbeaver.model.sql;visibility:=reexport,
org.jkiss.dbeaver.registry,
org.jkiss.dbeaver.data.gis,
javax.servlet;visibility:=reexport,
@@ -412,6 +412,9 @@ type Query {
# Returns session state ( initialize if not )
sessionState: SessionInfo
# Session permissions
sessionPermissions: [ID]!
# Get driver info
driverList( id: ID ): [ DriverInfo! ]
@@ -0,0 +1,20 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Vendor: %Bundle-Vendor
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: io.cloudbeaver.service.auth;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Release-Date: 20200504
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.expressions,
org.apache.commons.logging,
org.eclipse.core.commands,
org.eclipse.core.resources,
io.cloudbeaver.server,
org.jkiss.dbeaver.model,
org.jkiss.dbeaver.model.sql
Bundle-Localization: OSGI-INF/l10n/bundle
Automatic-Module-Name: io.cloudbeaver.service.auth
@@ -0,0 +1,2 @@
Bundle-Vendor = DBeaver Corp
Bundle-Name = Cloudbeaver Web Service - Metadata
@@ -0,0 +1,7 @@
source.. = src/
output.. = target/classes/
bin.includes = .,\
META-INF/,\
OSGI-INF/,\
schema/,\
plugin.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension point="io.cloudbeaver.service">
<service id="auth" label="User authentication" description="User authentication services" class="io.cloudbeaver.service.metadata.WebServiceAuth">
</service>
</extension>
</plugin>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.cloudbeaver</groupId>
<artifactId>bundles</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.service.metadata</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
@@ -0,0 +1,73 @@
type UserInfo {
userName: ID!
}
type RoleInfo {
roleName: ID!
permissions: [ID]!
}
type PermissionInfo {
id: ID!
label: [String]
description: [String]
}
type Admin {
users: [UserInfo]
roles: [RoleInfo]
permissions: [PermissionInfo]
createUser(userName: ID!): UserInfo!
deleteUser(userName: ID!): Boolean
setUserAuthCredentials(userName: ID!, model: ID!, credentials: Object): Boolean
grantUserRole(user: ID!, role: ID!): Boolean
revokeUserRole(user: ID!, role: ID!): Boolean
}
type AuthCredentialInfo {
id: ID!
label: String!
description: String
protected: Boolean
editable: Boolean
possibleValues: [String]!
order: Int
}
type AuthModelInfo {
id: ID!
label: String!
icon: ID
description: String
isDefault: Boolean
crdentialsInfo: [AuthCredentialInfo]!
}
type UserAuthInfo {
userName: String!
loginTime: DateTime
# Optional login message
message: String
}
extend type Query {
login(model: ID!, credentials: Object!): UserAuthInfo
logout: Boolean
sessionUser: UserAuthInfo
authModels: [AuthModelInfo]!
}
@@ -0,0 +1,54 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2020 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.service.metadata;
import graphql.schema.idl.TypeDefinitionRegistry;
import io.cloudbeaver.DBWebException;
import io.cloudbeaver.WebServiceUtils;
import io.cloudbeaver.api.DBWModel;
import io.cloudbeaver.api.DBWServiceGraphQL;
import io.cloudbeaver.api.DBWUtils;
import io.cloudbeaver.server.model.WebNavigatorNodeInfo;
import io.cloudbeaver.server.model.session.WebSession;
import org.jkiss.dbeaver.model.DBPScriptObject;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.navigator.DBNNode;
import org.jkiss.dbeaver.model.struct.DBSObject;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Web service implementation
*/
public class WebServiceAuth implements DBWServiceGraphQL {
private static final String SCHEMA_FILE_NAME = "schema/service.auth.graphqls";
@Override
public TypeDefinitionRegistry getTypeDefinition() throws DBWebException {
return WebServiceUtils.loadSchemaDefinition(getClass(), SCHEMA_FILE_NAME);
}
@Override
public void bindWiring(DBWModel model) throws DBWebException {
model.getQueryType().dataFetcher("login", env -> {
throw new DBWebException("Not implemented");
});
}
}
@@ -15,7 +15,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
io.cloudbeaver.server,
org.jkiss.dbeaver.data.transfer,
org.jkiss.dbeaver.model,
org.jkiss.dbeaver.model.sql,
org.jkiss.dbeaver.registry
Bundle-Localization: OSGI-INF/l10n/bundle
@@ -14,10 +14,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.commands,
org.eclipse.core.resources,
io.cloudbeaver.server,
com.google.gson,
javax.servlet,
org.jkiss.bundle.graphql.java,
org.jkiss.dbeaver.model,
org.jkiss.dbeaver.model.sql
Bundle-Localization: OSGI-INF/l10n/bundle
Automatic-Module-Name: io.cloudbeaver.service.metadata