From f54a2bc6e19cee8ec13f9b20f0113b163af0dbbf Mon Sep 17 00:00:00 2001 From: Chris Bush Date: Mon, 13 Feb 2023 10:59:09 -0500 Subject: [PATCH 1/2] Update for Rules v2: remove "Device Sync Permissions" --- .../flutter/sync/write-to-synced-realm.txt | 45 ++++++------- .../sdk/swift/sync/write-to-synced-realm.txt | 64 ++++++++----------- 2 files changed, 44 insertions(+), 65 deletions(-) diff --git a/source/sdk/flutter/sync/write-to-synced-realm.txt b/source/sdk/flutter/sync/write-to-synced-realm.txt index c38c2623d6..b8aac2fce8 100644 --- a/source/sdk/flutter/sync/write-to-synced-realm.txt +++ b/source/sdk/flutter/sync/write-to-synced-realm.txt @@ -23,31 +23,20 @@ The examples on this page use an Atlas App Services App with the following Device Sync configuration and a client app with the following Realm SDK data model and subscriptions. -Device Sync is configured with the following queryable fields: - -- ``_id`` (always included) -- ``miles`` -- ``ownerId`` - -Device Sync has permissions configured to let users read and write only their own -data: +The App Services App has permissions configured to let users read and write only +their own data: .. code-block:: json { - "rules": {}, - "defaultRoles": [ - { - "name": "owner-read-write", - "applyWhen": {}, - "read": { - "ownerId": "%%user.id" - }, - "write": { - "ownerId": "%%user.id" - } - } - ] + "name": "owner-read-write", + "apply_when": {}, + "document_filters": { + "read": { "ownerId": "%%user.id" }, + "write": { "ownerId": "%%user.id" } + }, + "read": true, + "write": true } The examples on this page use the following schema: @@ -72,12 +61,14 @@ of the following: the write reverts with a non-fatal compensating write error (ErrorCompensatingWrite). - To learn more about compensating write errors and how to avoid them, refer to the :ref:`Compensating Writes ` section. -- **The Device Sync permissions** in your App Services App. - - If your try to write data that doesn't match the Device Sync permissions expression, - the write reverts with a non-fatal permission denied error (ErrorPermissionDenied). - - To learn more about configuring Device Sync permissions for your app, - refer to :ref:`sync-rules` and the :ref:`flexible-sync-permissions-guide` - in the App Services documentation. +- **The permissions** in your App Services App. + - If your try to write data that doesn't match the permissions expression, + the write reverts with a non-fatal permission denied error. In the client, + this shows as an error (ErrorCompensatingWrite). On the server, you can see more + details about how the write was denied was by a write filter in the role. + - To learn more about configuring permissions for your app, see + :ref:`sync-rules` and the :ref:`flexible-sync-permissions-guide` in the + App Services documentation. To learn more about permission denied errors, compensating write errors and other Device Sync error types, refer to :ref:`sync-errors` in the App Services documentation. diff --git a/source/sdk/swift/sync/write-to-synced-realm.txt b/source/sdk/swift/sync/write-to-synced-realm.txt index 1a65348560..f455386bfe 100644 --- a/source/sdk/swift/sync/write-to-synced-realm.txt +++ b/source/sdk/swift/sync/write-to-synced-realm.txt @@ -23,15 +23,14 @@ of the following: - **The sync subscription query.** - If your write operation doesn't match the query in the subscription, the write reverts with a non-fatal compensating write error (ErrorCompensatingWrite). -- **The Device Sync permissions** in your App Services App. - - If your try to write data that doesn't match the Device Sync permissions expression, - the write reverts with a non-fatal permission denied error. - In the client, this shows as an (ErrorCompensatingWrite). On the server, - you can see more details about how the write was denied was by a - write filter in the role. - - To learn more about configuring Device Sync permissions for your app, - refer to :ref:`sync-rules` and the :ref:`flexible-sync-permissions-guide` - in the App Services documentation. +- **The permissions** in your App Services App. + - If your try to write data that doesn't match the permissions expression, + the write reverts with a non-fatal permission denied error. In the client, + this shows as an error (ErrorCompensatingWrite). On the server, you can see more + details about how the write was denied was by a write filter in the role. + - To learn more about configuring permissions for your app, see + :ref:`sync-rules` and the :ref:`flexible-sync-permissions-guide` in the + App Services documentation. .. warning:: Multiprocess Sync is Not Supported @@ -42,40 +41,29 @@ of the following: Determining What Data Syncs --------------------------- -The data that you can write to a synced realm is the intersection of your -Device Sync configuration - your queryable fields and permissions - and the -Flexible Sync subscription query that you use when you open the realm. +The data that you can write to a synced realm is the intersection of your Device +Sync configuration, your permissions, and the Flexible Sync subscription query +that you use when you open the realm. The examples on this page use the following configurations and models: Device Sync Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~ -Device Sync is configured with the following queryable fields: - -- ``_id`` (this is a queryable field in every Device Sync configuration) -- ``ownerId`` -- ``complexity`` - Device Sync has permissions configured to let users read and write only their own data: .. code-block:: json { - "rules": {}, - "defaultRoles": [ - { - "name": "owner-read-write", - "applyWhen": {}, - "read": { - "ownerId": "%%user.id" - }, - "write": { - "ownerId": "%%user.id" - } - } - ] + "name": "owner-read-write", + "apply_when": {}, + "document_filters": { + "read": { "ownerId": "%%user.id" }, + "write": { "ownerId": "%%user.id" } + }, + "read": true, + "write": true } Client Data Model and Configuration @@ -96,8 +84,8 @@ is less than or equal to ``4``: What Data Syncs? ~~~~~~~~~~~~~~~~ -The subscription query combined with the Device Sync permissions mean -that the synced realm only syncs objects where: +The subscription query combined with the permissions mean that the synced realm +only syncs objects where: - The ``ownerId`` matches the ``user.id`` of the logged-in user (from the permissions) - The ``complexity`` property's value is less than or equal to ``4`` (from the subscription query) @@ -124,11 +112,11 @@ Writes to Flexible Sync realms may broadly fall into one of two categories: Successful Writes ~~~~~~~~~~~~~~~~~ -When the write matches both the :ref:`Device Sync permissions ` -and the :ref:`Flexible Sync subscription query -` in the client, the Realm Swift SDK -can successfully write the object to the synced realm. This object syncs -with the App Services backend when the device has a network connection. +When the write matches both the :ref:`permissions ` and the +:ref:`Flexible Sync subscription query +` in the client, the Realm Swift SDK +can successfully write the object to the synced realm. This object syncs with +the App Services backend when the device has a network connection. .. literalinclude:: /examples/generated/code/start/SyncedRealmCRUD.snippet.successful-write.swift :language: swift From 5885ea92082d1542c61c23bd6845887160841ed2 Mon Sep 17 00:00:00 2001 From: Chris Bush Date: Mon, 13 Feb 2023 15:14:32 -0500 Subject: [PATCH 2/2] Undo mention of queryable fields --- source/sdk/flutter/sync/write-to-synced-realm.txt | 6 ++++++ source/sdk/swift/sync/write-to-synced-realm.txt | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/sdk/flutter/sync/write-to-synced-realm.txt b/source/sdk/flutter/sync/write-to-synced-realm.txt index b8aac2fce8..ae39d21145 100644 --- a/source/sdk/flutter/sync/write-to-synced-realm.txt +++ b/source/sdk/flutter/sync/write-to-synced-realm.txt @@ -23,6 +23,12 @@ The examples on this page use an Atlas App Services App with the following Device Sync configuration and a client app with the following Realm SDK data model and subscriptions. +Device Sync is configured with the following queryable fields: + +- ``_id`` (always included) +- ``miles`` +- ``ownerId`` + The App Services App has permissions configured to let users read and write only their own data: diff --git a/source/sdk/swift/sync/write-to-synced-realm.txt b/source/sdk/swift/sync/write-to-synced-realm.txt index f455386bfe..4d598515e7 100644 --- a/source/sdk/swift/sync/write-to-synced-realm.txt +++ b/source/sdk/swift/sync/write-to-synced-realm.txt @@ -47,10 +47,16 @@ that you use when you open the realm. The examples on this page use the following configurations and models: -Device Sync Configuration -~~~~~~~~~~~~~~~~~~~~~~~~~ +App Services Configuration +~~~~~~~~~~~~~~~~~~~~~~~~~~ -Device Sync has permissions configured to let users read and write only their own +Device Sync is configured with the following queryable fields: + +- ``_id`` (always included) +- ``miles`` +- ``ownerId`` + +The App Services App has permissions configured to let users read and write only their own data: .. code-block:: json