Skip to content

Commit

Permalink
feat: add support for modular models metadata (#141)
Browse files Browse the repository at this point in the history
* feat: add support for modular models metadata

* chore: refactor definitions based on feedback

* chore: improve regex for file field
  • Loading branch information
ewanharris authored Mar 18, 2024
1 parent cf9358a commit 66b9e5c
Show file tree
Hide file tree
Showing 7 changed files with 2,376 additions and 1,716 deletions.
36 changes: 35 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.

34 changes: 34 additions & 0 deletions openfga/v1/authzmodel.proto
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ message TypeDefinition {
];

// A map whose keys are the name of the relation and whose value is the Metadata for that relation.
// It also holds information around the module name and source file if this model was constructed
// from a modular model.
Metadata metadata = 3;
}

Expand All @@ -80,10 +82,31 @@ message RelationTypeInfo {

message Metadata {
map<string, RelationMetadata> relations = 1;

string module = 2 [(validate.rules).string = {
pattern: "^[^:#@\\s]{1,50}$",
ignore_empty: true
}];

SourceInfo source_info = 3 [json_name = "source_info"];
}

message SourceInfo {
string file = 1 [(validate.rules).string = {
pattern: "^[a-zA-Z0-9_\\-\\/]{1,100}\\.fga$",
ignore_empty: true
}];
}

message RelationMetadata {
repeated RelationReference directly_related_user_types = 1 [json_name = "directly_related_user_types"];

string module = 2 [(validate.rules).string = {
pattern: "^[^:#@\\s]{1,50}$",
ignore_empty: true
}];

SourceInfo source_info = 3 [json_name = "source_info"];
}

// RelationReference represents a relation of a particular object type (e.g. 'document#viewer').
Expand Down Expand Up @@ -200,6 +223,17 @@ message Condition {
(validate.rules).map.max_pairs = 25,
(validate.rules).map.keys.string = {pattern: "^[^:#@\\s]{1,50}$"}
];

ConditionMetadata metadata = 4;
}

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

SourceInfo source_info = 2 [json_name = "source_info"];
}

message ConditionParamTypeRef {
Expand Down
3 changes: 2 additions & 1 deletion openfga/v1/openfga_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,8 @@ message WriteAuthorizationModelRequest {
(validate.rules).string = {
in: [
"1.0",
"1.1"
"1.1",
"1.2"
],
ignore_empty: false
}
Expand Down
Loading

0 comments on commit 66b9e5c

Please sign in to comment.