Skip to content

Commit 328b1ec

Browse files
authored
feat(frontier): check permission for specific principal (#320)
Signed-off-by: Kush Sharma <[email protected]>
1 parent 7fb61c3 commit 328b1ec

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

raystack/frontier/v1beta1/admin.proto

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,32 @@ service AdminService {
280280
description: "Create new platform preferences. The platform preferences **name** must be unique within the platform and can contain only alphanumeric characters, dashes and underscores.";
281281
};
282282
}
283+
284+
// Check
285+
rpc CheckFederatedResourcePermission(CheckFederatedResourcePermissionRequest) returns (CheckFederatedResourcePermissionResponse) {
286+
option (google.api.http) = {
287+
post: "/v1beta1/admin/check",
288+
body: "*"
289+
};
290+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
291+
tags: "Authz";
292+
summary: "Check";
293+
description: "Returns true if a principal has required permissions to access a resource and false otherwise.<br/> Note the principal can be a user, group or a service account.";
294+
};
295+
}
296+
297+
// Platform
298+
rpc AddPlatformUser(AddPlatformUserRequest) returns (AddPlatformUserResponse) {
299+
option (google.api.http) = {
300+
post: "/v1beta1/admin/platform/users",
301+
body: "*"
302+
};
303+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
304+
tags: "Platform";
305+
summary: "Add platform user";
306+
description: "Adds a user to a platform.";
307+
};
308+
}
283309
}
284310

285311
message ListAllUsersRequest {
@@ -453,4 +479,40 @@ message CreatePreferencesRequest {
453479

454480
message CreatePreferencesResponse {
455481
repeated Preference preference = 1;
456-
}
482+
}
483+
484+
message CheckFederatedResourcePermissionRequest {
485+
string subject = 1 [
486+
(google.api.field_behavior) = REQUIRED,
487+
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "the subject to check. <br/> *Example:* `user:..uuidofuser..`"}
488+
];
489+
string resource = 2 [
490+
(google.api.field_behavior) = REQUIRED,
491+
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "`namespace:uuid` or `namespace:name` of the org or project, and `namespace:urn` of a resource under a project. In case of an org/project either provide the complete namespace (app/organization) or Frontier can also parse aliases for the same as `org` or `project`. <br/> *Example:* `organization:92f69c3a-334b-4f25-90b8-4d4f3be6b825` or `app/project:project-name` or `compute/instance:92f69c3a-334b-4f25-90b8-4d4f3be6b825`"}
492+
];
493+
string permission = 3 [
494+
(google.api.field_behavior) = REQUIRED,
495+
(validate.rules).string.pattern = "^[A-Za-z0-9._-]+$",
496+
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "the permission name to check. <br/> *Example:* `get`, `list`, `compute.instance.create`"}
497+
];
498+
}
499+
500+
message CheckFederatedResourcePermissionResponse {
501+
bool status = 1;
502+
}
503+
504+
message AddPlatformUserRequest {
505+
string user_id = 1 [
506+
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "The user id to add to the platform."}
507+
];
508+
string serviceuser_id = 2 [
509+
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "The service user id to add to the platform."}
510+
];
511+
512+
string relation = 3 [
513+
(google.api.field_behavior) = REQUIRED,
514+
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {description: "The relation to add as in the platform. It can be admin or member."}
515+
];
516+
}
517+
518+
message AddPlatformUserResponse {}

raystack/frontier/v1beta1/frontier.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ service FrontierService {
10781078
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
10791079
tags: "Authz";
10801080
summary: "Check";
1081-
description: "Returns true if a principal has required permissions to access a resource and false otherwise.<br/> Note the principal can be a user or a service account, and Frontier will the credentials from the current logged in principal from the session cookie (if any), or the client id and secret (in case of service users) or the access token (in case of human user accounts).";
1081+
description: "Returns true if a principal has required permissions to access a resource and false otherwise.<br/> Note the principal can be a user or a service account. Frontier will extract principal from the current logged in session cookie (if any), or the client id and secret (in case of service users) or the access token.";
10821082
};
10831083
}
10841084

0 commit comments

Comments
 (0)