Grant management added to Roles API and SDK (#185)
* Adding grants related methods to Roles. * Adding grants back after the merge of Principals. * Adding tests for Grant related custom methods. * Improving api handler methods. * Fixing tests and sdk field. * Adding todos for adding principals and grants to List and Update Role responses. * Fix up Set* tests and fix SetPrincipals bug. * Making AddPrincipals and RemovePrincipals similar to the tests for AddGrants and RemoveGrants. * Add JSON grants to output (#187) I also changed canonical_grants to grants_canonical and used grants_json. I believe that when members are simply different formats of other members this is the preferred way to have it in the API. Let me know if you disagree and we can dig in more. * Regenerate the API role resource. Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
This commit is contained in:
1 parent
260703febe
commit
847ca1cc78
19 files changed
+3321
-732
No files matched your search
@@ -51,4 +51,12 @@ message Role {
|
||||
// The grants that this role provides for it's principals.
|
||||
// Output only.
|
||||
repeated string grants = 11;
|
||||
|
||||
// The canonical version of the grants in the grants field with the same index.
|
||||
// Output only.
|
||||
repeated string grants_canonical = 12;
|
||||
|
||||
// The JSON version of the grants in the grants field with the same index.
|
||||
// Output only.
|
||||
repeated string grants_json = 13;
|
||||
}
|
||||
@@ -169,6 +169,69 @@ service RoleService {
|
||||
summary: "Removes the specified Users and/or Groups from a Role."
|
||||
};
|
||||
}
|
||||
|
||||
// AddRoleGrants adds grants to a role. The provided request must include
|
||||
// the org id and the role id which the grants will be added to. If the
|
||||
// org id is missing, malformed or references a non existing organization,
|
||||
// an error is returned. It is not an error to have duplicate grants.
|
||||
rpc AddRoleGrants(AddRoleGrantsRequest) returns (AddRoleGrantsResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/orgs/{org_id}/roles/{role_id}:add-grants"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
additional_bindings {
|
||||
post: "/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:add-grants"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
}
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Adds grants to a role"
|
||||
};
|
||||
}
|
||||
|
||||
// SetRoleGrants sets the role's grants. Any existing grants on the role are
|
||||
// deleted if they are not included in this request. The provided request must
|
||||
// include the org id and the role id which the grants will be set to. If the
|
||||
// org id is missing, malformed or references a non existing organization, an
|
||||
// error is returned. It is not an error to have duplicate grants.
|
||||
rpc SetRoleGrants(SetRoleGrantsRequest) returns (SetRoleGrantsResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/orgs/{org_id}/roles/{role_id}:set-grants"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
additional_bindings {
|
||||
post: "/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:set-grants"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
}
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Set grants for a role, removing any grants that are not specified in the request."
|
||||
};
|
||||
}
|
||||
|
||||
// RemoveRoleGrants removes the users and/or groups from the specified role.
|
||||
// The provided request must include the org id and the role id which the users
|
||||
// and/or groups will be removed from. If the org id is missing, malformed or references a non
|
||||
// existing organization, an error is returned. It is not an error to have duplicate
|
||||
// user/group ids.
|
||||
rpc RemoveRoleGrants(RemoveRoleGrantsRequest) returns (RemoveRoleGrantsResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/v1/orgs/{org_id}/roles/{role_id}:remove-grants"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
additional_bindings {
|
||||
post: "/v1/orgs/{org_id}/projects/{project_id}/roles/{role_id}:remove-grants"
|
||||
body: "*"
|
||||
response_body: "item"
|
||||
}
|
||||
};
|
||||
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
|
||||
summary: "Removes grants from a role."
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
message GetRoleRequest {
|
||||
@@ -269,4 +332,46 @@ message RemoveRolePrincipalsRequest {
|
||||
|
||||
message RemoveRolePrincipalsResponse {
|
||||
resources.roles.v1.Role item = 1;
|
||||
}
|
||||
|
||||
message AddRoleGrantsRequest {
|
||||
string org_id = 1;
|
||||
string project_id = 2;
|
||||
string role_id = 3;
|
||||
// The version ensures the role hasn't changed since it was last retrieved and if
|
||||
// it has the request will fail.
|
||||
google.protobuf.UInt32Value version = 4;
|
||||
repeated string grants = 5 [json_name="grants"];
|
||||
}
|
||||
|
||||
message AddRoleGrantsResponse {
|
||||
resources.roles.v1.Role item = 1;
|
||||
}
|
||||
|
||||
message SetRoleGrantsRequest {
|
||||
string org_id = 1;
|
||||
string project_id = 2;
|
||||
string role_id = 3;
|
||||
// The version ensures the role hasn't changed since it was last retrieved and if
|
||||
// it has the request will fail.
|
||||
google.protobuf.UInt32Value version = 4;
|
||||
repeated string grants = 5 [json_name="grants"];
|
||||
}
|
||||
|
||||
message SetRoleGrantsResponse {
|
||||
resources.roles.v1.Role item = 1;
|
||||
}
|
||||
|
||||
message RemoveRoleGrantsRequest {
|
||||
string org_id = 1;
|
||||
string project_id = 2;
|
||||
string role_id = 3;
|
||||
// The version ensures the role hasn't changed since it was last retrieved and if
|
||||
// it has the request will fail.
|
||||
google.protobuf.UInt32Value version = 4;
|
||||
repeated string grants = 5 [json_name="grants"];
|
||||
}
|
||||
|
||||
message RemoveRoleGrantsResponse {
|
||||
resources.roles.v1.Role item = 1;
|
||||
}
|
||||
Reference in new issue
Block a user