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

feat: update definitions to support ABAC Conditions #90

Merged
merged 19 commits into from
Sep 14, 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: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/docs/openapiv2/apidocs.swagger.json linguist-generated=true
*.pb.go linguist-generated=true
*.pb.*.go linguist-generated=true
go.sum linguist-generated=true
buf.lock linguist-generated=true
1 change: 1 addition & 0 deletions .github/workflows/review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- main
- feat/abac

permissions:
contents: read
Expand Down
179 changes: 175 additions & 4 deletions docs/openapiv2/apidocs.swagger.json

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

53 changes: 53 additions & 0 deletions openfga/v1/authzmodel.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ message AuthorizationModel {
json_name = "type_definitions",
(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",
(validate.rules).map.max_pairs = 25,
(validate.rules).map.keys.string = {pattern: "^[^:#@\\s]{1,50}$"}
];
}

message TypeDefinition {
Expand Down Expand Up @@ -81,6 +87,9 @@ message RelationReference {

Wildcard wildcard = 3;
}

// The name of a condition that is enforced over the allowed relation.
string condition = 4;
}

message Wildcard {}
Expand Down Expand Up @@ -126,3 +135,47 @@ message TupleToUserset {
ObjectRelation tupleset = 1;
ObjectRelation computed_userset = 2;
}

message Condition {
// A unique name for the condition
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).string = {pattern: "^[^:#@\\s]{1,50}$"}
];

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

// A map of parameter names to the parameter's defined type reference.
map<string, ConditionParamTypeRef> parameters = 3 [
(validate.rules).map.max_pairs = 25,
(validate.rules).map.keys.string = {pattern: "^[^:#@\\s]{1,50}$"}
];
}

message ConditionParamTypeRef {
enum TypeName {
TYPE_NAME_UNSPECIFIED = 0;
TYPE_NAME_ANY = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're keeping any?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If in the future we'll introduce it, it makes sense to have it here so that we reserve the field number

TYPE_NAME_BOOL = 2;
TYPE_NAME_STRING = 3;
TYPE_NAME_INT = 4;
TYPE_NAME_UINT = 5;
TYPE_NAME_DOUBLE = 6;
TYPE_NAME_DURATION = 7;
TYPE_NAME_TIMESTAMP = 8;
TYPE_NAME_MAP = 9;
TYPE_NAME_LIST = 10;
TYPE_NAME_IPADDRESS = 11;
}

TypeName type_name = 1 [
(google.api.field_behavior) = REQUIRED,
(validate.rules).enum.defined_only = true
];

repeated ConditionParamTypeRef generic_types = 2 [(validate.rules).repeated.max_items = 5];
}
Loading
Loading