Skip to content

POC: delegate tree and sharing to Drive - #2548

Draft
NathanVss wants to merge 4 commits into
mainfrom
poc/docsxdrive
Draft

POC: delegate tree and sharing to Drive#2548
NathanVss wants to merge 4 commits into
mainfrom
poc/docsxdrive

Conversation

@NathanVss

Copy link
Copy Markdown
Contributor

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:

  • new drive_client calling Drive server-to-server, impersonating the current user so Drive's permission logic applies everywhere (anonymous included, which makes public links work)
  • Document is 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 cache
  • DocumentAccess and Invitation are dropped, the sharing endpoints are commented out until Drive implements AskForAccess
  • idempotent s2s endpoints so Drive can propagate delete/restore/purge on whole subtrees
  • the sharing UI is removed, only read-only visibility badges remain
  • dev env is remapped to run beside Drive with its Keycloak

e2e tests are not updated at this stage, it's a POC.

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
@github-actions

Copy link
Copy Markdown
Contributor

Size Change: -14.4 kB (-0.33%)

Total Size: 4.35 MB

📦 View Changed
Filename Size Change
apps/impress/out/_next/static/a8745b39/_buildManifest.js 680 B +680 B (new file) 🆕
apps/impress/out/_next/static/ca6e9467/_buildManifest.js 0 B -677 B (removed) 🏆
apps/impress/out/_next/static/chunks/4749.js 47.6 kB -12 kB (-20.06%) 🎉
apps/impress/out/_next/static/chunks/7864.js 0 B -1.64 kB (removed) 🏆
apps/impress/out/_next/static/chunks/pages/_app.js 528 kB -793 B (-0.15%)

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants