Skip to content

Commit

Permalink
Promote BulkCheckPermission to v1
Browse files Browse the repository at this point in the history
The 'BulkCheckPermission' API is stable and can be promoted into
the v1 'PermissionsService'.
  • Loading branch information
alecmerdler committed Feb 14, 2024
1 parent 1485497 commit d091615
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 7 deletions.
13 changes: 6 additions & 7 deletions authzed/api/v1/experimental_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ service ExperimentalService {
}

rpc BulkCheckPermission(BulkCheckPermissionRequest)
returns (BulkCheckPermissionResponse) {
option (google.api.http) = {
post: "/v1/experimental/permissions/bulkcheckpermission"
body: "*"
};
}
returns (BulkCheckPermissionResponse) {
option (google.api.http) = {
post: "/v1/experimental/permissions/bulkcheckpermission"
body: "*"
};
}
}

message BulkCheckPermissionRequest {
Expand Down Expand Up @@ -87,7 +87,6 @@ message BulkCheckPermissionPair {
}

message BulkCheckPermissionResponseItem {

CheckPermissionResponse.Permissionship permissionship = 1 [ (validate.rules).enum = {defined_only: true, not_in: [0]} ];

PartialCaveatInfo partial_caveat_info = 2 [ (validate.rules).message.required = false ];
Expand Down
51 changes: 51 additions & 0 deletions authzed/api/v1/permission_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option java_package = "com.authzed.api.v1";

import "google/protobuf/struct.proto";
import "google/api/annotations.proto";
import "google/rpc/status.proto";
import "validate/validate.proto";

import "authzed/api/v1/core.proto";
Expand Down Expand Up @@ -56,6 +57,16 @@ service PermissionsService {
};
}

// CheckPermissionsBulk evaluates the given list of permission checks
// and returns the list of results.
rpc CheckPermissionsBulk(CheckPermissionsBulkRequest)
returns (CheckPermissionsBulkResponse) {
option (google.api.http) = {
post: "/v1/permissions/checkpermissionsbulk"
body: "*"
};
}

// ExpandPermissionTree reveals the graph structure for a resource's
// permission or relation. This RPC does not recurse infinitely deep and may
// require multiple calls to fully unnest a deeply nested graph.
Expand Down Expand Up @@ -349,6 +360,46 @@ message CheckPermissionResponse {
PartialCaveatInfo partial_caveat_info = 3 [ (validate.rules).message.required = false ];
}


message CheckPermissionsBulkRequest {
Consistency consistency = 1;

repeated CheckPermissionsBulkRequestItem items = 2 [ (validate.rules).repeated .items.message.required = true ];
}

message CheckPermissionsBulkRequestItem {
ObjectReference resource = 1 [ (validate.rules).message.required = true ];

string permission = 2 [ (validate.rules).string = {
pattern : "^([a-z][a-z0-9_]{1,62}[a-z0-9])?$",
max_bytes : 64,
} ];

SubjectReference subject = 3 [ (validate.rules).message.required = true ];

google.protobuf.Struct context = 4 [ (validate.rules).message.required = false ];
}

message CheckPermissionsBulkResponse {
ZedToken checked_at = 1 [ (validate.rules).message.required = false ];

repeated CheckPermissionsBulkPair pairs = 2 [ (validate.rules).repeated .items.message.required = true ];
}

message CheckPermissionsBulkPair {
CheckPermissionsBulkRequestItem request = 1;
oneof response {
CheckPermissionsBulkResponseItem item = 2;
google.rpc.Status error = 3;
}
}

message CheckPermissionsBulkResponseItem {
CheckPermissionResponse.Permissionship permissionship = 1 [ (validate.rules).enum = {defined_only: true, not_in: [0]} ];

PartialCaveatInfo partial_caveat_info = 2 [ (validate.rules).message.required = false ];
}

// ExpandPermissionTreeRequest returns a tree representing the expansion of all
// relationships found accessible from a permission or relation on a particular
// resource.
Expand Down

0 comments on commit d091615

Please sign in to comment.