Adding Data to Oso Cloud
Oso Cloud stores facts to represent authorization-relevant data in your app. To add and update facts stored in Oso Cloud, your applications can write facts using the API.
Clients
Add facts to Oso Cloud using the tell
method:
oso-cloud tell has_role User:bob owner Organization:acme
If you need to add multiple facts at once, you can use the corresponding bulk_tell
method in every client (bulk_tell
is not currently available in the CLI):
await oso.bulkTell([
["has_role", {type: "User", id: "bob"}, "owner", {type: "Organization", id: "acme"}],
["has_relation", {type: "Repository", id: "anvil"}, "parent", {type: "Organization", id: "acme"}]
]);
The bulk_tell
method is more than just a convenient way of avoiding a for-loop, it also writes the full set of facts simultaneously. This is useful if you need to write a set of related facts and want to ensure that no authorize
requests are made using only a subset of those facts.
In the dashboard
You can also add facts from the Data page (opens in a new tab) of the dashboard by clicking "Add" on the type of fact you want to add.
Fact Syntax
Facts are represented slightly differently depending on which of the above methods you are using.
If we wanted to add the fact has_role(User:bob, String:owner, Organization:acme)
with the cli or on the dashboard, we'd represent it with spaces as:
has_role User:bob "owner" Organization:acme
.
For convenience and safety, the tell
methods in Oso Cloud clients take language objects rather than strings. The details are different
depending on the client. You can refer to the examples on this or check out the docs for your client for more detail.
Talk to an Oso Engineer
If you'd like to learn more about using Oso Cloud in your app or have any questions about this guide, connect with us on Slack. We're happy to help.