Skip to content

Commit 5d77708

Browse files
committed
fix: best practices & attributes
1 parent 7fe4d59 commit 5d77708

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

app/best-practices/page.mdx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,14 @@ You should be testing the logic of your schema to ensure that it behaves the way
105105
Tags: **schema**
106106

107107
If an authorization concept can be expressed using relations, it should be.
108-
We provide caveats as an escape hatch; they should only be used for context that’s only available at request time, or else ABAC logic that cannot be expressed in terms of relationships.
108+
We provide caveats as an escape hatch; they should only be used for context that’s only available at request time, or for ABAC logic that cannot be expressed in terms of relationships.
109109

110-
This is because caveats come with a performance penalty.
111-
A caveated relationship is both harder to cache and also slows down computation of the graph walk required to compute a permission.
110+
This is because caveats come with a performance penalty: a caveated relationship is both harder to cache and also slows down computation of the graph walk required to compute a permission.
112111

113112
Some examples:
114113

115-
- A banlist - this could be expressed as a list in caveat context, but it can also be expressed as a relation with negation.
116-
- A notion of public vs internal - boolean flags seem like an obvious caveat use case, but they can also be expressed using self relations.
114+
- A banlist - this could be expressed as a list in caveat context, but it can also be expressed as a relation with [exclusion](https://authzed.com/docs/spicedb/concepts/schema#--exclusion).
115+
- A notion of public vs internal - boolean flags seem like an obvious caveat use case, but they can also be expressed using [self relationships](https://authzed.com/docs/spicedb/modeling/attributes#self-relationships).
117116
- Dynamic roles - these could be expressed as a list in caveats, and it’s not immediately obvious how to build them into a SpiceDB schema, but our [Google Cloud IAM example](https://authzed.com/blog/google-cloud-iam-modeling) shows how it’s possible.
118117

119118
### Make Your Writes Idempotent

app/spicedb/modeling/attributes/page.mdx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@ import { Callout } from "nextra/components";
55

66
If you are migrating to SpiceDB from a pre-existing authorization system, it's likely that attributes play a part in your authorization evaluations.
77

8-
SpiceDB is a Relationship Based Access control system.
9-
This gives SpiceDB the flexibility to evaluate attributes for access control alongside more complicated access control logic like roles and/or relationships.
8+
SpiceDB can evaluate attributes for access control decisions alongside more complicated access control logic like roles and/or relationships.
109

1110
The sections below will provide practical examples for implementing various kinds of attributes in the SpiceDB schema language.
1211
Before reading this guide, it's recommended that you have some familiarity with the SpiceDB schema language. [These documents](/spicedb/modeling/developing-a-schema) are a good place to start.
1312

1413
## Boolean Attributes
1514

16-
A boolean attribute is an attribute on an object that affects authorization by enabling or disabling an authorization setting.
17-
Boolean attributes can often be thought of as a toggle.
18-
Feature flag authorization can be enabled with boolean attributes.
15+
A boolean or binary attribute is an attribute on an object that can affect authorization.
16+
Boolean attributes can often be thought of as a toggle. For example, feature flag authorization can be enabled with boolean attributes.
1917

2018
### Wildcards
2119

22-
[Wildcards](/spicedb/concepts/schema#wildcards) are a way to implement boolean attributes.
20+
[Wildcards](/spicedb/concepts/schema#wildcards) are one way to implement boolean attributes.
2321
Wildcards modify a type so that a relationship can be written to all objects of a resource type but not individual objects.
2422

2523
In the example below, the schema enforces the following authorization logic: a user will have `edit` permission on the document if they are related to the document as an `editor` and they relate to the document through `edit_enabled`.
@@ -54,9 +52,10 @@ In summary, a `user` has permission to edit a `document` if they are related to
5452
<Callout type="warning">
5553
There is no mechanism in the SpiceDB schema language that enforces that a
5654
relation be used as a self relation. In order to avoid accidentally misusing a
57-
self relation (e.g. relating an object to a different instance of the same
58-
type) it is recommended to implement client side logic that enforces only
59-
using the self relation for it's intended purpose.
55+
self relation (e.g. by writing the relationship
56+
`document:1#edit_enabled@document:2`) it is recommended to implement client
57+
side logic that enforces only using the self relation for its intended
58+
purpose.
6059
</Callout>
6160

6261
## Attribute Matching
@@ -104,4 +103,4 @@ This example is similar to the one above, except it requires that all `country`
104103

105104
In almost all cases, [caveats](/spicedb/concepts/caveats) should only be used when data required to evaluate a CheckPermission request is only available at the time of the request (e.g. user's current location or time of day).
106105
Using caveats for static data (e.g. a document's status) can have negative performance impacts.
107-
Static attribute data should always be modeled in the schema using patterns similar to those described above.
106+
Static attribute data should always be modeled in the schema using the patterns described above.

0 commit comments

Comments
 (0)