Skip to main content

Send Data to Oso Cloud as Context Facts

For Oso to make authorization decisions, it requires data from your application. Oso accepts data as facts — a lightweight format that complements logic written in Polar. You send facts to Oso Cloud along with an authorization request. Facts sent to Oso Cloud with this method are context facts. The syntax depends on which client SDK you use. In the TypeScript SDK, context facts are passed as an optional 4th argument to the oso.authorize call.
src/authz.ts
Code defining context facts build an array of up to three facts.
  • A fact declaring the relationship between the Repository and its parent Organization
  • [Optional] A fact declaring the User’s role in the Organization
  • [Optional] A fact declaring the User’s role on the Repository
The array is passed as the fourth argument to .authorize().
Now the results from Oso Cloud are the same as the results from the original code.
Learn more about the limitations of facts in the primitive types section of our documentation. Context facts provide your authorization data to Oso Cloud conveniently. You send it whenever you make a authorization request. However, over time this generates additional network traffic as you make more requests. Much of that traffic is unnecessary, because these data do not change frequently. Local Authorization informs the Oso Cloud client how to translate data from your application database directly into facts to make an authorization decision. Learn to set that up next.