POC: delegate tree and sharing to Drive - #2548
Draft
NathanVss wants to merge 4 commits into
Draft
Conversation
The document tree, sharing and trash are moving to Drive: Docs needs a client to read and mutate its mirror items there. Every call carries a server-to-server token plus the acting user's identity so Drive applies its own permission logic; no identity headers means anonymous, which is how public link reach flows back to logged-out visitors. The client also maps Drive abilities onto the Docs abilities shape consumed by the frontend and the collaboration server, with all sharing-management abilities disabled, and caches item fetches for a few seconds to soften per-request lookups.
Documents live in Drive as pointer items sharing the document id, and Drive is the source of truth for hierarchy, sharing, link reach and trash. Keeping a local copy of any of it would mean syncing two authorities, so the Document model drops its tree structure (treebeard) and access rows entirely and becomes a thin wrapper: a non-persisted drive_item, fetched per request on behalf of the user, feeds abilities, user role, link fields and tree data. Fail closed when Drive is unreachable. Lists and trees are proxied from Drive; "locally known" documents (the ones the user created or visited) only back secondary views. Deleting from Docs pushes to Drive's trash, and idempotent server-to-server endpoints let Drive propagate delete, restore and purge for whole subtrees. Public link reach now applies to anonymous visitors too, including attachments. DocumentAccess and Invitation are removed (invitations only existed to become accesses); sharing endpoints are commented, not deleted, so they can come back when Drive implements AskForAccess.
Sharing is managed in Drive now: keeping the share modal, invitations and role management in Docs would offer two competing places to do the same thing on the same items. The whole doc-share feature goes away; only read-only visibility badges remain so users still see at a glance that a document is public or shared. The 403 page points users to the document owner instead of an in-app access request, and the shared button in the grid becomes a passive indicator.
The POC needs both stacks up at once on one machine, so the default ports (3000, 8071, 8083, 4444...) are remapped to a parallel scheme (3001, 8072, 8084, 4445...) and both compose networks share the lasuite-network bridge. Authentication is delegated to Drive's Keycloak: users must have the same OIDC sub in both apps for the impersonation headers to resolve, so a single realm serves the two of them and the local Keycloak is no longer proxied. The Drive server-to-server dev token is a placeholder, mirrored in the Drive branch of the POC.
| def raise_as_drf(exc): | ||
| """Convert a DriveClientError to the closest DRF exception.""" | ||
| if exc.status_code in (401, 403): | ||
| raise drf_exceptions.PermissionDenied(str(exc)) from exc |
| if exc.status_code in (401, 403): | ||
| raise drf_exceptions.PermissionDenied(str(exc)) from exc | ||
| if exc.status_code == 404: | ||
| raise drf_exceptions.NotFound(str(exc)) from exc |
| raise drf_exceptions.PermissionDenied(str(exc)) from exc | ||
| if exc.status_code == 404: | ||
| raise drf_exceptions.NotFound(str(exc)) from exc | ||
| raise drf_exceptions.APIException(str(exc)) from exc |
Contributor
|
Size Change: -14.4 kB (-0.33%) Total Size: 4.35 MB 📦 View Changed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POC of a deep integration with Drive. Companion PR: suitenumerique/drive#790
Docs documents live in the Drive tree as pointer items sharing the document id. Drive becomes the source of truth for hierarchy, sharing, link reach and trash. Docs keeps the content and the collaborative editing.
Concretely:
drive_clientcalling Drive server-to-server, impersonating the current user so Drive's permission logic applies everywhere (anonymous included, which makes public links work)Documentis now a thin wrapper around its Drive item: abilities, user role, link fields and trees all come from Drive, fetched per request with a short cacheDocumentAccessandInvitationare dropped, the sharing endpoints are commented out until Drive implements AskForAccesse2e tests are not updated at this stage, it's a POC.