Skip to content

Commit

Permalink
Incorporate X-Forwarded-Prefix into url key of PATCH Workspace Layer
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Sep 13, 2023
1 parent a124405 commit b3d34ef
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- [#765](https://github.com/LayerManager/layman/issues/765) Remove `authn.txt` files from workspace directories. The same information as in `authn.txt` files is saved in prime DB schema.
- [#868](https://github.com/LayerManager/layman/issues/868) Fill table `map_layer` with relations between maps and [internal layers](doc/models.md#internal-map-layer) (layers published on this Layman instance). Relations to [external layers](doc/models.md#internal-map-layer) (layers of other servers) are not imported into the table.
### Changes
- [#868](https://github.com/LayerManager/layman/issues/868) Endpoints [GET Publications](doc/rest.md#get-publications), [GET Layers](doc/rest.md#get-layers), [GET Workspace Layers](doc/rest.md#get-workspace-layers), [GET Maps](doc/rest.md#get-maps), [GET Workspace Maps](doc/rest.md#get-workspace-maps), [GET Workspace Layer](doc/rest.md#get-workspace-layer), [GET Workspace Map](doc/rest.md#get-workspace-map), [POST Workspace Layers](doc/rest.md#post-workspace-layers), [DELETE Workspace Layer](doc/rest.md#delete-workspace-layer), [DELETE Workspace Layers](doc/rest.md#delete-workspace-layers), [DELETE Workspace Map](doc/rest.md#delete-workspace-map), [DELETE Workspace Maps](doc/rest.md#delete-workspace-maps), [POST Workspace Maps](doc/rest.md#post-workspace-maps) and [WMS/WFS endpoints](doc/endpoints.md) respects [HTTP header `X-Forwarded-Prefix`](doc/client-proxy.md#x-forwarded-prefix-http-header) of the request in the response.
- [#868](https://github.com/LayerManager/layman/issues/868) Endpoints [GET Publications](doc/rest.md#get-publications), [GET Layers](doc/rest.md#get-layers), [GET Workspace Layers](doc/rest.md#get-workspace-layers), [GET Maps](doc/rest.md#get-maps), [GET Workspace Maps](doc/rest.md#get-workspace-maps), [GET Workspace Layer](doc/rest.md#get-workspace-layer), [GET Workspace Map](doc/rest.md#get-workspace-map), [POST Workspace Layers](doc/rest.md#post-workspace-layers), [DELETE Workspace Layer](doc/rest.md#delete-workspace-layer), [DELETE Workspace Layers](doc/rest.md#delete-workspace-layers), [DELETE Workspace Map](doc/rest.md#delete-workspace-map), [DELETE Workspace Maps](doc/rest.md#delete-workspace-maps), [POST Workspace Maps](doc/rest.md#post-workspace-maps), [PATCH Workspace Layer](doc/rest.md#patch-workspace-layer) and [WMS/WFS endpoints](doc/endpoints.md) respects [HTTP header `X-Forwarded-Prefix`](doc/client-proxy.md#x-forwarded-prefix-http-header) of the request in the response.
- [#868](https://github.com/LayerManager/layman/issues/868) Relations between map and [internal layers](doc/models.md#internal-map-layer) are updated in `map_layer` table when calling [POST Workspace Maps](doc/rest.md#post-workspace-maps), [DELETE Workspace Map](doc/rest.md#delete-workspace-map), and [DELETE Workspace Maps](doc/rest.md#delete-workspace-maps).
- [#880](https://github.com/LayerManager/layman/issues/880) Use Docker Compose v2 (`docker compose`) in Makefile without `compatibility` flag and remove `Makefile_docker-compose_v1` file. Docker containers are named according to Docker Compose v2 and may have different name after upgrade.
- [#765](https://github.com/LayerManager/layman/issues/765) Stop saving OAuth2 claims in filesystem, use prime DB schema only.
Expand Down
7 changes: 7 additions & 0 deletions doc/client-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ Currently, value of `X-Forwarded-Prefix` affects following URLs:
* `url` key
* [POST Workspace Maps](rest.md#post-workspace-maps)
* `url` key
* [PATCH Workspace Layer](rest.md#patch-workspace-layer)
* `url` key
* `wms`.`url` key
* `wfs`.`url` key
* `style`.`url` key
* `thumbnail`.`url` key
* `metadata`.`comparison_url` key
* [OGC endpoints](endpoints.md)
* Headers `X-Forwarded-Proto`, `X-Forwarded-Host`, `X-Forwarded-For`, `X-Forwarded-Path`, `Forwarded` and `Host` are ignored
* [WMS endpoints](endpoints.md#web-map-service)
Expand Down
4 changes: 3 additions & 1 deletion src/layman/layer/rest_workspace_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def get(workspace, layername):
def patch(workspace, layername):
app.logger.info(f"PATCH Layer, actor={g.user}")

x_forwarded_prefix = layman_util.get_x_forwarded_prefix(request.headers)

info = layman_util.get_publication_info(workspace, LAYER_TYPE, layername,
context={'keys': ['title', 'name', 'description', 'table_uri', 'geodata_type', 'style_type',
'original_data_source', ]})
Expand Down Expand Up @@ -260,7 +262,7 @@ def patch(workspace, layername):
)

app.logger.info('PATCH Layer changes done')
info = util.get_complete_layer_info(workspace, layername)
info = util.get_complete_layer_info(workspace, layername, x_forwarded_prefix=x_forwarded_prefix)
info.update(layer_result)

return jsonify(info), 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@ def test_publication(self, publication, rest_method):
publication_response = response[0] if isinstance(response, list) and len(response) == 1 else response
if rest_method == self.patch_publication:
exp_resp = {
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}',
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}',
'thumbnail': {
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/rest/workspaces/{publication.workspace}/layers/{publication.name}/thumbnail'
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/thumbnail'
},
'metadata': {
'comparison_url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/rest/workspaces/{publication.workspace}/layers/{publication.name}/metadata-comparison',
'comparison_url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/metadata-comparison',
},
'wms': {
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/geoserver/{publication.workspace}_wms/ows',
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/geoserver/{publication.workspace}_wms/ows',
},
'sld': {
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/rest/workspaces/{publication.workspace}/layers/{publication.name}/style',
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/style',
},
'style': {
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/rest/workspaces/{publication.workspace}/layers/{publication.name}/style',
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/layers/{publication.name}/style',
},
}

geodata_type = response['geodata_type']
if geodata_type == settings.GEODATA_TYPE_VECTOR:
exp_resp['wfs'] = {
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/geoserver/{publication.workspace}/wfs'
'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/geoserver/{publication.workspace}/wfs'
}
else:
exp_resp = {'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}{proxy_prefix}/rest/workspaces/{publication.workspace}/{publication.type.split(".")[1]}s/{publication.name}'}
Expand Down

0 comments on commit b3d34ef

Please sign in to comment.