cs3org / wopiserver

A vendor-neutral application gateway compatible with the WOPI specifications.
Apache License 2.0
55 stars 26 forks source link

Improve handling of globals #61

Open glpatcern opened 2 years ago

glpatcern commented 2 years ago

This refers in particular to the core code base and the storage interfaces.

osamaahmed17 commented 11 months ago

@glpatcern I am interested to work on this tasks during my free time. One question before I start working on MAC, do I have to make these folder in the laptops main directory such as (etc, var) or wopi server in the project directory? I have referenced it below.

Screenshot 2023-11-18 at 14 08 24
glpatcern commented 11 months ago

Hi there, those instructions refer to a production deployment, and as indicated they concern the system top-level folders. You can also run everything in a container, see the Dockerfile for details (where you see the same files in the container's top level folders).

osamaahmed17 commented 11 months ago

Thank you for the information. I was able to run the Wopi server on local in Ubuntu. When I go to http://192.168.1.106:8880/wopi , I get the follow screen.

Screenshot from 2023-12-06 00-58-19

However, when I go to any other route like "/wopi/iop/openinapp", it says "Client not authorized".

Furthermore, I researched some implementations for improving the handling of globals. One of the most elegant ways I was able to figure it out was by Flask. It provides the g object, which is a global namespace that can store data during the life of a request. @glpatcern , I would appreciate to know your opinion!

glpatcern commented 11 months ago

However, when I go to any other route like "/wopi/iop/openinapp", it says "Client not authorized".

That means you didn't provide the required authorization token.

Furthermore, I researched some implementations for improving the handling of globals. One of the most elegant ways I was able to figure it out was by Flask. It provides the g object, which is a global namespace that can store data during the life of a request.

If it only survives during the life of a request, it does not fit the purpose: as you can see in the code, there are a number of global variables that live "forever", until the server is shut down.

osamaahmed17 commented 11 months ago

Thank you for the information! I have got two more points. 🙂

glpatcern commented 11 months ago

How do I add an authorization token?

Please have a look at the examples such as https://github.com/cs3org/wopiserver/blob/master/tools/wopiopen.py

Well there is another method that involves Flask's configuration handling. It allows you to set global settings that are accessible across the entire application.

Can you share more details about this "other method"? Consider that here we're talking about global references to packages or classes, not just settings.

osamaahmed17 commented 11 months ago

For the first point, I am going through the file for authorization that you shared with me. 🙂

For the second point, I was considering putting all the globals in the app.config file and referencing them from there to get their value, but better global handling can also be achieved through custom Flask extensions or modules that encapsulate global references to packages or classes. It can help manage and organize these references more effectively.

osamaahmed17 commented 10 months ago

@glpatcern, I went through the file you shared with me and if the second point's method in the comment is fine for you, I will start working on this issue. 🙂

glpatcern commented 10 months ago

Hi there, to me it's not yet clear the method you want to pursue. Maybe you could start with a minimal modification and PR to validate the principle