userrole.rst 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. .. _rest_api_user_roles:
  2. Users/Groups and Roles
  3. ======================
  4. Security
  5. --------
  6. The Users/Groups and Roles Rest API is only accessible to users with the role ROLE_ADMIN.
  7. Input/Output
  8. ------------
  9. Data Object Transfer
  10. ~~~~~~~~~~~~~~~~~~~~
  11. Both XML and JSON are supported for transfer of data objects. The default is XML. Alternatively, JSON may be used by setting the 'content-type' (POST) and 'accept' (GET) http headers to 'application/json' in your requests.
  12. Encoding of a user in XML::
  13. <user>
  14. <userName>..</userName>
  15. <password>..</password>
  16. <enabled>true/false</enabled>
  17. </user>
  18. Encoding of a user in JSON::
  19. {"userName": "..", "password": "..", enabled: true/false}
  20. Passwords are left out in results of reading requests.
  21. Encoding of a list of users in XML::
  22. <users>
  23. <user> ... </user>
  24. <user> ... </user>
  25. ...
  26. </users>
  27. Encoding of a list of users in JSON::
  28. {"users":[ {..}, {..}, .. ]}
  29. Encoding of a list of groups in XML::
  30. <groups>
  31. <group> agroupname </group>
  32. <group> bgroupname </group>
  33. ...
  34. </groups>
  35. Encoding of a list of groups in JSON::
  36. {"groups":[ {..}, {..}, .. ]}
  37. Encoding of a list of roles::
  38. <roles>
  39. <role> arolename </role>
  40. <role> brolename </role>
  41. ...
  42. </roles>
  43. Encoding of a list of roles in JSON::
  44. {"roles":[ {..}, {..}, .. ]}
  45. Configuration
  46. -------------
  47. The default user/group service is by default the service named "default". This can be
  48. altered in the following manner:
  49. #. Start geoserver with the following java system property present::
  50. org.geoserver.rest.DefaultUserGroupServiceName=<name_of_usergroupservice>
  51. Requests
  52. --------
  53. ``/rest/usergroup/[service/<serviceName>/]users/``
  54. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. Query all users or add a new user in a particular or the default user/group service.
  56. .. list-table::
  57. :header-rows: 1
  58. :widths: 10 20 20
  59. * - Method
  60. - Action
  61. - Response
  62. * - GET
  63. - List all users in service.
  64. - 200 OK. List of users in XML.
  65. * - POST
  66. - Add a new user
  67. - 201 Inserted. Created ``ID`` header.
  68. ``/rest/usergroup/[service/<serviceName>/]user/<user>``
  69. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  70. Query, modify or delete a specific user in a particular or the default user/group service.
  71. .. list-table::
  72. :header-rows: 1
  73. :widths: 10 20 20
  74. * - Method
  75. - Action
  76. - Response
  77. * - GET
  78. - Read user information
  79. - 200 OK. User in XML.
  80. * - POST
  81. - Modify the user, unspecified fields remain unchanged.
  82. - 200 OK.
  83. * - DELETE
  84. - Delete the user
  85. - 200 OK.
  86. ``/rest/usergroup/[service/<serviceName>/]groups/``
  87. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. Query all groups in a particular user/group or the default service.
  89. .. list-table::
  90. :header-rows: 1
  91. :widths: 10 20 20
  92. * - Method
  93. - Action
  94. - Response
  95. * - GET
  96. - List all groups in service.
  97. - 200 OK. List of groups in XML.
  98. ``/rest/usergroup/[service/<serviceName>/]group/<group>``
  99. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100. Add or delete a specific group in a particular or the default user/group service.
  101. .. list-table::
  102. :header-rows: 1
  103. :widths: 10 20 20
  104. * - Method
  105. - Action
  106. - Response
  107. * - POST
  108. - Add the group.
  109. - 200 OK.
  110. * - DELETE
  111. - Delete the group.
  112. - 200 OK.
  113. ``/rest/usergroup/[service/<serviceName>/]user/<user>/groups``
  114. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115. Query all groups associated with a user in a particular or the default user/group service.
  116. .. list-table::
  117. :header-rows: 1
  118. :widths: 10 20 20
  119. * - Method
  120. - Action
  121. - Response
  122. * - GET
  123. - List all groups associated with user.
  124. - 200 OK. List of groups in XML.
  125. ``/rest/usergroup/[service/<serviceName>/]group/<group>/users``
  126. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  127. Query all users associated with a group in a particular or the default user/group service.
  128. .. list-table::
  129. :header-rows: 1
  130. :widths: 10 20 20
  131. * - Method
  132. - Action
  133. - Response
  134. * - GET
  135. - List all users associated with group.
  136. - 200 OK. List of groups in XML.
  137. ``/rest/usergroup/[service/<serviceName>/]<user>/group/<group>``
  138. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. Associate or disassociate a specific user with a specific group in a particular or the default user/group service.
  140. .. list-table::
  141. :header-rows: 1
  142. :widths: 10 20 20
  143. * - Method
  144. - Action
  145. - Response
  146. * - POST
  147. - Associate the user with the group.
  148. - 200 OK.
  149. * - DELETE
  150. - Disassociate the user from the group.
  151. - 200 OK.
  152. ``rest/roles/[service/{serviceName}/]``
  153. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  154. Query all roles in a particular role service or the active role service.
  155. .. list-table::
  156. :header-rows: 1
  157. :widths: 10 20 20
  158. * - Method
  159. - Action
  160. - Response
  161. * - GET
  162. - List all roles in service.
  163. - 200 OK. List of roles in XML.
  164. ``/rest/roles/[service/<serviceName>/]role/<role>``
  165. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  166. Add or delete a specific role in a particular role service or the active role service.
  167. .. list-table::
  168. :header-rows: 1
  169. :widths: 10 20 20
  170. * - Method
  171. - Action
  172. - Response
  173. * - POST
  174. - Add the role.
  175. - 200 OK.
  176. * - DELETE
  177. - Delete the role.
  178. - 200 OK.
  179. ``/rest/roles/[service/<serviceName>/]<serviceName>/user/<user>/roles``
  180. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  181. Query all roles associated with a user in a particular role service or the active role service.
  182. .. list-table::
  183. :header-rows: 1
  184. :widths: 10 20 20
  185. * - Method
  186. - Action
  187. - Response
  188. * - GET
  189. - List all roles associated with user.
  190. - 200 OK. List of roles in XML.
  191. ``/rest/roles/[service/<serviceName>/]role/<role>/user/<user>/``
  192. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  193. Associate or disassociate a specific user with a specific role in a particular role service or the active role service.
  194. .. list-table::
  195. :header-rows: 1
  196. :widths: 10 20 20
  197. * - Method
  198. - Action
  199. - Response
  200. * - POST
  201. - Associate the user with the role.
  202. - 200 OK.
  203. * - DELETE
  204. - Disassociate the user from the role.
  205. - 200 OK.