Skip to content

Commit

Permalink
fix: add regex for read api user field (#218)
Browse files Browse the repository at this point in the history
Add regex to assert that read API's user field (if specified) must
have both type and object.

Close openfga/openfga#2189
  • Loading branch information
adriantam authored Jan 7, 2025
1 parent 205c0f0 commit c22e6db
Show file tree
Hide file tree
Showing 4 changed files with 1,746 additions and 1,717 deletions.
2 changes: 1 addition & 1 deletion docs/openapiv2/apidocs.swagger.json

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

9 changes: 7 additions & 2 deletions openfga/v1/openfga_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ service OpenFGAService {
"1. `tuple_key` is optional. If not specified, it will return all tuples in the store.\n"
"2. `tuple_key.object` is mandatory if `tuple_key` is specified. It can be a full object (e.g., "
"`type:object_id`) or type only (e.g., `type:`).\n"
"3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only.\n"
"3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. "
"If tuple_key.user is specified, it needs to be a full object (e.g., `type:user_id`).\n"
"## Examples\n"
"### Query for all objects in a type definition\n"
"To query for all objects that `user:bob` has `reader` relationship in "
Expand Down Expand Up @@ -1190,7 +1191,11 @@ message ReadRequest {

message ReadRequestTupleKey {
string user = 1 [
(validate.rules).string = {max_bytes: 512},
(validate.rules).string = {
pattern: "^[^\\s]{1,511}:[^\\s]{1,511}$"
ignore_empty: true
max_bytes: 512
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
max_length: 512
example: "\"user:anne\""
Expand Down
Loading

0 comments on commit c22e6db

Please sign in to comment.