2

Is it possible to create GeoServer users for a list of usernames (and associated passwords) in one batch? (similar to using the Linux newusers command to create multiple users)

I've asked a related question about How to batch create GeoServer stores for each user?. It seems that that's possible with the GeoServer RESTful API.

But how about the GeoServer users themselves?

Can I also batch create the users as well?

I searched about REST API for creating users/roles, but couldn't find anything.


I've tried the Geofence rest API as suggested: I deployed both geoserver-2.8-SNAPSHOT-geofence-plugin.zip and geoserver-2.8-SNAPSHOT-geofence-server-plugin.zip, rebooted, and when I used the REST API with

curl -v -u admin:geoserver -X POST -H "Content-type: text/xml" -d "<User> <username>testu</username> </User>" http://localhost/geoserver/rest/usergroup/users

, I got the following error, no user is added. Any ideas what I am doing wrong or any suggestions? (I can't change the system configuration files, so REST API is preferable.)

Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'admin'
> POST /geoserver/rest/usergroup/users HTTP/1.1
> Host: localhost
> Authorization: Basic XXXXXXXXXXXXXX
> User-Agent: curl/7.47.0
> Accept: */*
> Content-type: text/xml
> Content-Length: 41
> 
* upload completely sent off: 41 out of 41 bytes
< HTTP/1.1 405 Method Not Allowed
< Date: Tue, 24 Jan 2017 04:57:58 GMT
< Server: Noelios-Restlet-Engine/1.0..8
< Allow: GET
< Content-Length: 0
< 
* Connection #0 to host localhost left intact
1

2 Answers 2

2

As far as I'm aware, No. The GeoServer documentation does not allude to the possibility, and only discusses single user creation.

Furthermore, when following OpenGeo Suite tutorial on working on creating multiple users, they go through the process of showing how to create a user and then the following steps to create multiple users is the repeat the steps of creating a single user.

Click Add new user again and repeat the above process, creating two new users, private_viewer and private_edit, and associating them with the ROLE_PRIVATE and ROLE_PRIVATEEDIT roles, respectively.

I've search for this capability as well to no avail in other forums, blogs etc...

2

You can't do it via the web interface but you can do it by editing the users.xml file directly or using the rest API.

You can edit the file here:

security/usergroup/{group-name}/users.xml

Or you can use the REST API:

http://docs.geoserver.org/latest/en/user/community/geofence-server/rest-userrole.html

It's recommended that you use encrypted passwords, but to get the ball rolling you can use plain text passwords, e.g.

plain:mypassword

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.