Oso
Use Oso and its Polar policies for MainSDK access - setup, main.yaml, testing, limits and swapping.
Oso is an authorization service that models roles, relationships and attributes in its Polar policy language. Behind access, your Oso policies decide and MainSDK adds typed checks, fail-closed behaviour and audit. Pick it when your team already models permissions in Oso.
Interfaces it serves
Pick Oso in main.yaml for any of these. Your calls stay the same, and you can swap later.
accessBuilding for 0.3Driver oso Oso
access:
driver: osoSwap to another provider
Before you start
- Set up Oso for your app and write your policy.
- Create an API key for each environment and keep it in your secrets manager.
Configure
access:
driver: oso
models: [rbac, rebac]
unreachable: { deny: true, cache: 30s }
# [to be decided] connection keys; suggested secret: OSO_API_KEYUse it
import { access } from "mainsdk";
const decision = await access.check({ subject: user, action: "repos.write", resource: repo });
if (!decision.allow) throw new Error("forbidden");Local development and testing
Build on in-process Cedar with mainsdk dev. createTestApp() from @mainsdk/testing puts access on its fake, and chaos.on("access", { outage: true }) shows checks denying with MAIN-ACCESS-0007.
What MainSDK adds on top
- Deny by default, with no bypass path.
- Denies when Oso is unreachable, with only a short cache you set.
- Lists filtered at the database, not after fetching rows.
- Every decision written to the audit log with the policy version.
See Permissions.
Limits and notes
- The
accessspec lists Oso as a driver that comes later in phases 1-2 through the driver kit, beyond its capability profile. - Which models the driver supports is declared in its capability profile;
mainsdk checknames any gap withMAIN-ACCESS-0004. access.raw()returns the Oso client;mainsdk checklists every use.
Swap to or from it
access:
driver: cedar # was osoFAQ
Do I rewrite my Polar policy? Not to adopt the driver. Only if you later move to another engine.
Next
Was this page helpful?