Skip to content

Commit

Permalink
Add http endpoint to list permissions (#5571)
Browse files Browse the repository at this point in the history
* Add http endpoint to list permissions

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* extract handler registration

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* use generated protobuf

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update permissions mock in graph service

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add unit test

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* return correct userid

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* assert error message type in tests

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

---------

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Feb 15, 2023
1 parent cde6158 commit 92923f6
Show file tree
Hide file tree
Showing 9 changed files with 743 additions and 265 deletions.
654 changes: 397 additions & 257 deletions protogen/gen/ocis/services/settings/v0/settings.pb.go

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions protogen/gen/ocis/services/settings/v0/settings.pb.micro.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 99 additions & 0 deletions protogen/gen/ocis/services/settings/v0/settings.pb.web.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions protogen/gen/ocis/services/settings/v0/settings.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,38 @@
]
}
},
"/api/v0/settings/permissions-list": {
"post": {
"operationId": "PermissionService_ListPermissions",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v0ListPermissionsResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v0ListPermissionsRequest"
}
}
],
"tags": [
"PermissionService"
]
}
},
"/api/v0/settings/permissions-list-by-resource": {
"post": {
"operationId": "PermissionService_ListPermissionsByResource",
Expand Down Expand Up @@ -857,6 +889,25 @@
}
}
},
"v0ListPermissionsRequest": {
"type": "object",
"properties": {
"accountUuid": {
"type": "string"
}
}
},
"v0ListPermissionsResponse": {
"type": "object",
"properties": {
"permissions": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"v0ListRoleAssignmentsRequest": {
"type": "object",
"properties": {
Expand Down
14 changes: 14 additions & 0 deletions protogen/proto/ocis/services/settings/v0/settings.proto
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ service RoleService {
}

service PermissionService {
rpc ListPermissions(ListPermissionsRequest) returns (ListPermissionsResponse) {
option (google.api.http) = {
post: "/api/v0/settings/permissions-list",
body: "*"
};
}
rpc ListPermissionsByResource(ListPermissionsByResourceRequest) returns (ListPermissionsByResourceResponse) {
option (google.api.http) = {
post: "/api/v0/settings/permissions-list-by-resource",
Expand Down Expand Up @@ -240,6 +246,14 @@ message RemoveRoleFromUserRequest {
// requests and responses for permissions
// ---

message ListPermissionsRequest {
string account_uuid = 1;
}

message ListPermissionsResponse {
repeated string permissions = 1;
}

message ListPermissionsByResourceRequest {
ocis.messages.settings.v0.Resource resource = 1;
}
Expand Down
30 changes: 30 additions & 0 deletions services/graph/mocks/permissions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions services/graph/pkg/service/v0/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Publisher interface {

// Permissions is the interface used to access the permissions service
type Permissions interface {
ListPermissions(ctx context.Context, req *settingssvc.ListPermissionsRequest, opts ...client.CallOption) (*settingssvc.ListPermissionsResponse, error)
GetPermissionByID(ctx context.Context, request *settingssvc.GetPermissionByIDRequest, opts ...client.CallOption) (*settingssvc.GetPermissionByIDResponse, error)
ListPermissionsByResource(ctx context.Context, in *settingssvc.ListPermissionsByResourceRequest, opts ...client.CallOption) (*settingssvc.ListPermissionsByResourceResponse, error)
}
Expand Down
Loading

0 comments on commit 92923f6

Please sign in to comment.