api
api copied to clipboard
refactor: change TypeDefinition signature to be more canonical
Today a TypeDefinition
has the following protobuf definition:
message TypeDefinition {
string type = 1;
map<string, Userset> relations = 2;
Metadata metadata = 3;
}
https://github.com/openfga/api/blob/main/openfga/v1/authzmodel.proto#L26
A more canonical and easier consume definition of a TypeDefinition would look like:
message TypeDefinition {
string type = 1;
map<string, Relation> relations = 2;
}
https://github.com/openfga/api/blob/main/openfga/v1/authzmodel.proto#L42
The only reason(s) why the metadata
field is needed today is because we did not want to break existing compatibility with the Userset
definition in the map<string, Userset>
and so we introduced an additional field. The Relation
definition itself should encapsulate all of the information/metadata associated with the relation. Doing so will allow the OpenFGA core and other integrations to more seemlessly make use of a TypeDefinition and the relations contained therein without having to reconstruct a map[string]Relation
all over the place in client code.
References: https://github.com/openfga/openfga/pull/726/files#r1189164147
Note that this will be a breaking change for the WriteAuthorizationModel
API