index.rst 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. .. _security_tutorials_ldap:
  2. Authentication with LDAP
  3. ========================
  4. This tutorial introduces GeoServer LDAP support and walks through the process of
  5. setting up authentication against an LDAP server. It is recommended that the
  6. :ref:`security_auth_provider_ldap` section be read before proceeding.
  7. LDAP server setup
  8. -----------------
  9. A mock LDAP server will be used for this tutorial. Download and run the `acme-ldap <https://geoserver.org/acme-ldap/acme-ldap-1.0.jar>`_ jar::
  10. java -jar acme-ldap.jar
  11. The output of which should look like the following::
  12. Directory contents:
  13. ou=people,dc=acme,dc=org
  14. uid=bob,ou=people,dc=acme,dc=org
  15. uid=alice,ou=people,dc=acme,dc=org
  16. uid=bill,ou=people,dc=acme,dc=org
  17. ou=groups,dc=acme,dc=org
  18. cn=users,ou=groups,dc=acme,dc=org
  19. member: uid=bob,ou=people,dc=acme,dc=org
  20. member: uid=alice,ou=people,dc=acme,dc=org
  21. cn=admins,ou=groups,dc=acme,dc=org
  22. member: uid=bill,ou=people,dc=acme,dc=org
  23. Server running on port 10389
  24. The following diagram illustrates the hierarchy of the LDAP datatabse:
  25. .. figure:: images/acme_ldap.png
  26. :align: center
  27. The LDAP tree consists of:
  28. * The root domain component, ``dc=acme,dc=org``
  29. * Two organizational units (groups) named ``user`` and ``admin``
  30. * Two users named ``bob`` and ``alice`` who are members of the ``user`` group
  31. * One user named ``bill`` who is a member of the ``admin`` group
  32. Configure the LDAP authentication provider
  33. ------------------------------------------
  34. #. Start GeoServer and login to the web admin interface as the ``admin`` user.
  35. #. Click the ``Authentication`` link located under the ``Security`` section of
  36. the navigation sidebar.
  37. .. figure:: images/ldap1.jpg
  38. :align: center
  39. #. Scroll down to the ``Authentication Providers`` panel and click the ``Add new`` link.
  40. .. figure:: images/ldap2.jpg
  41. :align: center
  42. #. Click the ``LDAP`` link.
  43. .. figure:: images/ldap3.jpg
  44. :align: center
  45. #. Fill in the fields of the settings form as follows:
  46. * Set ``Name`` to "acme-ldap"
  47. * Set ``Server URL`` to "ldap://localhost:10389/dc=acme,dc=org"
  48. * Set ``User lookup pattern`` to "uid={0},ou=people"
  49. #. Test the LDAP connection by entering the username "bob" and password "secret"
  50. in the connection test form located on the right and click the
  51. ``Test Connection`` button.
  52. .. figure:: images/ldap4.jpg
  53. :align: center
  54. A successful connection should be reported at the top of the page.
  55. #. Save.
  56. #. Back on the authentication page scroll down to the ``Provider Chain`` panel
  57. and move the ``acme-ldap`` provider from ``Available`` to ``Selected``.
  58. .. figure:: images/ldap5.jpg
  59. :align: center
  60. #. Save.
  61. Test a LDAP login
  62. -----------------
  63. #. Navigate to the GeoServer home page and log out of the admin account.
  64. #. Login as the user "bob" with the password "secret".
  65. .. figure:: images/ldap6.jpg
  66. :align: center
  67. Logging in as bob doesn't yield any administrative functionality because the bobaccount has not been mapped to the administrator role. In the next section
  68. GeoServer will be configured to map groups from the LDAP database to roles.
  69. Map LDAP groups to GeoServer roles
  70. ----------------------------------
  71. When using LDAP for authentication GeoServer maps LDAP groups to GeoServer roles
  72. by prefixing the group name with ``ROLE_`` and converting the result to
  73. uppercase. For example bob and alice are members of the ``user`` group so after
  74. authentication they would be assigned a role named ``ROLE_USER``. Similarly
  75. bill is a member of the ``admin`` group so he would be assigned a role named
  76. ``ROLE_ADMIN``.
  77. #. Log out of the web admin and log back in as the admin user.
  78. #. Navigate to the ``Authentication`` page.
  79. #. Scroll to the ``Authentication Providers`` panel and click the ``acme-ldap``
  80. link.
  81. .. figure:: images/ldap7.jpg
  82. :align: center
  83. #. On the settings page fill in the following form fields:
  84. * Set ``Group search base`` to "ou=groups"
  85. * Set ``Group search filter`` to "member={0}"
  86. The first field specifies the node of the LDAP directory tree at which groups
  87. are located. In this case the organizational unit named ``groups``. The
  88. second field specifies the LDAP query filter to use in order to locate those
  89. groups that a specific user is a member of. The ``{0}`` is a placeholder
  90. which is replaced with the ``uid`` of the user.
  91. * Set ``Group to use as ADMIN`` to "ADMIN"
  92. * Set ``Group to use as GROUP_ADMIN`` to "ADMIN"
  93. If you want support for hierarchical LDAP groups:
  94. * Check :guilabel:`Enable Hierarchical groups search` box.
  95. * Set ``Max depth for hierarchical groups search`` to 10 (-1 for infinite depth, or the depth number you want to support).
  96. * Set ``Nested group search filter`` to "member={0}"
  97. .. figure:: images/ldap14.jpg
  98. :align: center
  99. These settings let users in the LDAP admin group to be recognized as GeoServer administrators.
  100. #. Save.
  101. At this point the LDAP provider will populate an authenticated user with roles
  102. based on the groups the user is a member of.
  103. At this point members of the ``admin`` LDAP group should be given full
  104. administrative privileges once authenticated. Log out of the admin account and
  105. log in as "bill" with the password "hello". Once logged in full administrative
  106. functionality should be available.
  107. Configure the LDAP role service
  108. ------------------------------------------
  109. An additional step permits to configure a role service to get GeoServer roles
  110. from the LDAP repository and allow access rights to be assigned to those roles.
  111. #. Click the ``Users,Group,Roles`` link located under the ``Security`` section
  112. of the navigation sidebar.
  113. #. Click the ``Add new link`` under the ``Role Services`` section.
  114. #. Click the ``LDAP`` option under the ``New Role Service`` section.
  115. .. figure:: images/ldap15.png
  116. :align: center
  117. #. Enter ``ldaprs`` in the ``Name`` text field.
  118. #. Enter ``ldap://localhost:10389/dc=acme,dc=org`` in the ``Server URL`` text field.
  119. #. Enter ``ou=groups`` in the ``Group search base`` text field.
  120. #. Enter ``member=uid={0},ou=people,dc=acme,dc=org`` in the ``Group user membership search filter`` text field.
  121. #. Enter ``cn=*`` in the ``All groups search filter`` text field.
  122. Then we need to a choose a user to authenticate on the server (many LDAP server don't allow anonymous data lookup).
  123. #. Check the ``Authenticate to extract roles`` checkbox.
  124. #. Enter ``uid=bill,ou=people,dc=acme,dc=org`` in the ``Username`` text field.
  125. #. Enter ``hello`` in the ``Password`` text field.
  126. If we want Hierarchical groups working we need:
  127. #. Check the ``Enable Hierarchical groups search`` checkbox.
  128. #. Enter ``10`` in the ``Max depth for hierarchical groups search`` text field.
  129. #. Enter ``member={1}`` in the ``Nested group search filter`` text field.
  130. #. Save.
  131. #. Click the ``ldaprs`` role service item under the ``Role Services`` section.
  132. #. Select ``ROLE_ADMIN`` from the ``Administrator role`` combo-box.
  133. #. Select ``ROLE_ADMIN`` from the ``Group administrator role`` combo-box.
  134. #. Save again.
  135. You should now be able to see and assign the new ``ROLE_ADMIN`` and ``ROLE_USER`` roles wherever an ``Available Roles`` list is shown (for example in the ``Data`` and ``Services`` rules sections.