Skip to content

Commit

Permalink
proposed validation as starting point
Browse files Browse the repository at this point in the history
  • Loading branch information
jpadilla committed Aug 25, 2023
1 parent 02af021 commit 6747b2c
Show file tree
Hide file tree
Showing 7 changed files with 1,746 additions and 1,560 deletions.
5 changes: 4 additions & 1 deletion docs/openapiv2/apidocs.swagger.json

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

32 changes: 27 additions & 5 deletions openfga/v1/authzmodel.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ message AuthorizationModel {
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "[{\"type\": \"user\"}, {\"type\":\"document\",\"relations\":{\"reader\":{\"union\":{\"child\":[{\"this\":{}},{\"computedUserset\":{\"object\":\"\",\"relation\":\"writer\"}}]}},\"writer\":{\"this\":{}}},\"metadata\":{\"relations\":{\"reader\":{\"directly_related_user_types\":[{\"type\":\"user\"}]},\"writer\":{\"directly_related_user_types\":[{\"type\":\"user\"}]}}}}]"}
];

map<string, Condition> conditions = 4 [json_name = "conditions"];
map<string, Condition> conditions = 4 [
json_name = "conditions",
(validate.rules).map.max_pairs = 100,
(validate.rules).map.keys.string = {
pattern: "^[a-zA-Z0-9]{1,25}$",
min_len: 1,
max_len: 25,
}
];
}

message TypeDefinition {
Expand Down Expand Up @@ -134,13 +142,27 @@ message TupleToUserset {

message Condition {
// A unique name for the condition
string name = 1;
string name = 1 [(validate.rules).string = {
pattern: "^[a-zA-Z0-9]{1,25}$",
min_len: 1,
max_len: 25
}];

// A Google CEL expression, expressed as a string.
string expression = 2;
string expression = 2 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {max_bytes: 5120}
];

// A map of parameter names to the parameter's defined type reference.
map<string, ConditionParamTypeRef> parameters = 3;
map<string, ConditionParamTypeRef> parameters = 3 [
(validate.rules).map.max_pairs = 25,
(validate.rules).map.keys.string = {
pattern: "^[a-zA-Z0-9]{1,25}$",
min_len: 1,
max_len: 25
}
];
}

message ConditionParamTypeRef {
Expand All @@ -160,5 +182,5 @@ message ConditionParamTypeRef {

TypeName type_name = 1 [(validate.rules).enum.defined_only = true];

repeated ConditionParamTypeRef generic_types = 2;
repeated ConditionParamTypeRef generic_types = 2 [(validate.rules).repeated.max_items = 5];
}
10 changes: 9 additions & 1 deletion openfga/v1/openfga_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,15 @@ message WriteAuthorizationModelRequest {
}
];

map<string, openfga.v1.Condition> conditions = 4 [json_name = "conditions"];
map<string, openfga.v1.Condition> conditions = 4 [
json_name = "conditions",
(validate.rules).map.max_pairs = 100,
(validate.rules).map.keys.string = {
pattern: "^[a-zA-Z0-9]{1,25}$",
min_len: 1,
max_len: 25
}
];
}

message WriteAuthorizationModelResponse {
Expand Down
389 changes: 199 additions & 190 deletions proto/openfga/v1/authzmodel.pb.go

Large diffs are not rendered by default.

116 changes: 112 additions & 4 deletions proto/openfga/v1/authzmodel.pb.validate.go

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

Loading

0 comments on commit 6747b2c

Please sign in to comment.