Commit Graph

1211 Commits

Author SHA1 Message Date
Samuel Paccoud - DINUM
f717a39109 🐛(backend) fix link definition select options linked to ancestors
We were returning too many select options for the restricted link reach:
- when the "restricted" reach is an option (key present in the returned
  dictionary), the possible values for link roles are now always None to
  make it clearer that they don't matter and no select box should be
  shown for roles.
- Never propose "restricted" as option for link reach when the ancestors
  already offer a public access. Indeed, restricted/editor was shown when
  the ancestors had public/read access. The logic was to propose editor
  role on more restricted reaches... but this does not make sense for
  restricted since the role does is not taken into account for this reach.
  Roles are set by each access line assign to users/teams.
2025-07-08 13:53:16 +02:00
Samuel Paccoud - DINUM
04b8400766 (backend) add max_role field to the document access API endpoint
The frontend needs to know what to display on an access. The maximum
role between the access role and the role equivalent to all accesses
on the document's ancestors should be computed on the backend.
2025-07-08 13:53:16 +02:00
Samuel Paccoud - DINUM
d232654c55 ♻️(backend) simplify further select options on link reach/role
We reduce the number of options even more by treating link reach
and link role independently: link reach must be higher than its
ancestors' equivalent link reach and link role must be higher than
its ancestors' link role.

This reduces the number of possibilities but we decided to start
with the most restrictive and simple offer and extend it if we
realize it faces too many criticism instead of risking to offer
too many options that are too complex and must be reduced afterwards.
2025-07-08 13:53:16 +02:00
Samuel Paccoud - DINUM
d0eb2275e5 🐛(backend) fix creating/updating document accesses for teams
This use case was forgotten when the support for team accesses
was added. We add tests to stabilize the feature and its security.
2025-07-08 13:53:16 +02:00
Samuel Paccoud - DINUM
50faf766c8 (backend) add document path and depth to accesses endpoint
The frontend requires this information about the ancestor document
to which each access is related. We make sure it does not generate
more db queries and does not fetch useless and heavy fields from
the document like "excerpt".
2025-07-08 13:53:15 +02:00
Samuel Paccoud - DINUM
433cead0ac 🐛(backend) allow creating accesses when privileged by heritage
We took the opportunity of this bug to refactor serializers and
permissions as advised one day by @qbey: no permission checks in
serializers.
2025-07-08 13:53:15 +02:00
Samuel Paccoud - DINUM
d12c637dad (backend) fix randomly failing test due to delay before check
There is a delay between the time the signature is issued and the
time it is checked. Although this delay is minimal, if the signature
is issued at the end of a second, both timestamps can differ of 1s.

> assert response["X-Amz-Date"] == timezone.now().strftime("%Y%m%dT%H%M%SZ")
AssertionError: assert equals failed '20250504T175307Z'  '20250504T175308Z'
2025-07-08 13:53:15 +02:00
Samuel Paccoud - DINUM
184b5c015b ♻️(backend) stop requiring owner for non-root documents
If root documents are guaranteed to have a owner, non-root documents
will automatically have them as owner by inheritance. We should not
require non-root documents to have their own direct owner because
this will make it difficult to manage access rights when we move
documents around or when we want to remove access rights for someone
on a document subtree... There should be as few overrides as possible.
2025-07-08 13:53:15 +02:00
Samuel Paccoud - DINUM
1ab237af3b (backend) add max ancestors role field to document access endpoint
This field is set only on the list view when all accesses for a given
document and all its ancestors are listed. It gives the highest role
among all accesses related to each document.
2025-07-08 13:52:35 +02:00
Samuel Paccoud - DINUM
f782a0236b ♻️(backend) optimize refactoring access abilities and fix inheritance
The latest refactoring in a445278 kept some factorizations that are
not legit anymore after the refactoring.

It is also cleaner to not make serializer choice in the list view if
the reason for this choice is related to something else b/c other
views would then use the wrong serializer and that would be a
security leak.

This commit also fixes a bug in the access rights inheritance: if a
user is allowed to see accesses on a document, he should see all
acesses related to ancestors, even the ancestors that he can not
read. This is because the access that was granted on all ancestors
also apply on the current document... so it must be displayed.

Lastly, we optimize database queries because the number of accesses
we fetch is going up with multi-pages and we were generating a lot
of useless queries.
2025-07-08 13:52:35 +02:00
Samuel Paccoud - DINUM
c1fc1bd52f (backend) add computed link reach and role to document API
On a document, we need to display the status of the link (reach and
role) taking into account the ancestors link reach/role as well as
the current document.
2025-07-08 13:52:35 +02:00
Samuel Paccoud - DINUM
1c34305393 (backend) add ancestors link reach and role to document API
On a document, we need to display the status of the link (reach and
role) as inherited from its ancestors.
2025-07-08 13:52:34 +02:00
Samuel Paccoud - DINUM
611ba496d2 ♻️(backend) simplify roles by returning only the max role
We were returning the list of roles a user has on a document (direct
and inherited). Now that we introduced priority on roles, we are able
to determine what is the max role and return only this one.

This commit also changes the role that is returned for the restricted
reach: we now return None because the role is not relevant in this
case.
2025-07-08 13:51:26 +02:00
Samuel Paccoud - DINUM
0a9a583a67 (backend) fix randomly failing test on user search
The user account created to query the API had a random email
that could randomly interfere with our search results.
2025-07-08 13:49:32 +02:00
Samuel Paccoud - DINUM
8f67e382ba ♻️(backend) refactor get_select_options to take definitions dict
This will allow us to simplify the get_abilities method. It is also
more efficient because we have computed this definitions dict and
the the get_select_options method was doing the conversion again.
2025-07-08 13:49:32 +02:00
Samuel Paccoud - DINUM
18d46acd75 (backend) give an order to choices
We are going to need to compare choices to materialize the fact that
choices are ordered. For example an admin role is higer than an
editor role but lower than an owner role.

We will need this to compute the reach and role resulting from all
the document accesses (resp. link accesses) assigned on a document's
ancestors.
2025-07-08 13:49:31 +02:00
Samuel Paccoud - DINUM
fae024229e (backend) we want to display ancestors accesses on a document share
The document accesses a user have on a document's ancestors also apply
to this document. The frontend needs to list them as "inherited" so we
need to add them to the list.
Adding a "document_id" field on the output will allow the frontend to
differentiate between inherited and direct accesses on a document.
2025-07-08 13:49:31 +02:00
Samuel Paccoud - DINUM
df2b953e53 ♻️(backend) factorize document query set annotation
The methods to annotate a document queryset were factorized on the
viewset but the correct place is the custom queryset itself now that
we have one.
2025-07-08 13:47:39 +02:00
Samuel Paccoud - DINUM
a7c91f9443 ♻️(backend) refactor resource access viewset
The document viewset was overriding the get_queryset method from its
own mixin. This was a sign that the mixin was not optimal anymore.
In the next commit I will need to complexify it further so it's time
to refactor the mixin.
2025-07-08 13:47:39 +02:00
Samuel Paccoud - DINUM
0a5887c162 ♻️(backend) remove different reach for authenticated and anonymous
If anonymous users have reader access on a parent, we were considering
that an edge use case was interesting: allowing an authenticated user
to still be editor on the child.

Although this use case could be interesting, we consider, as a first
approach, that the value it carries is not big enough to justify the
complexity for the user to understand this complex access right heritage.
2025-07-08 13:47:39 +02:00
Samuel Paccoud - DINUM
26c7af0dbf (backend) add ancestors links definitions to document abilities
The frontend needs to display inherited link accesses when it displays
possible selection options. We need to return this information to the
client.
2025-07-08 13:47:39 +02:00
Samuel Paccoud - DINUM
0499aec624 🐛(backend) fix link definition select options linked to ancestors
We were returning too many select options for the restricted link reach:
- when the "restricted" reach is an option (key present in the returned
  dictionary), the possible values for link roles are now always None to
  make it clearer that they don't matter and no select box should be
  shown for roles.
- Never propose "restricted" as option for link reach when the ancestors
  already offer a public access. Indeed, restricted/editor was shown when
  the ancestors had public/read access. The logic was to propose editor
  role on more restricted reaches... but this does not make sense for
  restricted since the role does is not taken into account for this reach.
  Roles are set by each access line assign to users/teams.
2025-07-08 13:46:38 +02:00
renovate[bot]
21624e9224 ⬆️(dependencies) update js dependencies 2025-07-07 19:27:46 +00:00
Manuel Raynaud
b0a9ce0938 📝(readme) clean README (#1129)
## Purpose

Clean readme
2025-07-07 16:17:05 +00:00
renovate[bot]
e256017628 ⬆️(dependencies) update python dependencies 2025-07-07 08:42:36 +00:00
Anthony LC
50ce604ade 🐛(frontend) fix circular dependencies
Seems to have some circular dependencies appearing.
We will import what we need directly from the
feature instead of the parent docs index file.
2025-07-07 10:21:10 +02:00
Anthony LC
55979e4370 🛂(frontend) block edition only when not alone
We added a system to know if a user is alone
on a document or not. We adapt the
frontend to block the edition only
when the user is not alone on the document.
2025-07-07 10:21:09 +02:00
Manuel Raynaud
9a8f952210 🚩(back) use existing no websocket feature flag
An already existing feature flag
COLLABORATION_WS_NOT_CONNECTED_READY_ONLY was used bu the frontend
application to disable or not the edition for a user not connected to
the websocket. We want to reuse it in the backend application to disable
or not the no websocket feature.
2025-07-07 10:21:09 +02:00
Manuel Raynaud
118804e810 (back) new endpoint document can_edit
The endpoint can_edit is added to the DocumentViewset, it will give the
information to the frontend application id the current user can edit the
Docs based on the no-websocket rules.
2025-07-07 10:20:12 +02:00
Manuel Raynaud
651f2d1d75 (back) check on document update if user can save it
When a document is updated, users not connected to the collaboration
server can override work made by other people connected to the
collaboration server. To avoid this, the priority is given to user
connected to the collaboration server. If the websocket property in the
request payload is missing or set to False, the backend fetch the
collaboration server to now if the user can save or not. If users are
already connected, the user can't save. Also, only one user without
websocket can save a connect, the first user saving acquire a lock and
all other users can't save.
To implement this behavior, we need to track all users, connected and
not, so a session is created for every user in the
ForceSessionMiddleware.
2025-07-07 10:15:22 +02:00
Manuel Raynaud
b96de36382 (y-provider) add endpoint returning document connection state
We need a new endpoint in the y-provider server allowing the backend to
retrieve the number of active connections on a document and if a session
key exists.
2025-07-07 10:15:20 +02:00
Stephan Meijer
65b6701708 ♻️(backend) pass API token to Yprovider with scheme Bearer
Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 17:11:20 +02:00
Stephan Meijer
0be366b7b6 ♻️(frontend) support Bearer in servers/y-provider
Support passing API Token as Bearer in the Authorization-header.

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 17:11:19 +02:00
Stephan Meijer
78a6772bab ♻️(backend) raw payloads on convert endpoint
Handle the raw payloads in requests and responses to convert-endpoint.

This change replaces Base64-encoded I/O with direct binary streaming,
yielding several benefits:
- **Network efficiency**: Eliminates the ~33% size inflation of Base64,
cutting bandwidth and latency.
- **Memory savings**: Enables piping DOCX (already compressed) buffers
straight to DocSpec API without holding, encoding and decoding multi-MB
payload in RAM.

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 17:11:15 +02:00
Stephan Meijer
fde520a6f3 ♻️(frontend) raw payloads on convert endpoint
Accept raw payload on convert-endpoint and respond with raw Yjs payload

This change replaces Base64-encoded I/O with direct binary streaming,
yielding several benefits:
- **Network efficiency**: Eliminates the ~33% size inflation of Base64,
cutting bandwidth and latency.
- **Memory savings**: Enables piping DOCX (already compressed) buffers
straight to DocSpec API without holding, encoding and decoding multi-MB
payload in RAM.

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 17:10:47 +02:00
Stephan Meijer
cef2d274fc ♻️(frontend) following HTTP standards on auth
Return 401 Unauthorized for missing/invalid API keys (per RFC 7235);
403 is reserved for valid-but-forbidden credentials.

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 17:05:13 +02:00
Stephan Meijer
a9db392a61 ♻️(frontend) simplify Express middleware
Simplify the use of middleware in Express

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 17:04:58 +02:00
Stephan Meijer
186ae952f5 (frontend) test successful conversion
Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 17:04:55 +02:00
Stephan Meijer
f3c9c41b86 (frontend) switch to vitest and enhance testability
Migrated from jest to vitest for server/y-provider, gaining faster runs,
esm-native support and cleaner mocking.

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 17:04:28 +02:00
Stephan Meijer
58bf5071c2 ♻️(backend) rename convert_markdown to convert (#1114)
Renamed the `convert_markdown` method to `convert` to prepare for an
all-purpose conversion endpoint, enabling support for multiple formats
and simplifying future extension.

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-04 13:30:32 +00:00
Manuel Raynaud
e148c237f1 🛂(back) restrict duplicate with accesses to admin or owner
Only admin or owner should be able to duplicate a document with existing
accesses.
2025-07-03 11:23:56 +02:00
Manuel Raynaud
e82e6a1fcf 🛂(back) restrict document's duplicate action to authenticated users
The duplicate was also able for anonynous user if they can read it. We
have to restrict it to at least reader authenticated otherwise no access
will be created on the duplicated document.
2025-07-03 11:23:56 +02:00
Anthony LC
fc1678d0c2 (frontend) Duplicate a doc
We can duplicate a document from the
tool options.
2025-07-03 11:23:55 +02:00
Anthony LC
2b2e81f042 ♻️(frontend) Simplify AGPL export pattern
We were maintaining two separate components
for AGPL and MIT license exports.
This commit consolidates the functionality into
a single component that handles both licenses,
simplifying the codebase and reducing duplication.
2025-07-02 15:06:37 +02:00
Stephan Meijer
c8ae2f6549 ♻️(backend) rename convert-markdown endpoint
Renamed the `convert-markdown` endpoint to `convert` as a
general-purpose conversion endpoint for integration with DocSpec
conversion (DOCX import), without altering its existing functionality.

In a future contribution, this endpoint will not only support conversion
from Markdown -> BlockNote -> Yjs but also directly BlockNote -> Yjs.

Signed-off-by: Stephan Meijer <me@stephanmeijer.com>
2025-07-02 14:49:02 +02:00
Manuel Raynaud
1d741871d7 (helm) allow to configure cronjobs using backend image
We want to configure cronjobs. Instead of declaring them one by one, we
use a CronJobList, the will all have the same pattern, mostly the
command and the schedule will change.
2025-07-01 14:51:29 +02:00
soyouzpanda
6c3850b22b (frontend) support _FILE environment variables for secrets
Allow configuration variables that handles secrets to be read from a
file given in an environment variable.
2025-07-01 10:47:55 +02:00
soyouzpanda
31e8ed3a00 (backend) support _FILE environment variables for secrets
Allow configuration variables that handles secrets, like
`DJANGO_SECRET_KEY` to be able to read from a file which is given
through an environment file.

For example, if `DJANGO_SECRET_KEY_FILE` is set to
`/var/lib/docs/django-secret-key`, the value of `DJANGO_SECRET_KEY` will
be the content of `/var/lib/docs/django-secret-key`.
2025-07-01 10:32:55 +02:00
Manuel Raynaud
7e63e9e460 ♻️(back) exclude /admin from CSP rules
We have to exclude the /admin prefix to allow loading static files when
the django admin is used.
2025-06-30 14:46:01 +02:00
Anthony LC
388f71d9d0 (frontend) button access request on share modal
When a document is in public or connected mode,
users can now request access to the document.
2025-06-30 12:13:28 +02:00