- A configuration file that maps your facts to SQL queries
- Use the Local Authorization API in your application code
Write the configuration file
You configure Local Authorization with a yaml file passed to the Oso Cloud client on instantiation. This configuration file lists the fact signatures used for your authorization queries. It also associates them with the SQL that generates the facts from your application data. Recall that you send up to three context facts to Oso for any “read repository” authorization request:local_authorization_config.yaml
- Any value returned by the query is represented in the fact signature by using the wildcard character (
_
). - Any value not returned from a query must be explicitly specified in the fact signature by its type and value (e.g.
String:parent
). - The
sql_types:
section is optional, but strongly recommended.
Use the Local Authorization API
You provide this configuration file to the Oso Cloud client when you instantiate it. Then you use the Local Authorization API to make authorization decisions without passing data to Oso Cloud. In the Typescript SDK, you useauthorizeLocal
in place of authorize
.
backend/src/authz.ts
- The
osoClient
instantiation is modified to include thelocal_authorization_config.yaml
file. - The call to
authorize()
is replaced with a call toauthorizeLocal()
- The query returned from
authorizeLocal()
is executed against the database to resolve the authorization request
canReadRepo()
function is smaller. This is because we do not need code in that function
to get role data and convert it to facts. It is handled by the query returned from authorizeLocal()
now.
You can write the query that
authorizeLocal()
returns to a log if you’d like
to inspect it.