tutorial.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. Using the Internal GeoFence server (Tutorial)
  2. =============================================
  3. Introduction
  4. ------------
  5. This tutorial shows how to install and configure the :ref:`community_geofence_server` plug-in. It shows how to create rules in two ways: using the GUI and REST methods.
  6. The tutorial assumes:
  7. * GeoServer is running on http://localhost:8080/geoserver
  8. * You have a user/group service called "default" that allows the creation of new users. If your primary user/group service is not called "default", you must start geoserver with the following java system property present::
  9. org.geoserver.rest.DefaultUserGroupServiceName=<name_of_usergroupservice>
  10. with <name_of_usergroupservice> a user/group service that allows the creation of new users.
  11. Getting Started
  12. ---------------
  13. Install the plugin-in, see :ref:`geofence_server_install`. Configure the user/group service as described above if necessary.
  14. Restart GeoServer.
  15. .. note:: Since we defined no rules yet, the default behavior of GeoFence is to deny access to all resources.
  16. There should now be a :guilabel:`GeoFence Data Rules` link on the left side of the screen after logging in. Click on it.
  17. This is the configuration page of your internal GeoFence.
  18. .. figure:: images/tutorial_rulespage1.png
  19. :align: center
  20. Creating new Rules with the GUI
  21. -------------------------------
  22. 1. Click on the "Add new rule" link. Change only "Access" to "DENY".
  23. .. figure:: images/tutorial_rulepage1.png
  24. :align: center
  25. Click on "Save".
  26. .. figure:: images/tutorial_rulespage2.png
  27. :align: center
  28. We have now expressed that the first rule (with lowest priority) disallows everyone from everything. The following more specific rules we make will provide the exceptions to that general rule. It is also possible to do it the other way (allow everyone to anything as most general rule and specify exceptions to that.)
  29. 2. As a next step, we will grant the administrator access to everything. Click on "Add new rule" again. Change "Role" to "ADMIN" and click "Save".
  30. .. figure:: images/tutorial_rulepage2.png
  31. :align: center
  32. .. figure:: images/tutorial_rulespage3.png
  33. :align: center
  34. You now have a working, basic security configuration.
  35. Creating rules with the REST API
  36. --------------------------------
  37. 1. Open a new tab with your browser and go to the following URL: http://localhost:8080/geoserver/geofence/rest/rules.
  38. You should get an XML representation of your rules::
  39. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  40. <Rules count="2">
  41. <Rule id="2">
  42. <access>ALLOW</access>
  43. <priority>0</priority>
  44. <roleName>ADMIN</roleName>
  45. </Rule>
  46. <Rule id="1">
  47. <access>DENY</access>
  48. <priority>1</priority>
  49. </Rule>
  50. </Rules>
  51. 2. Let us first create a new user.
  52. Do this by sending a POST request to the following URL http://localhost:8080/geoserver/rest/security/usergroup/users with the following content::
  53. <user>
  54. <userName>michaeljfox</userName>
  55. <password>back2$future</password>
  56. <enabled>true</enabled>
  57. </user>
  58. You should receive a ``201 Created`` HTTP Response.
  59. 3. Now we will create an access rule for this user.
  60. Do this by sending a POST request to the following URL: http://localhost:8080/geoserver/geofence/rest/rules with the following content::
  61. <Rule>
  62. <userName>michaeljfox</userName>
  63. <workspace>topp</workspace>
  64. <layer>states</layer>
  65. <service>WMS</service>
  66. <request>GetMap</request>
  67. <access>ALLOW</access>
  68. </Rule>
  69. Again, you should receive a ``201 Created`` HTTP Response.
  70. When browsing to the URL http://localhost:8080/geoserver/geofence/rest/rules we should now see the following information::
  71. <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  72. <Rules count="2">
  73. <Rule id="3">
  74. <access>ALLOW</access>
  75. <layer>states</layer
  76. <priority>0</priority>
  77. <request>GETMAP</request>
  78. <service>WMS</service>
  79. <userName>michaeljfox</userName>
  80. <workspace>topp</workspace>
  81. </Rule>
  82. <Rule id="2">
  83. <access>ALLOW</access>
  84. <priority>0</priority>
  85. <roleName>ADMIN</roleName>
  86. </Rule>
  87. <Rule id="1">
  88. <access>DENY</access>
  89. <priority>1</priority>
  90. </Rule>
  91. </Rules>
  92. 4. It should now be possible to log on with username ``michaeljfox`` and password ``back2$future`` and perform a ``GetMap`` on the layer ``topp:states``, but nothing else.