From 1ecc56e0824fe2c1d72ddafc44e1b33c30190f2d Mon Sep 17 00:00:00 2001 From: julianleonard123 Date: Thu, 6 Feb 2025 17:56:26 +0100 Subject: [PATCH 1/5] add examples of relationship expiration for playground and zed. --- .../concepts/expiring-relationships.mdx | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/pages/spicedb/concepts/expiring-relationships.mdx b/pages/spicedb/concepts/expiring-relationships.mdx index 67d0f437..b2fbf01e 100644 --- a/pages/spicedb/concepts/expiring-relationships.mdx +++ b/pages/spicedb/concepts/expiring-relationships.mdx @@ -1,5 +1,6 @@ import { Callout } from 'nextra/components'; import YouTube from 'react-youtube'; +import { InlinePlayground } from '@/components/playground'; # Expiring Relationships @@ -26,7 +27,7 @@ SpiceDB supports expiring relationships, which lets users define relationships t You should evaluate the impact of clock drift in your application. -## Schema Use +## Schema Expiring relationships follow a similar use to caveated subject types. The novelty here is that users need to enable the feature using the `use` clause. @@ -45,7 +46,7 @@ definition resource { } ``` -## API Use +## API The expiration of a relationship is [on a per-relationship basis](https://buf.build/authzed/api/docs/63b8911ef2871c56e5048d1f40a8473f98457ca9:authzed.api.v1#authzed.api.v1.Relationship) at write time, using `WriteRelationships` or `BulkImportRelationships` APIs. @@ -73,6 +74,24 @@ WriteRelationshipsRequest { } ``` +## Playground + +Write relationships in the Playground with the format `[expiration:2025-12-31T23:59:59Z]`: + +```yaml +resource:r1#folder@folder:folder1[expiration:2025-12-31T23:59:59Z] +``` + +
+ +## zed + +Use the `--expiration-time` flag to pass the expiration time of the relationship in RFC 3339 format: + +```shell zed +zed relationship create resource:r1 folder folder:folder1 --expiration-time 2025-12-31T23:59:59Z +``` + ## Garbage Collection As soon as a relationship expires, it will no longer be used in permission checks. From 6cef69de6791439625a9542dfcff93e43a3e519e Mon Sep 17 00:00:00 2001 From: julianleonard123 Date: Thu, 6 Feb 2025 18:09:48 +0100 Subject: [PATCH 2/5] remove trailing space to make linter happy --- pages/spicedb/concepts/expiring-relationships.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/spicedb/concepts/expiring-relationships.mdx b/pages/spicedb/concepts/expiring-relationships.mdx index b2fbf01e..b0fd9969 100644 --- a/pages/spicedb/concepts/expiring-relationships.mdx +++ b/pages/spicedb/concepts/expiring-relationships.mdx @@ -76,7 +76,7 @@ WriteRelationshipsRequest { ## Playground -Write relationships in the Playground with the format `[expiration:2025-12-31T23:59:59Z]`: +Write relationships in the Playground with the format `[expiration:2025-12-31T23:59:59Z]`: ```yaml resource:r1#folder@folder:folder1[expiration:2025-12-31T23:59:59Z] From a1b0142b7526c2efa16b603de83b3e6e14bedac5 Mon Sep 17 00:00:00 2001 From: julianleonard123 Date: Thu, 6 Feb 2025 18:15:27 +0100 Subject: [PATCH 3/5] improved wording on playground example. --- pages/spicedb/concepts/expiring-relationships.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/spicedb/concepts/expiring-relationships.mdx b/pages/spicedb/concepts/expiring-relationships.mdx index b0fd9969..6c5b6fa0 100644 --- a/pages/spicedb/concepts/expiring-relationships.mdx +++ b/pages/spicedb/concepts/expiring-relationships.mdx @@ -76,12 +76,12 @@ WriteRelationshipsRequest { ## Playground -Write relationships in the Playground with the format `[expiration:2025-12-31T23:59:59Z]`: +Set expirations on relationships in the Playground with the format `[expiration:2025-12-31T23:59:59Z]`: ```yaml resource:r1#folder@folder:folder1[expiration:2025-12-31T23:59:59Z] ``` - +or specify expirations in RFC 3339 format in the `Expiration` column in the Relationship grid editor.
## zed From 08aeecb9a79b98673f0b4c53ebfb815f9d9a9c13 Mon Sep 17 00:00:00 2001 From: julianleonard123 Date: Thu, 6 Feb 2025 18:17:38 +0100 Subject: [PATCH 4/5] fix linting issue --- pages/spicedb/concepts/expiring-relationships.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/pages/spicedb/concepts/expiring-relationships.mdx b/pages/spicedb/concepts/expiring-relationships.mdx index 6c5b6fa0..59982dbd 100644 --- a/pages/spicedb/concepts/expiring-relationships.mdx +++ b/pages/spicedb/concepts/expiring-relationships.mdx @@ -81,6 +81,7 @@ Set expirations on relationships in the Playground with the format `[expiration: ```yaml resource:r1#folder@folder:folder1[expiration:2025-12-31T23:59:59Z] ``` + or specify expirations in RFC 3339 format in the `Expiration` column in the Relationship grid editor.
From 09fdc4c4bfaac5c674e88286229fcefb07e14f89 Mon Sep 17 00:00:00 2001 From: julianleonard123 Date: Thu, 6 Feb 2025 18:25:20 +0100 Subject: [PATCH 5/5] zed date looks better with quotes in docs. --- pages/spicedb/concepts/expiring-relationships.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/spicedb/concepts/expiring-relationships.mdx b/pages/spicedb/concepts/expiring-relationships.mdx index 59982dbd..609e14a3 100644 --- a/pages/spicedb/concepts/expiring-relationships.mdx +++ b/pages/spicedb/concepts/expiring-relationships.mdx @@ -90,7 +90,7 @@ or specify expirations in RFC 3339 format in the `Expiration` column in the Rela Use the `--expiration-time` flag to pass the expiration time of the relationship in RFC 3339 format: ```shell zed -zed relationship create resource:r1 folder folder:folder1 --expiration-time 2025-12-31T23:59:59Z +zed relationship create resource:r1 folder folder:folder1 --expiration-time "2025-12-31T23:59:59Z" ``` ## Garbage Collection