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

Add RBAC enhancement interfaces for V2 #1186

Merged
merged 1 commit into from
Nov 20, 2024
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
52 changes: 35 additions & 17 deletions src/main/java/io/milvus/v2/client/MilvusClientV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
import io.milvus.v2.service.index.response.*;
import io.milvus.v2.service.partition.PartitionService;
import io.milvus.v2.service.partition.request.*;
import io.milvus.v2.service.rbac.RoleService;
import io.milvus.v2.service.rbac.UserService;
import io.milvus.v2.service.rbac.RBACService;
import io.milvus.v2.service.rbac.request.*;
import io.milvus.v2.service.rbac.response.*;
import io.milvus.v2.service.utility.UtilityService;
Expand Down Expand Up @@ -73,8 +72,7 @@ public class MilvusClientV2 {
private final IndexService indexService = new IndexService();
private final VectorService vectorService = new VectorService();
private final PartitionService partitionService = new PartitionService();
private final UserService userService = new UserService();
private final RoleService roleService = new RoleService();
private final RBACService rbacService = new RBACService();
private final UtilityService utilityService = new UtilityService();
private ConnectConfig connectConfig;
private RetryConfig retryConfig = RetryConfig.builder().build();
Expand Down Expand Up @@ -625,7 +623,7 @@ public void releasePartitions(ReleasePartitionsReq request) {
* @return List of String usernames
*/
public List<String> listUsers() {
return retry(()->userService.listUsers(this.getRpcStub()));
return retry(()->rbacService.listUsers(this.getRpcStub()));
}
/**
* describe user
Expand All @@ -634,31 +632,31 @@ public List<String> listUsers() {
* @return DescribeUserResp
*/
public DescribeUserResp describeUser(DescribeUserReq request) {
return retry(()->userService.describeUser(this.getRpcStub(), request));
return retry(()->rbacService.describeUser(this.getRpcStub(), request));
}
/**
* create user
*
* @param request create user request
*/
public void createUser(CreateUserReq request) {
retry(()->userService.createUser(this.getRpcStub(), request));
retry(()->rbacService.createUser(this.getRpcStub(), request));
}
/**
* change password
*
* @param request change password request
*/
public void updatePassword(UpdatePasswordReq request) {
retry(()->userService.updatePassword(this.getRpcStub(), request));
retry(()->rbacService.updatePassword(this.getRpcStub(), request));
}
/**
* drop user
*
* @param request drop user request
*/
public void dropUser(DropUserReq request) {
retry(()->userService.dropUser(this.getRpcStub(), request));
retry(()->rbacService.dropUser(this.getRpcStub(), request));
}
// role operations
/**
Expand All @@ -667,7 +665,7 @@ public void dropUser(DropUserReq request) {
* @return List of String role names
*/
public List<String> listRoles() {
return retry(()->roleService.listRoles(this.getRpcStub()));
return retry(()->rbacService.listRoles(this.getRpcStub()));
}
/**
* describe role
Expand All @@ -676,55 +674,75 @@ public List<String> listRoles() {
* @return DescribeRoleResp
*/
public DescribeRoleResp describeRole(DescribeRoleReq request) {
return retry(()->roleService.describeRole(this.getRpcStub(), request));
return retry(()->rbacService.describeRole(this.getRpcStub(), request));
}
/**
* create role
*
* @param request create role request
*/
public void createRole(CreateRoleReq request) {
retry(()->roleService.createRole(this.getRpcStub(), request));
retry(()->rbacService.createRole(this.getRpcStub(), request));
}
/**
* drop role
*
* @param request drop role request
*/
public void dropRole(DropRoleReq request) {
retry(()->roleService.dropRole(this.getRpcStub(), request));
retry(()->rbacService.dropRole(this.getRpcStub(), request));
}
/**
* grant privilege
*
* @param request grant privilege request
*/
public void grantPrivilege(GrantPrivilegeReq request) {
retry(()->roleService.grantPrivilege(this.getRpcStub(), request));
retry(()->rbacService.grantPrivilege(this.getRpcStub(), request));
}
/**
* revoke privilege
*
* @param request revoke privilege request
*/
public void revokePrivilege(RevokePrivilegeReq request) {
retry(()->roleService.revokePrivilege(this.getRpcStub(), request));
retry(()->rbacService.revokePrivilege(this.getRpcStub(), request));
}
/**
* grant role
*
* @param request grant role request
*/
public void grantRole(GrantRoleReq request) {
retry(()->roleService.grantRole(this.getRpcStub(), request));
retry(()->rbacService.grantRole(this.getRpcStub(), request));
}
/**
* revoke role
*
* @param request revoke role request
*/
public void revokeRole(RevokeRoleReq request) {
retry(()->roleService.revokeRole(this.getRpcStub(), request));
retry(()->rbacService.revokeRole(this.getRpcStub(), request));
}

public void createPrivilegeGroup(CreatePrivilegeGroupReq request) {
retry(()->rbacService.createPrivilegeGroup(this.getRpcStub(), request));
}

public void dropPrivilegeGroup(DropPrivilegeGroupReq request) {
retry(()->rbacService.dropPrivilegeGroup(this.getRpcStub(), request));
}

public ListPrivilegeGroupsResp listPrivilegeGroups(ListPrivilegeGroupsReq request) {
return retry(()->rbacService.listPrivilegeGroups(this.getRpcStub(), request));
}

public void addPrivilegesToGroup(AddPrivilegesToGroupReq request) {
retry(()->rbacService.addPrivilegesToGroup(this.getRpcStub(), request));
}

public void removePrivilegesFromGroup(RemovePrivilegesFromGroupReq request) {
retry(()->rbacService.removePrivilegesFromGroup(this.getRpcStub(), request));
}

// Utility Operations
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/io/milvus/v2/service/rbac/Privilege.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.milvus.v2.service.rbac;

import lombok.Data;
import lombok.experimental.SuperBuilder;

@Data
@SuperBuilder
public class Privilege {
private String name;
}
35 changes: 35 additions & 0 deletions src/main/java/io/milvus/v2/service/rbac/PrivilegeGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.milvus.v2.service.rbac;

import lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;

import java.util.ArrayList;
import java.util.List;

@Data
@SuperBuilder
public class PrivilegeGroup {
private String groupName;
@Builder.Default
private List<Privilege> privileges = new ArrayList<>();
}
Loading
Loading