Skip to content

Commit

Permalink
Merge pull request #773 from Permify/docs
Browse files Browse the repository at this point in the history
docs: add abac examples and code snippets
  • Loading branch information
tolgaOzen authored Oct 25, 2023
2 parents 5bb7545 + 43b0e70 commit 29971a1
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 37 deletions.
29 changes: 9 additions & 20 deletions docs/docs/api-overview/data/read-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,15 @@ Read API allows for directly querying the stored graph data to display and filte
```go
rr, err: = client.Data.Relationship.Read(context.Background(), & v1.Data.RelationshipReadRequest {
TenantId: "t1",
Metadata: &v1.Data.RelationshipReadRequestMetadata {
Metadata: &v1.Data.AttributeReadRequestMetadata {
SnapToken: ""
},
Filter: &v1.TupleFilter {
Filter: &v1.AttributeFilter {
Entity: &v1.EntityFilter {
Type: "organization",
Ids: []string {"1"} ,
},
Relation: "member",
Subject: &v1.SubjectFilter {
Type: "",
Id: []string {""},
Relation: ""
}}
Attributes: []string {"private"},
})
```
Expand All @@ -59,12 +54,9 @@ client.data.relationship.read({
"1"
]
},
relation: "member",
subject: {
type: "",
ids: [],
relation: ""
}
attributes: [
"private"
],
}
}).then((response) => {
// handle response
Expand All @@ -88,12 +80,9 @@ curl --location --request POST 'localhost:3476/v1/tenants/{tenant_id}/data/relat
"1"
]
},
relation: "member",
subject: {
type: "",
ids: [],
relation: ""
}
attributes: [
"private"
],
}
}'
```
Expand Down
72 changes: 71 additions & 1 deletion docs/docs/api-overview/data/write-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,85 @@ Here are the available attribute value types:
<TabItem value="go" label="Go">

```go
// Convert the wrapped attribute value into Any proto message
value, err := anypb.New(&v1.BooleanValue{
Data: true,
})
if err != nil {
// Handle error
}

cr, err := client.Data.Write(context.Background(), &v1.DataWriteRequest{
TenantId: "t1",,
Metadata: &v1.DataWriteRequestMetadata{
SchemaVersion: "",
},
Tuples: []*v1.Attribute{
{
Entity: &v1.Entity{
Type: "organization",
Id: "1",
},
Relation: "admin",
Subject: &v1.Subject{
Type: "user",
Id: "1",
Relation: "",
},
},
},
Attributes: []*v1.Attribute{
{
Entity: &v1.Entity{
Type: "account",
Id: "1",
},
Attribute: "public",
Value: value,
},
},
})
```

</TabItem>

<TabItem value="node" label="Node">

```javascript
const booleanValue = BooleanValue.fromJSON({ data: true });

const value = Any.fromJSON({
typeUrl: 'type.googleapis.com/base.v1.BooleanValue',
value: BooleanValue.encode(booleanValue).finish()
});

client.data.write({
tenantId: "t1",
metadata: {
schemaVersion: ""
},
tuples: [{
entity: {
type: "organization",
id: "1"
},
relation: "admin",
subject: {
type: "user",
id: "1"
}
}],
attributes: [{
entity: {
type: "document",
id: "1"
},
attribute: "public",
value: value,
}]
}).then((response) => {
// handle response
})
```

</TabItem>
Expand Down Expand Up @@ -197,7 +267,7 @@ curl --location --request POST 'localhost:3476/v1/tenants/{tenant_id}/data/write
"attribute": "private",
"value": {
"@type": "type.googleapis.com/base.v1.BooleanValue",
"value": "true"
"value": true
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/comparision.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This comparison table shows the differentiation between authorization solutions
| **Watch API** |||||
| **RBAC** |||||
| **ReBAC** |||||
| **ABAC** || 🟡 || |
| **ABAC** || 🟡 || |
| **Data Filtering** |||||
| **Multi Tenancy** |||||
| **Testing & Validation** || 🟡 |||
Expand Down
27 changes: 12 additions & 15 deletions docs/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,29 +458,26 @@ A consistent hashing ring ensures data distribution that minimizes reorganizatio
```
├── distributed
| ├── enabled
| ├── node
| ├── node-name
| ├── protocol
| ├── address
| ├── port
```

#### Glossary

| Required | Argument | Default | Description |
|----------|-----------|---------|--------------------------------------------------------------------------|
| [x] | enabled | false | switch option for distributed. |
| [x] | node | - | endpoint definition for distributed |
| [x] | node-name | - | node name definition for protocol agent (for example serf node name) |
| [x] | protocol | - | a field where you specify which gossip protocol to use, for example serf |
| Required | Argument | Default | Description |
|----------|-------------|---------|--------------------------------------|
| [x] | enabled | false | switch option for distributed. |
| [] | address | - | address of the distributed service |
| [] | port | 5000 | port on which the service is exposed |


#### ENV

| Argument | ENV | Type |
|------------------------|-------------------------------|---------|
| distributed-enabled | PERMIFY_DISTRIBUTED_ENABLED | boolean |
| distributed-node | PERMIFY_DISTRIBUTED_NODE | string |
| distributed-node-name | PERMIFY_DISTRIBUTED_NODE_NAME | string |
| distributed-protocol | PERMIFY_DISTRIBUTED_PROTOCOL | string |
| Argument | ENV | Type |
|----------------------|-----------------------------|---------|
| distributed-enabled | PERMIFY_DISTRIBUTED_ENABLED | boolean |
| distributed-address | PERMIFY_DISTRIBUTED_ADDRESS | string |
| distributed-port | PERMIFY_DISTRIBUTED_PORT | string |

</p>
</details>
Expand Down
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ module.exports = {
items: [
"api-overview/data/write-data",
"api-overview/data/read-relationships",
"api-overview/data/read-attributes",
"api-overview/data/delete-data"
],
},
Expand Down

0 comments on commit 29971a1

Please sign in to comment.