Skip to content

✨ POC: integrate Docs documents in the Drive tree - #790

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

✨ POC: integrate Docs documents in the Drive tree#790
NathanVss wants to merge 6 commits into
mainfrom
poc/docsxdrive

Conversation

@NathanVss

Copy link
Copy Markdown
Contributor

Purpose

POC exploring the integration of Docs into Drive: documents live in the Drive
tree next to regular files, and Drive becomes the source of truth for the
hierarchy, sharing and trash while Docs keeps owning content and collaborative
editing.

Proposal

  • Pointer items: a FILE item carrying metadata.external_app points to a
    resource hosted by another application. It has no filename and no physical
    upload, is ready as soon as created, and can hold children (sub-documents).
    File-only abilities (download, wopi, upload, convert) are disabled on them.
  • Server-to-server impersonation: trusted apps authenticate with a static
    bearer token and act on behalf of a user via X-User-Sub/X-User-Email,
    reusing every existing endpoint with its full permission logic. No identity
    headers means the caller acts for an anonymous visitor, so public link reach
    works end to end. The "s2s" auth tag prevents notification loops.
  • Generic external app contract: apps registered in EXTERNAL_APPS provide
    a backend implementing create/delete/restore/purge of their resources.
    Integrating a new app does not require touching the item views. Docs is the
    first implementation.
  • Lifecycle propagation: creating a pointer item from Drive triggers the
    app back-channel (rolled back on failure); trash, restore and purge notify
    the app for every pointer of the affected subtree, with an idempotent
    backstop in the purge task covering the cron path.
  • UI: sub-documents are hidden from listing views (only the document root
    surfaces), a tree-descendants action serves the whole document tree to the
    app, and the explorer gets a "New Docs document" entry; clicking a pointer
    item (or landing on its preview route) opens the Docs frontend.

The Docs side of the POC lives in a companion branch on the impress
repository.

Notes

  • Local dev config: shared placeholder token in env.d/development/common and
    an impress client in the Keycloak realm so both apps share the same
    identity provider.
  • e2e tests are intentionally not covered at this stage (POC).

Resources hosted by other applications (e.g. Docs documents) need to
live in the Drive tree next to regular files. A metadata.external_app
marker turns a FILE item into a pointer: it carries no filename and no
physical upload, is ready as soon as created, and can hold children so
an app can model sub-resources. Abilities gate every file-only feature
(download, wopi, upload, convert) and soft delete now propagates to
descendants of such items like it does for folders.
External apps integrated in the tree must enforce the exact same
permissions as Drive without duplicating them. A static bearer token
identifies the trusted app and the X-User-Sub/X-User-Email headers name
the acting user, so every existing endpoint keeps its permission logic.
Without identity headers the caller acts for an anonymous visitor,
which makes public-link reach work end to end. The returned "s2s" auth
tag lets views detect these calls to prevent notification loops.
Integrating a new application must not require touching the item views.
Each app configured in EXTERNAL_APPS provides a backend implementing a
small contract (create, delete, restore, purge resources) resolved by
name from the item metadata. The Docs backend is the first
implementation, calling the Docs server-to-server endpoints. The
FRONTEND_DOCS_URL setting is kept as a real setting because the config
endpoint exposes it to the frontend.
The external app must mirror what happens to its pointer items in
Drive. Creating one from Drive triggers the app back-channel (rolled
back if the app fails), and trash, restore and purge notify the app for
every pointer of the affected subtree. The purge task carries a
backstop notification so the cron path is covered too; app endpoints
are idempotent so retries are safe. Server-to-server calls skip all
hooks because the app initiated the operation itself.

Sub-documents (children of a pointer item) are hidden from all listing
views so only the document root surfaces in the UI, while the new
tree-descendants action returns the whole document tree to the app.
Docs documents live in the tree as pointer items, so the explorer needs
to treat them specially: a dedicated create menu entry posts an item
carrying the docs metadata (same UX as template files, no auto-open),
the grid shows the Docs icon, and clicking one opens the Docs frontend
instead of the preview. The file preview route hands over to Docs too,
so shared links to the item keep working.
Running the POC locally needs the two apps to trust each other: a dev
placeholder token shared by both directions of the server-to-server
API, the Docs URLs resolvable from the compose network, and an impress
client in the Keycloak realm so Docs signs in on Drive's identity
provider (single session across both apps).
@sonarqubecloud

Copy link
Copy Markdown

)
item.soft_delete()
item.delete()
raise drf.exceptions.APIException(detail=str(exc)) from exc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants