api
api copied to clipboard
feat: initial OpenFGA `v2beta1` protobuf API development
Description
Start the development branch for the v2beta1
protobuf API definitions for OpenFGA. This is to get things started with that new API development effort as we go into the new year.
As we work through these changes in the scope of this PR, lets try to focus on a few guiding principles:
-
Well typed and strongly typed protobuf API contract - prefer objects over string encoded entities where you can (e.g.
Object
instead ofstring object
) -
Separation of input types vs output types and a clear definition of required vs non-required fields within them- this really helps other development in our tooling such as in the SDKs etc..
-
Think about the gRPC experience, not just the HTTP mapping - the protobuf API is the definitive source of truth. The HTTP API is derived off of it. When in doubt, the protobuf API should take precedence.
-
Give a shit about naming things - if you've had a beef with the API names, speak up and fight for the cause 😄
-
Encourage strong alignment with
buf lint
lint style guidelines so that we have a standard - we shouldn't have to make exceptions regularly for our protobuf API linting behavior. Stick to the community standard of usingbuf lint
and the default rules for it. -
Consider Google API Improvement Proposals (AIPs) as a good starting point for inspiration behind certain API changes and design - we don't have to copy Google API guidelines, but they've clearly given a lot of API experience some thought and since they are the primary driving force behind gRPC and RPC APIs in general, their guidelines are a good reference point for ideas of achieving certain design goals. In particular, consider the AIPs around standard methods.
A few notable changes to get started:
-
The new API has been designed with an emphasis on a strongly typed protobuf API. For example, instead of
string object
fields we have explicitObject object
fields. -
User
fields have been renamed toSubject
to avoid confusion with the often defined type nameuser
.Subject
is a strongly typed entity that can be one_ofObject
(a direct object),TypedWildcard
(to represent the public wildcard), or aSubjectSet
(to represent the set of subjects that expand to one or more concrete objects). ASubjectSet
models Usersets in Zanzibar nomenclature. -
TupleKey
has been more aptly namedRelationshipTuple
- this coincides with our official documentation Concepts better (see Relationship Tuple) -
Userset
, which previously represented a relation rewrite rule, has been refactored to a more aptly namedRelationRewrite
and the model of it is much more uniform. -
The relations defined in an AuthorizationModel has changed from a direct
Userset rewrite
field to a map of Relation structuresmap<string, Relation>
. This will make things more uniform by far in all application code that deals with an AuthorizationModel structure and will more easily allow for indexing into the model's relation map to grab a particular relation. -
Relation
now uniformly represents a relation definition, and the constructs associated with it such as the type restrictions that apply to it etc.. -
The
ReadChanges
API has been renamed toWatchChanges
and has been relocated to an auxillary gRPC service definitionWatchService
. This will allow for a separate watch server to implement the WatchService and allow that service to be hosted and scaled independently of the mainOpenFGAService
which services Checks, ListObjects, etc.. The ability to serve and scale this service independently will be more important especially as we start building other features around changelog metadata such as the indexer andExpandedWatchChanges
endpoints etc.. These workloads will be different and need not be served from the same server in general..
References
Review Checklist
- [ ] I have clicked on "allow edits by maintainers".
- [ ] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
- [ ] The correct base branch is being used, if not
main
- [ ] I have added tests to validate that the change in functionality is working as expected
- [ ] todo: add protobuf doc to every protobuf message and field as appropriate.
- [ ] todo: add required field specifications and other protobuf annotations for OpenAPI generation