-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add authorization proto #29
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| syntax = "proto3"; | ||
|
|
||
| package agynio.api.authorization.v1; | ||
|
|
||
| import "google/protobuf/timestamp.proto"; | ||
|
|
||
| option go_package = "github.com/agynio/api/gen/agynio/api/authorization/v1;authorizationv1"; | ||
|
|
||
| // AuthorizationService is a thin gRPC proxy to OpenFGA. | ||
| // It mirrors the OpenFGA runtime API and injects store/model IDs. | ||
| service AuthorizationService { | ||
| // Check tests whether a user has a specific relationship with an object. | ||
| rpc Check(CheckRequest) returns (CheckResponse); | ||
| // BatchCheck evaluates multiple authorization checks in a single call. | ||
| // Each check includes a correlation_id for matching results. | ||
| rpc BatchCheck(BatchCheckRequest) returns (BatchCheckResponse); | ||
| // Write creates or deletes relationship tuples in the store. | ||
| rpc Write(WriteRequest) returns (WriteResponse); | ||
| // Read retrieves relationship tuples matching a partial tuple filter. | ||
| rpc Read(ReadRequest) returns (ReadResponse); | ||
| // ListObjects returns all objects of a given type that a user has a | ||
| // specific relationship with. | ||
| rpc ListObjects(ListObjectsRequest) returns (ListObjectsResponse); | ||
| // ListUsers returns all users that have a specific relationship with an object. | ||
| rpc ListUsers(ListUsersRequest) returns (ListUsersResponse); | ||
| } | ||
|
|
||
| // =========================================================================== | ||
| // Common | ||
| // =========================================================================== | ||
|
|
||
| message TupleKey { | ||
| string user = 1; // e.g. "identity:user_abc" | ||
| string relation = 2; // e.g. "owner" | ||
| string object = 3; // e.g. "tenant:tenant_123" | ||
| } | ||
|
|
||
| message Tuple { | ||
| TupleKey key = 1; | ||
| google.protobuf.Timestamp timestamp = 2; | ||
| } | ||
|
|
||
| // =========================================================================== | ||
| // Check | ||
| // =========================================================================== | ||
|
|
||
| message CheckRequest { | ||
| TupleKey tuple_key = 1; | ||
| } | ||
|
|
||
| message CheckResponse { | ||
| bool allowed = 1; | ||
| } | ||
|
|
||
| // =========================================================================== | ||
| // BatchCheck | ||
| // =========================================================================== | ||
|
|
||
| message BatchCheckItem { | ||
| TupleKey tuple_key = 1; | ||
| string correlation_id = 2; | ||
| } | ||
|
|
||
| message BatchCheckRequest { | ||
| repeated BatchCheckItem checks = 1; | ||
| } | ||
|
|
||
| message BatchCheckResult { | ||
| bool allowed = 1; | ||
| string error = 2; | ||
| } | ||
|
|
||
| message BatchCheckResponse { | ||
| map<string, BatchCheckResult> results = 1; | ||
| } | ||
|
|
||
| // =========================================================================== | ||
| // Write | ||
| // =========================================================================== | ||
|
|
||
| message WriteRequest { | ||
| repeated TupleKey writes = 1; | ||
| repeated TupleKey deletes = 2; | ||
| } | ||
|
|
||
| message WriteResponse {} | ||
|
|
||
| // =========================================================================== | ||
| // Read | ||
| // =========================================================================== | ||
|
|
||
| message ReadRequest { | ||
| TupleKey tuple_key = 1; | ||
| int32 page_size = 2; | ||
| string page_token = 3; | ||
| } | ||
|
|
||
| message ReadResponse { | ||
| repeated Tuple tuples = 1; | ||
| string next_page_token = 2; | ||
| } | ||
|
|
||
| // =========================================================================== | ||
| // ListObjects | ||
| // =========================================================================== | ||
|
|
||
| message ListObjectsRequest { | ||
| string type = 1; // e.g. "tenant" | ||
| string relation = 2; // e.g. "member" | ||
| string user = 3; // e.g. "identity:user_abc" | ||
| } | ||
|
|
||
| message ListObjectsResponse { | ||
| repeated string objects = 1; // e.g. ["tenant:tenant_123"] | ||
| } | ||
|
|
||
| // =========================================================================== | ||
| // ListUsers | ||
| // =========================================================================== | ||
|
|
||
| message UserTypeFilter { | ||
| string type = 1; // e.g. "identity" | ||
| string relation = 2; // optional, for usersets | ||
| } | ||
|
|
||
| message ListUsersRequest { | ||
| string object = 1; // e.g. "tenant:tenant_123" | ||
| string relation = 2; // e.g. "member" | ||
| repeated UserTypeFilter user_filters = 3; // at least one required | ||
| } | ||
|
|
||
| message User { | ||
| oneof user { | ||
| string object = 1; // e.g. "identity:user_abc" | ||
| string wildcard = 2; // e.g. "identity:*" | ||
| } | ||
| } | ||
|
|
||
| message ListUsersResponse { | ||
| repeated User users = 1; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] The issue spec includes a short description for each RPC (e.g. "Can identity X perform relation Y on resource Z? Returns
allowed: bool"). Adding per-RPC doc comments would improve discoverability and is consistent with the pattern inchat.proto. Not blocking, but recommended.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added per-RPC doc comments in 2a70be0.