Skip to content
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

fix: context is not a required field of a RelationshipCondition #120

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/openapiv2/apidocs.swagger.json

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

49 changes: 37 additions & 12 deletions openfga/v1/authzmodel.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import "validate/validate.proto";
message AuthorizationModel {
string id = 1 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {pattern: "^[ABCDEFGHJKMNPQRSTVWXYZ0-9]{26}$", ignore_empty: false},
(validate.rules).string = {
pattern: "^[ABCDEFGHJKMNPQRSTVWXYZ0-9]{26}$",
ignore_empty: false
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"01G5JAVJ41T49E9TT3SKVS7X1J\""}
];

string schema_version = 2 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {pattern: "^[1-9].[1-9]$", ignore_empty: false},
(validate.rules).string = {
pattern: "^[1-9].[1-9]$",
ignore_empty: false
},
json_name = "schema_version"
];

Expand All @@ -28,13 +34,19 @@ message AuthorizationModel {
map<string, Condition> conditions = 4 [
json_name = "conditions",
(validate.rules).map.max_pairs = 25,
(validate.rules).map.keys.string = {pattern: "^[^:#@\\s]{1,50}$", ignore_empty: false}
(validate.rules).map.keys.string = {
pattern: "^[^:#@\\s]{1,50}$",
ignore_empty: false
}
];
}

message TypeDefinition {
string type = 1 [
(validate.rules).string = {pattern: "^[^:#@\\s]{1,254}$", ignore_empty: false},
(validate.rules).string = {
pattern: "^[^:#@\\s]{1,254}$",
ignore_empty: false
},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"document\""}
];
Expand All @@ -49,7 +61,10 @@ message TypeDefinition {
}

message Relation {
string name = 1 [(validate.rules).string = {pattern: "^[^:#@\\s]{1,50}$", ignore_empty: false}];
string name = 1 [(validate.rules).string = {
pattern: "^[^:#@\\s]{1,50}$",
ignore_empty: false
}];

Userset rewrite = 2 [
(validate.rules).message.required = true,
Expand All @@ -74,7 +89,10 @@ message RelationMetadata {
// RelationReference represents a relation of a particular object type (e.g. 'document#viewer').
message RelationReference {
string type = 1 [
(validate.rules).string = {pattern: "^[^:#@\\s]{1,254}$", ignore_empty: false},
(validate.rules).string = {
pattern: "^[^:#@\\s]{1,254}$",
ignore_empty: false
},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"group\""}
];
Expand All @@ -98,9 +116,7 @@ message RelationReference {
message Wildcard {}

message Usersets {
repeated Userset child = 1 [
(google.api.field_behavior) = REQUIRED
];
repeated Userset child = 1 [(google.api.field_behavior) = REQUIRED];
}

message Difference {
Expand Down Expand Up @@ -138,7 +154,10 @@ message ObjectRelation {
message ComputedUserset {
string relation = 1 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {max_bytes: 50, ignore_empty: false}
(validate.rules).string = {
max_bytes: 50,
ignore_empty: false
}
];
}

Expand All @@ -158,13 +177,19 @@ message Condition {
// A unique name for the condition
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {pattern: "^[^:#@\\s]{1,50}$", ignore_empty: false}
(validate.rules).string = {
pattern: "^[^:#@\\s]{1,50}$",
ignore_empty: false
}
];

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

// A map of parameter names to the parameter's defined type reference.
Expand Down
37 changes: 20 additions & 17 deletions openfga/v1/openfga.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@ import "validate/validate.proto";
// See https://openfga.dev/docs/concepts#what-is-an-object
message Object {
string type = 1 [
(validate.rules).string = {pattern: "^[^:#@\\s]{1,254}$", ignore_empty: false},
(validate.rules).string = {
pattern: "^[^:#@\\s]{1,254}$",
ignore_empty: false
},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"document\""}
];

string id = 2 [
(validate.rules).string = {pattern: "[^#:\\s]+$", ignore_empty: false},
(validate.rules).string = {
pattern: "[^#:\\s]+$",
ignore_empty: false
},
(google.api.field_behavior) = REQUIRED
];
}

message RelationshipCondition {
// A reference (by name) of the relationship condition defined in the authorization model.
string name = 1 [
(validate.rules).string = {pattern: "^[^\\s]{2,256}$", ignore_empty: false},
(validate.rules).string = {
pattern: "^[^\\s]{2,256}$",
ignore_empty: false
},
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
max_length: 256,
Expand All @@ -40,10 +49,7 @@ message RelationshipCondition {
// Additional context/data to persist along with the condition.
// The keys must match the parameters defined by the condition, and the value types must
// match the parameter type definitions.
google.protobuf.Struct context = 2 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).message.required = true
];
google.protobuf.Struct context = 2;
}

message TupleKeyWithoutCondition {
Expand Down Expand Up @@ -84,7 +90,10 @@ message TupleKeyWithoutCondition {
message TupleKey {
string user = 1 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {max_bytes: 512, ignore_empty: false},
(validate.rules).string = {
max_bytes: 512,
ignore_empty: false
},
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
max_length: 512,
example: "\"user:anne\""
Expand Down Expand Up @@ -162,15 +171,11 @@ message UsersetTree {
}

message Nodes {
repeated Node nodes = 1 [
(google.api.field_behavior) = REQUIRED
];
repeated Node nodes = 1 [(google.api.field_behavior) = REQUIRED];
}

message Users {
repeated string users = 1 [
(google.api.field_behavior) = REQUIRED
];
repeated string users = 1 [(google.api.field_behavior) = REQUIRED];
}

message Computed {
Expand All @@ -185,9 +190,7 @@ message UsersetTree {
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {ignore_empty: false}
];
repeated Computed computed = 2 [
(google.api.field_behavior) = REQUIRED
];
repeated Computed computed = 2 [(google.api.field_behavior) = REQUIRED];
}

message Difference {
Expand Down
Loading
Loading