3liz / py-qgis-server

QGIS embbeded WMS/WFS/WCS asynchronous scalable http server
https://docs.3liz.org/py-qgis-server
Mozilla Public License 2.0
68 stars 16 forks source link

Management API - Strip the root directory from the "link" property of the project cache #40

Closed mdouchin closed 1 year ago

mdouchin commented 2 years ago

When the projects cache root directory is configured like

[projects.cache]
strict_check = false
rootdir = /srv/lizmap/accounts
size = 50
advanced_report = yes

The entrypoint /pool/ returns a wrong URL in the link property, for example

        {
          "filename": "/srv/lizmap/accounts/foo/instances/dev/data/qgis/rep1/bar.qgs",
          "key": "/srv/lizmap/accounts/foo/instances/dev/data/qgis/rep1/bar.qgs",
          "last_modified": "2022-03-29T04:23:58",
          "link": "http://172.16.0.188:7001/cache//srv/lizmap/accounts/foo/instances/dev/data/qgis/rep1/bar.qgs",
          "num_layers": 16
        }

the link property should return http://172.16.0.188:7001/cache/foo/instances/dev/data/qgis/rep1/bar.qgs

dmarteau commented 2 years ago

Fixed in https://github.com/3liz/py-qgis-server/commit/cdea27dbe10b5d8d12c370a31319f9f1494f5300

the link property should return http://172.16.0.188:7001/cache/foo/instances/dev/data/qgis/rep1/bar.qgs

No really because Lizmap send the absolute path of the project in the MAP parameter and this parameter is used as caching key; this is ok because the path is under the rootdir parameter (and the file: protocol is the default protocol) and it is expected that the client use consistent MAP values.

dmarteau commented 2 years ago

As said in the previous comment: path in in links are consistent with the MAP parameter received by the qgis server as sent by Lizmap (there is no awarness on how lizmap build the project path).

The configuration CACHE_ROOTDIR only ensure that file paths are not outside the configured cache (for security reason).

dmarteau commented 2 years ago

If you want path relative to rootdir you must ensure that Lizmap send relative url's to py-qgis-server.

Note that the fact that py-qgis-server accepts path absolute with respect to the rootdir is a convenience atm for Lizmap support because Lizmap send the absolute full path in the MAP parameter.

I though that Lizmap was supporting relative URL now, is that actually the case ?

dmarteau commented 1 year ago

@mdouchin This has been fixed in https://github.com/3liz/py-qgis-server/commit/34af564cc8924d1e347e67df72008658df9f3873

In case the key start with '/' then the key will be returned as MAP parameter instead of url path.