GeoServer UI (http://localhost:8080/geoserver/web/) provides the means to configure the security of layergroups by granting read/write access to various roles. I would assume that the UI is simply a front-end on the REST API and that everything which can be achieved through the UI, can also be achieved via REST API directly.
I've tried a GET request on http://localhost:8080/geoserver/rest/security/acl/layergroups but received an error 404. This is to be expected, for according to the following API references, there is no endpoint for layergroups ACL:
- https://docs.geoserver.org/latest/en/user/rest/api/accesscontrol.html
- https://docs.geoserver.org/latest/en/api/#1.0.0/security.yaml
It would be nice if there were a separate endpoint for layergroups ACL. Apparently, after enabling read/write access of myrole
to mylayergroup
via GeoServer UI, the layergroups ACL settings show up in a GET request to the layers ACL:
GET http://localhost:8080/geoserver/rest/security/acl/layers
{'*.*.r': '*', '*.*.w': 'GROUP_ADMIN,ADMIN', 'mylayergroup.r': 'myrole', 'mylayergroup.w': 'myrole'}
However, GeoServer seems to expect layers ACL rules in the following format:
{'myworkspace.mylayer.r': 'myrole', 'myworkspace.mylayer.w': 'myrole'}
I tried a POST request with JSON payload in the same format as the UI seemed to have used, and got an error 422:
POST http://localhost:8080/geoserver/rest/security/acl/layers
JSON: {'mylayergroup.r': 'myrole', 'mylayergroup.w': 'myrole'}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 422 Invalid rule mylayergroup.r, the expected format is workspace.layer.mode=role1,role2,...</title>
</head>
<body>
<h2>HTTP ERROR 422</h2>
<p>Problem accessing /geoserver/rest/security/acl/layers. Reason:
<pre> Invalid rule mylayergroup.r, the expected format is workspace.layer.mode=role1,role2,...
</pre>
</p>
<hr>
<a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.18.v20190429</a>
<hr/>
</body>
</html>
How to configure the layergroups ACL via REST API?