camptocamp/c2cgeoportal — pull request #939 by asaunier (2014-04-03 16:17:04+00:00)
Title: Add layer-enabling substitution params

This PR uses the recent possibility (with C2C-built mapserver) to use runtime substitution variables in METADATA. As a result it is for instance possible to hide a protected layer from the GetCapabilities response by adding the following configuration in the LAYER definition (mapfile):

```
NAME "somelayername"
METADATA
"ows_enable_request" "%s_enable_somelayername%"
END
VALIDATION
"s_enable_somelayername" "^[a-zA-Z\!\*, ]*$"
"default_s_enable_somelayername" "!*"
END
```
=> by default the layer "somelayername" cannot be requested (GetCapabilities, GetMap, GetFeature, etc.).

When a user is authenticated, the mapserver proxy will retrieve the list of layernames available to the user (using joins between roles/restricted areas/layers) and automatically adds matching runtime substitution variables with value "** to the query string. In the example above: ``s_enable_somelayername=*``

The join query is inspired by the code in entry view:
https://github.com/camptocamp/c2cgeoportal/blob/1.4/c2cgeoportal/views/entry.py#L129-L137

__More work is required__
At the moment a problem remains because when the application loads an internat getcapabilities is performed, but without the substitution variable (perhaps there's also a problem with the caching tool):
https://github.com/camptocamp/c2cgeoportal/blob/1.4/c2cgeoportal/views/entry.py#L79