Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to share items with people outside the platform #10663

Merged
merged 81 commits into from
Dec 23, 2021

Conversation

rijkvanzanten
Copy link
Member

@rijkvanzanten rijkvanzanten commented Dec 23, 2021

Adds a new Sharing mechanism, that allows the user to share items from collections with people outside of Directus. Shares are controlled through a new sidebar detail on the item detail page:

CleanShot 2021-12-23 at 17 13 35@2x

Each share can be configured with some options to restrict its usage, this includes an optional password, a datetime-range in which it's valid, and a maximum number of uses the item can be viewed:

CleanShot 2021-12-23 at 17 14 30@2x

Shares can be.. shared by copying/sending the unique link it generates directly, or by having Directus itself send an email to any recipient:

CleanShot 2021-12-23 at 17 14 50@2x

CleanShot 2021-12-23 at 17 15 22@2x

Each share generates a unique URL that can be used to view the shared item, without having to have a user to login with. The user who receives the link can simply open it, and assuming all configured conditions have been met, view the item:

CleanShot 2021-12-23 at 17 20 21@2x

(in this particular case, only configured to allow to see the author's name)

Is this safe?

Every time you create a Share, you have the option to associate a role to the share. This allows you to have the share inherit the permissions of that given role. This allows you to finely control what exact fields (including relational fields) are available on the shared item. We obviously don't want to expose anything that wasn't explicitly shared, so in addition to inheriting the role's permissions, the API will automatically generate and inject a permissions set to ensure that only the shared item, and items that are relationally linked to the shared item can be viewed. This is done by following all relational fields, and automatically injecting permissions that ensure that only items that have an explicit relationship to the shared item can be viewed (if your role allows read access to those collections in the first place).

In addition, you can control what role is allowed to share what particular item within the system. This allows you to configure things like "Only reports that are marked as 'Done' can be shared":

CleanShot 2021-12-23 at 17 44 58@2x

api/src/app.ts Outdated Show resolved Hide resolved
api/src/controllers/shares.ts Show resolved Hide resolved
app/src/routes/login/login.vue Outdated Show resolved Hide resolved
app/src/stores/notifications.ts Outdated Show resolved Hide resolved
app/src/stores/settings.ts Outdated Show resolved Hide resolved
@rijkvanzanten rijkvanzanten merged commit dbf35a1 into main Dec 23, 2021
@rijkvanzanten rijkvanzanten deleted the feat/shares branch December 23, 2021 23:52
AustinPhillipTaylor pushed a commit to AustinPhillipTaylor/directus that referenced this pull request May 11, 2022
…#10663)

* Add directus_shares

* Don't check for usage limit on refresh

* Add all endpoints to the shares controller

* Move route `/auth/shared` to `/shared/auth`

* Add password protection

* Add `share` action in permissions

* Add `shares/:pk/info`

* Start on shared-view

* Add basic styling for full shared view

* Fixed migrations

* Add inline style for shared view

* Allow title override

* Finish /info endpoint for shares

* Add basic UUID validation to share/info endpont

* Add UUID validation to other routes

* Add not found state

* Cleanup /extract/finish share login endpoint

* Cleanup auth

* Added `share_start` and `share_end`

* Add share sidebar details.

* Allow share permissions configuration

* Hide the `new_share` button for unauthorized users

* Fix uses_left displayed value

* Show expired / upcoming shares

* Improved expired/upcoming styling

* Fixed share login query

* Fix check-ip and get-permissions middlewares behaviour when role is null

* Simplify cache key

* Fix typescript linting issues

* Handle app auth flow for shared page

* Fixed /users/me response

* Show when user is authenticated

* Try showing item drawer in shared page

* Improved shared card styling

* Add shares permissions and change share card styling

* Pull in schema/permissions on share

* Create getPermissionForShare file

* Change getPermissionsForShare signature

* Render form + item on share after auth

* Finalize public front end

* Handle fake o2m field in applyQuery

* [WIP]

* New translations en-US.yaml (Bulgarian) (directus#10585)

* smaller label height (directus#10587)

* Update to the latest Material Icons (directus#10573)

The icons are based on https://fonts.google.com/icons

* New translations en-US.yaml (Arabic) (directus#10593)

* New translations en-US.yaml (Arabic) (directus#10594)

* New translations en-US.yaml (Portuguese, Brazilian) (directus#10604)

* New translations en-US.yaml (French) (directus#10605)

* New translations en-US.yaml (Italian) (directus#10613)

* fix M2A list not updating (directus#10617)

* Fix filters

* Add admin filter on m2o role selection

* Add admin filter on m2o role selection

* Add o2m permissions traversing

* Finish relational tree permissions generation

* Handle implicit a2o relation

* Update implicit relation regex

* Fix regex

* Fix implicitRelation unnesting for new regex

* Fix implicitRelation length check

* Rename m2a to a2o internally

* Add auto-gen permissions for a2o

* [WIP] Improve share UX

* Add ctx menu options

* Add share dialog

* Add email notifications

* Tweak endpoint

* Tweak file interface disabled state

* Add nicer invalid state to password input

* Dont return info for expired/upcoming shares

* Tweak disabled state for relational interfaces

* Fix share button for non admin roles

* Show/hide edit/delete based on permissions to shares

* Fix imports of mutationtype

* Resolve (my own) suggestions

* Fix migration for ms sql

* Resolve last suggestion

Co-authored-by: Oreilles <oreilles.github@nitoref.io>
Co-authored-by: Oreilles <33065839+oreilles@users.noreply.github.com>
Co-authored-by: Ben Haynes <ben@rngr.org>
Co-authored-by: Thien Nguyen <72242664+tatthien@users.noreply.github.com>
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants