RESTful User Management API
What is it?
The RESTful User Management API will allow users to be configured via a web-based service. Administrators will also be able to browse existing users using a normal web browser.
Motivation
There currently is no means of configuring the users on a Geoserver instance beyond manually editing the users.properties file in the data directory. Allowing users to be configured via a RESTful web service will allow developers to more easily create a web-based user management interface, which will facilitate both remote user configuration and configuration by less technical users. See RESTful Configuration API for more information about the REST philosophy.
Proposed API
These URI's are relative to the directory in which geoserver is running (http://localhost:8080/geoserver/ by default). The following chart outlines the results of different HTTP methods for each. You can browse the API with a regular web browser, but for PUT requests a tool like curl or restclient (http://restclient.org/) will be useful.
| URI | GET |
POST |
PUT |
DELETE |
|---|---|---|---|---|
| /users/user | Retrieve a list of all users |
- |
- |
- |
| /users/user/{name} | Retrieve details for the user with username {name} in {format}. If {format} is omitted, the information will be returned in HTML | - | Set the details for the user instead. | Remove the user account. |
Notes: For all URI's, a format may be specified by appending .{format} to the normal URI (for example, "GET /geoserver/users/user.json" retrieves the list of all users in JSON format). If no format is specified, the results will be returned in HTML. If visiting a "subdirectory" of a URL, the format must not be included (ie, "GET /geoserver/users/user/david" rather than "GET /geoserver/users/user.html/david")
Implementation
There is currently a (partial) implementation of this API in a community module named QueryUsers. In order to get it functioning, follow these steps:
1. Edit web/pom.xml; add a dependency that looks like this:
<dependency> <groupId>org.geoserver</groupId> <artifactId>QueryUsers</artifactId> <version>1.0</version> </dependency>
2. Edit web/src/main/webapp/WEB-INF/web.xml and add a servlet mapping that looks like this:
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/users/*</url-pattern> </servlet-mapping>
3. Open a terminal window in the QueryUsers module directory and run "mvn install"
4. Rebuild the web module before running Geoserver again. If you have not already built Geoserver, a full build will work as well.