Skip to content

Commit ec8eafa

Browse files
committed
docs: update README
1 parent 8d74916 commit ec8eafa

File tree

1 file changed

+74
-28
lines changed

1 file changed

+74
-28
lines changed

README.md

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
[InferaDB](https://inferadb.com/) is a distributed, [Google Zanzibar](https://research.google/pubs/zanzibar-googles-consistent-global-authorization-system/)‑inspired authorization engine that replaces ad‑hoc database lookups and scattered logic with a unified, millisecond‑latency source of truth. With this SDK, you define permissions as policy‑as‑code and wire up a type‑safe client in just a few lines.
1515

16-
- **Rust‑Native & Async:** Fully integrated with the ecosystem (Tokio, Tracing) so you don't have to adapt generic policy engines to your runtime.
16+
- **Rust‑Native & Async:** Fully integrated with the ecosystem ([Tokio](https://crates.io/crates/tokio), [Tracing](https://crates.io/crates/tracing)) so you don't have to adapt generic policy engines to your runtime.
1717
- **Compile‑Time Safety:** Catch permission model mistakes in your build pipeline and tests, preventing surprises in production.
1818
- **Standards‑Based & Audit‑Ready:** Built on [AuthZen](https://openid.net/wg/authzen/) with automatic multi‑tenant isolation and cryptographically verifiable audit trails out of the box.
1919

@@ -60,21 +60,31 @@ let vault = org.vault("vlt_...");
6060

6161
### Permission Checks
6262

63+
#### Check a Permission
64+
6365
```rust
64-
// Simple check - returns bool
6566
let allowed = vault.check("user:alice", "view", "doc:1").await?;
67+
```
68+
69+
#### Check with ABAC Context
6670

67-
// With ABAC context
71+
```rust
6872
let allowed = vault.check("user:alice", "view", "doc:confidential")
6973
.with_context(Context::new()
7074
.with("ip_address", "10.0.0.50")
7175
.with("mfa_verified", true))
7276
.await?;
77+
```
78+
79+
#### Require Permission (Guard Clause)
7380

74-
// Guard clause - returns Err(AccessDenied) if denied
81+
```rust
7582
vault.check("user:alice", "edit", "doc:1").require().await?;
83+
```
84+
85+
#### Check Multiple Permissions
7686

77-
// Batch checks - single round-trip
87+
```rust
7888
let results = vault.check_batch([
7989
("user:alice", "view", "doc:1"),
8090
("user:alice", "edit", "doc:1"),
@@ -130,16 +140,20 @@ vault.relationships()
130140

131141
### Lookups
132142

143+
#### List Accessible Resources
144+
133145
```rust
134-
// What can a user access?
135146
let docs = vault.resources()
136147
.accessible_by("user:alice")
137148
.with_permission("view")
138149
.resource_type("document")
139150
.collect()
140151
.await?;
152+
```
141153

142-
// Who can access a resource?
154+
#### List Subjects with Access
155+
156+
```rust
143157
let users = vault.subjects()
144158
.with_permission("view")
145159
.on_resource("document:readme")
@@ -149,17 +163,21 @@ let users = vault.subjects()
149163

150164
### Explain & Simulate
151165

166+
#### Explain a Permission Decision
167+
152168
```rust
153-
// Debug why a permission was granted or denied
154169
let explanation = vault.explain_permission()
155170
.subject("user:alice")
156171
.permission("edit")
157172
.resource("document:readme")
158173
.execute()
159174
.await?;
160175
println!("{}", explanation.summary());
176+
```
177+
178+
#### Simulate What-If Scenarios
161179

162-
// Test what-if scenarios without persisting changes
180+
```rust
163181
let result = vault.simulate()
164182
.add_relationship(Relationship::new("doc:1", "editor", "user:bob"))
165183
.check("user:bob", "edit", "doc:1")
@@ -168,8 +186,9 @@ let result = vault.simulate()
168186

169187
### Watch for Changes
170188

189+
#### Stream Relationship Changes
190+
171191
```rust
172-
// Real-time stream of relationship changes
173192
let mut stream = vault.watch()
174193
.filter(WatchFilter::resource_type("document"))
175194
.run()
@@ -189,9 +208,9 @@ let org = client.organization("org_...");
189208
let vault = org.vault("vlt_...");
190209
```
191210

192-
### Organizations & Vaults
211+
### Organizations
193212

194-
### Get Current Organization
213+
#### Get Current Organization
195214

196215
```rust
197216
let info = org.control().get().await?;
@@ -213,9 +232,10 @@ let vaults = org.vaults().list().collect().await?;
213232

214233
### Schemas
215234

235+
#### Push a Schema
236+
216237
```rust
217-
// Push a new schema version
218-
let result = org.vault("vlt_...").schemas().push(r#"
238+
let result = vault.schemas().push(r#"
219239
type user {}
220240
type document {
221241
relation viewer: user
@@ -224,55 +244,81 @@ let result = org.vault("vlt_...").schemas().push(r#"
224244
permission edit = editor
225245
}
226246
"#).await?;
247+
```
227248

228-
// Validate without persisting
229-
let validation = org.vault("vlt_...").schemas().validate(schema_content).await?;
249+
#### Validate a Schema
230250

231-
// Activate a version
232-
org.vault("vlt_...").schemas().activate("v2").await?;
251+
```rust
252+
let validation = vault.schemas().validate(schema_content).await?;
253+
```
233254

234-
// Compare versions
235-
let diff = org.vault("vlt_...").schemas().diff("v1", "v2").await?;
255+
#### Activate a Schema Version
256+
257+
```rust
258+
vault.schemas().activate("v2").await?;
236259
```
237260

238-
### Members & Teams
261+
#### Compare Schema Versions
262+
263+
```rust
264+
let diff = vault.schemas().diff("v1", "v2").await?;
265+
```
266+
267+
### Members
268+
269+
#### Invite a Member
239270

240271
```rust
241-
// Invite a member
242272
org.members().invite(InviteMemberRequest::new("alice@example.com", OrgRole::Admin)).await?;
273+
```
274+
275+
### Teams
243276

244-
// Create a team
277+
#### Create a Team
278+
279+
```rust
245280
org.teams().create(CreateTeamRequest::new("Engineering")).await?;
281+
```
282+
283+
#### Add Member to Team
246284

247-
// Add member to team
285+
```rust
248286
org.teams().add_member("team_...", "user_...", TeamRole::Member).await?;
249287
```
250288

251289
### API Clients
252290

291+
#### Create an API Client
292+
253293
```rust
254-
// Create an API client for service-to-service auth
255294
let api_client = org.clients().create(
256295
CreateApiClientRequest::new("payment-service")
257296
).await?;
297+
```
298+
299+
#### Rotate Client Credentials
258300

259-
// Rotate credentials
301+
```rust
260302
org.clients().certificates("client_...").rotate(
261303
RotateCertificateRequest::new(public_key_pem)
262304
).await?;
263305
```
264306

265307
### Audit Logs
266308

309+
#### Query Audit Events
310+
267311
```rust
268-
// Query audit events
269312
let events = org.audit().list()
270313
.action(AuditAction::RelationshipCreated)
271314
.since(one_hour_ago)
272315
.collect()
273316
.await?;
317+
```
274318

275-
// Export to file
319+
#### Export Audit Logs
320+
321+
```rust
276322
org.audit().export()
277323
.format(ExportFormat::Json)
278324
.write_to_file("audit.json")

0 commit comments

Comments
 (0)