gristlabs_grist-core/test/fixtures/docs
Paul Fitzpatrick 2a206dfcf8 (core) add initial support for special shares
Summary:
This gives a mechanism for controlling access control within a document that is distinct from (though implemented with the same machinery as) granular access rules.

It was hard to find a good way to insert this that didn't dissolve in a soup of complications, so here's what I went with:
 * When reading rules, if there are shares, extra rules are added.
 * If there are shares, all rules are made conditional on a "ShareRef" user property.
 * "ShareRef" is null when a doc is accessed in normal way, and the row id of a share when accessed via a share.

There's no UI for controlling shares (George is working on it for forms), but you can do it by editing a `_grist_Shares` table in a document. Suppose you make a fresh document with a single page/table/widget, then to create an empty share you can do:

```
gristDocPageModel.gristDoc.get().docData.sendAction(['AddRecord', '_grist_Shares', null, {linkId: 'xyz', options: '{"publish": true}'}])
```

If you look at the home db now there should be something in the `shares` table:

```
$ sqlite3 -table landing.db "select * from shares"
+----+------------------------+------------------------+--------------+---------+
| id |          key           |         doc_id         |   link_id    | options |
+----+------------------------+------------------------+--------------+---------+
| 1  | gSL4g38PsyautLHnjmXh2K | 4qYuace1xP2CTcPunFdtan | xyz | ...      |
+----+------------------------+------------------------+--------------+---------+
```

If you take the key from that (gSL4g38PsyautLHnjmXh2K in this case) and replace the document's urlId in its URL with `s.<key>` (in this case `s.gSL4g38PsyautLHnjmXh2K` then you can use the regular document landing page (it will be quite blank initially) or API endpoint via the share.

E.g. for me `http://localhost:8080/o/docs/s0gSL4g38PsyautLHnjmXh2K/share-inter-3` accesses the doc.

To actually share some material - useful commands:

```
gristDocPageModel.gristDoc.get().docData.getMetaTable('_grist_Views_section').getRecords()
gristDocPageModel.gristDoc.get().docData.sendAction(['UpdateRecord', '_grist_Views_section', 1, {shareOptions: '{"publish": true, "form": true}'}])
gristDocPageModel.gristDoc.get().docData.getMetaTable('_grist_Pages').getRecords()
gristDocPageModel.gristDoc.get().docData.sendAction(['UpdateRecord', '_grist_Pages', 1, {shareRef: 1}])
```

For a share to be effective, at least one page needs to have its shareRef set to the rowId of the share, and at least one widget on one of those pages needs to have its shareOptions set to {"publish": "true", "form": "true"} (meaning turn on sharing, and include form sharing), and the share itself needs {"publish": true} on its options.

I think special shares are kind of incompatible with public sharing, since by their nature (allowing access to all endpoints) they easily expose the docId, and changing that would be hard.

Test Plan: tests added

Reviewers: dsagal, georgegevoian

Reviewed By: dsagal, georgegevoian

Subscribers: jarek, dsagal

Differential Revision: https://phab.getgrist.com/D4144
2024-01-04 05:57:38 -05:00
..
video (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
ACL-Test.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
ActiveDoc-sqlite.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
AllColumns.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
ApiDataRecordsTest.grist (core) disentangle some server tests, release to core, add GRIST_PROXY_AUTH_HEADER test 2022-03-24 15:11:32 -04:00
AttachmentsJsonMigration.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV1.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV2.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV3.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV4.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV5.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV6.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV7.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV8.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV16.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
BlobMigrationV17.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
CardView.grist (core) Fix hidden columns bug when editing data selection 2022-10-18 08:36:11 -07:00
CC_Statement.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
CC_Summaries-v2.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
CC_Summaries-v6.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
CC_Summaries.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
CCTransactions.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
ChartData.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Class Enrollment.grist (core) Highlight rows used as a selector in linking, but do not show 'inactive' cursors. 2023-06-21 12:21:19 -04:00
CopyOptions.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
CopyPaste2.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
CopyPaste.grist (core) Adds a UI panel for managing webhooks 2023-05-08 18:25:27 -04:00
Countries-Print.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Covid-19.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
Currencies.grist (core) Currency from grist column is persistent when exporting to excel 2023-05-08 10:39:01 +02:00
CustomWidget.grist (core) Moving widget tests to core 2022-09-06 17:17:14 +02:00
DefaultValuesV5.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
DefaultValuesV6.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
DefaultValuesV7.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
DefaultValuesV8.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
DeleteColumnsUndo.grist (core) Fix error in sandbox when removing multiple summary source columns 2023-09-27 16:23:49 +02:00
doctour.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
DocTutorial.grist (core) Add initial tutorials implementation 2023-03-22 10:09:02 -04:00
DownmigrateTest.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Excel.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Exports.grist (core) Fix imports into reference columns, and support two ways to import Numeric as a reference. 2023-05-02 10:28:14 -04:00
Favorite_Films_Raw.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Favorite_Films_With_Linked_Ref.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
Favorite_Films.grist (core) disentangle some server tests, release to core, add GRIST_PROXY_AUTH_HEADER test 2022-03-24 15:11:32 -04:00
FetchSelectedOptions.grist (core) Options for plugin API functions which fetch data from the selected table or record 2023-10-26 23:46:00 +02:00
FieldSettings.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
FilmsWithImages.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
FilterByComplexCellValues.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
FilterLinkChain.grist (core) Fix selecting new row in chain of filter links 2023-12-05 16:56:13 +02:00
FilterTest.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
GristNewUserInfo.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Hello.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
Hooks-v37.grist (core) Adds a UI panel for managing webhooks 2023-05-08 18:25:27 -04:00
ImportReferences.grist (core) Fix imports into reference columns, and support two ways to import Numeric as a reference. 2023-05-02 10:28:14 -04:00
InvalidValues.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Investment Research.grist (core) move more tests to grist-core 2021-12-10 18:33:07 -05:00
Landlord.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
LastPosition.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
LinkChain.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
LongList.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
ManyRefs.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
Memos-v34.grist (core) Add new UI for writing memos 2022-12-12 17:52:01 -05:00
NumericFormatting.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Pages-v19.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Pages.grist Adding tests for left panel 2022-08-03 16:15:45 +02:00
PasteParsing.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
RawSummaryTables.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Ref-AC-Test.grist Moving 3 ACinput tests to grist core 2022-08-10 13:10:50 +02:00
Ref-List-AC-Test.grist Moving 3 ACinput tests to grist core 2022-08-10 13:10:50 +02:00
RemoveTransformColumns.grist (core) Remove transform columns on shutdown 2023-11-14 22:31:34 +02:00
SchoolsSample.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
selectBy.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
SelectByRefList.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
SelectBySummary.grist (core) Allow adding rows to widgets filtered by a link using a formula column 2023-12-18 20:28:41 +02:00
SelectBySummaryRef.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
SelectionSummary.grist (core) Add cell selection summary 2022-09-30 09:11:46 -07:00
ShiftSelection.grist Support grid selection with Ctrl+Shift+Arrow (#615) 2023-08-14 09:28:41 -07:00
SortDates.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
SortFilterIconTest.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
SummarizeByRef.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
SummaryRulesBug.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
SummaryTableFormula.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
TabBar.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
Teams.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
TypeConversions.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
TypeEncoding.grist (core) Moving widget tests to core 2022-09-06 17:17:14 +02:00
Widgets.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v0.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v1.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v3.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v8.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v10.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v11.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v12.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v13.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v14.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v15.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v18.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v20.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v24.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v25.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
World-v33.grist (core) Update sort and filter UI 2022-11-17 15:33:45 -05:00
World-v39.grist (core) Record Cards 2023-11-19 20:12:37 -05:00
World.grist (core) add initial support for special shares 2024-01-04 05:57:38 -05:00
WorldSQLDB.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00
WorldUndo.grist (core) Moving nbrowser tests to grist-core 2022-10-25 17:22:54 +02:00