Skip to content

Commit

Permalink
Cb 4460 shared query history for the team (#29997)
Browse files Browse the repository at this point in the history
* CB-5067 team supervisor

* CB-4460 extended team members info api

---------

Co-authored-by: Evgenia Bezborodova <139753579+EvgeniaBzzz@users.noreply.github.com>
Co-authored-by: kseniaguzeeva <112612526+kseniaguzeeva@users.noreply.github.com>
  • Loading branch information
3 people committed May 14, 2024
1 parent 94ace59 commit d69b476
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
import org.jkiss.dbeaver.model.impl.plan.AbstractExecutionPlanNode;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.meta.PropertyLength;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -56,6 +53,7 @@ private CubridPlanNode(@Nullable CubridPlanNode parent, @Nullable String name, @
parseNode();
}


@NotNull
@Property(order = 0, viewable = true)
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.security.user.SMTeam;
import org.jkiss.dbeaver.model.security.user.SMUser;
import org.jkiss.dbeaver.model.security.user.SMUserFilter;
import org.jkiss.dbeaver.model.security.user.SMUserImportList;
import org.jkiss.dbeaver.model.security.user.*;

import java.util.List;
import java.util.Map;
Expand All @@ -44,7 +41,7 @@ public interface SMAdminController extends SMController {
* @throws DBException the db exception
*/
@NotNull
SMTeam[] getUserTeams(String userId) throws DBException;
SMUserTeam[] getUserTeams(String userId) throws DBException;

/**
* Create user.
Expand All @@ -70,6 +67,9 @@ void createUser(

void setUserTeams(String userId, String[] teamIds, String grantorId) throws DBException;

void setUserTeamRole(@NotNull String userId, @NotNull String teamId, @Nullable String teamRole) throws DBException;


/**
* Gets user by id.
*
Expand Down Expand Up @@ -99,9 +99,6 @@ void createUser(

SMTeam findTeam(String teamId) throws DBException;

@NotNull
String[] getTeamMembers(String teamId) throws DBException;

void createTeam(String teamId, String name, String description, String grantor) throws DBException;

void updateTeam(String teamId, String name, String description) throws DBException;
Expand Down Expand Up @@ -212,4 +209,8 @@ void deleteObjectPermissions(
@NotNull Set<String> subjectIds,
@NotNull Set<String> permissions
) throws DBException;

@NotNull
List<SMTeamMemberInfo> getTeamMembersInfo(@NotNull String teamId) throws DBException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.jkiss.dbeaver.model.auth.SMAuthCredentialsManager;
import org.jkiss.dbeaver.model.security.user.SMAuthPermissions;
import org.jkiss.dbeaver.model.security.user.SMObjectPermissions;
import org.jkiss.dbeaver.model.security.user.SMTeam;
import org.jkiss.dbeaver.model.security.user.SMUser;
import org.jkiss.dbeaver.model.security.user.SMUserTeam;

import java.util.List;
import java.util.Map;
Expand All @@ -47,7 +47,7 @@ public interface SMController extends DBPObjectController,
* @throws DBException the db exception
*/
@NotNull
SMTeam[] getCurrentUserTeams() throws DBException;
SMUserTeam[] getCurrentUserTeams() throws DBException;

/**
* Gets current active user.
Expand Down Expand Up @@ -221,4 +221,13 @@ void deleteAllObjectPermissions(
@NotNull String objectId,
@NotNull SMObjectType objectType
) throws DBException;

/**
* checks that the current suer has the required role and is a member of the same teams as the specified list of
* users
*/
boolean hasAccessToUsers(@NotNull String teamRole, @NotNull Set<String> userIds) throws DBException;

@NotNull
String[] getTeamMembers(String teamId) throws DBException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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 org.jkiss.dbeaver.model.security;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

public record SMTeamMemberInfo(@NotNull String userId, @Nullable String teamRole) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
import java.util.Map;

public abstract class SMSubject implements DBPNamedObject {

@NotNull
protected final String subjectId;
private final boolean secretStorage;
@NotNull
private final Map<String, String> metaParameters = new LinkedHashMap<>();

public SMSubject(
Expand All @@ -41,6 +42,7 @@ public SMSubject(
}
}

@NotNull
public String getSubjectId() {
return subjectId;
}
Expand All @@ -54,8 +56,8 @@ public void setMetaParameter(String name, String value) {
metaParameters.put(name, value);
}

@NotNull
public void setMetaParameters(Map<String, String> parameters) {

public void setMetaParameters(@NotNull Map<String, String> parameters) {
metaParameters.clear();
metaParameters.putAll(parameters);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,28 @@
package org.jkiss.dbeaver.model.security.user;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.utils.CommonUtils;

import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;

public class SMTeam extends SMSubject {

@Nullable
private String teamName;
@Nullable
private String description;
@NotNull
private Set<String> permissions = new LinkedHashSet<>();

public SMTeam(String teamId) {

public SMTeam(@NotNull String teamId) {
this(teamId, null, null, true);
}

public SMTeam(String teamId, String name, String description, boolean secretStorage) {
public SMTeam(@NotNull String teamId, @Nullable String name, @Nullable String description, boolean secretStorage) {
super(teamId, null, secretStorage);
this.teamName = name;
this.description = description;
Expand All @@ -57,24 +61,26 @@ public String getTeamName() {
return CommonUtils.isEmpty(teamName) ? subjectId : teamName;
}

public void setTeamName(String teamName) {
public void setTeamName(@Nullable String teamName) {
this.teamName = teamName;
}

@Nullable
@Property(viewable = true, order = 3)
public String getDescription() {
return description;
}

public void setDescription(String description) {
public void setDescription(@Nullable String description) {
this.description = description;
}

@NotNull
public Set<String> getPermissions() {
return permissions;
}

public void setPermissions(Set<String> permissions) {
public void setPermissions(@NotNull Set<String> permissions) {
this.permissions = permissions;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 org.jkiss.dbeaver.model.security.user;

import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;

public class SMUserTeam extends SMTeam {
@Nullable
private final String teamRole;

public SMUserTeam(
@NotNull SMTeam smTeam, @Nullable String teamRole
) {
super(smTeam.getTeamId(), smTeam.getTeamName(), smTeam.getDescription(), smTeam.isSecretStorage());
this.teamRole = teamRole;
}

@Nullable
public String getTeamRole() {
return teamRole;
}
}

0 comments on commit d69b476

Please sign in to comment.