tuwien-csd / damap-backend

MIT License
5 stars 6 forks source link

Live DMP Export Preview #259

Open GeoffreyKarnbach opened 1 week ago

GeoffreyKarnbach commented 1 week ago

Description

When working on a DMP (either during development to try out template changes, or as a user), to check out the current export state, a Word Document has to be exported everytime.

In order to enhance productivity, a Live Preview of the DMP Export would be very useful.

Proposed solution

There are two approaches, that may both be explored for displaying the preview in the Frontend:

Both approaches have advantages and disadvantages:

In addition to the location in the frontend, different technical challenges regarding the rendering and backend exist:

The approach to offer in localhost and in a deployed environment the live preview feature would be:

As mentioned before, the files need to be "publicly" available for the Microsoft Iframe to be able to access them. As the IFrame may also take API requests as input (as long as a Word Document is returned), following approach would lead to better security:

Through this approach, the "public" files, are protected by a 32 characters UUID name (that would have to be guessed) and a 64 characters password within a "short" timeframe, making it effectively not feasible for an attacker (same would apply to any other endpoint if a JWT is leaked, the password has to be treated as an authentication/access token).

This approach would furthermore allow users to generate exported documents, that can be shared using an URL and the password as query param to any non authenticated user.

An approach to persisting those temporary files would be to the "temp" environment of the operating system (%TEMP% for windows, /var/tmp or /tmp for Unix).

Alternative solution Generate a PDF on Server Side from the Word Document (no feasible approach was found, possible with libraries, but requires Microsoft Word to be installed in the Server Environment => not easily possible in Linux). This approach would make the entire approach easier, as rendering a PDF in the Frontend is trivial.

rekt-hard commented 1 week ago

Possible solution for converting the document to PDF:

GeoffreyKarnbach commented 1 week ago

Current prototype implementation in those branches:

https://github.com/tuwien-csd/damap-backend/tree/gk/252-preselection-of-the-template-real-time-view https://github.com/tuwien-csd/damap-frontend/tree/gk/252-preselection-of-the-template-real-time-view