index.rst 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. .. _security_tutorials_digest:
  2. Configuring Digest Authentication
  3. =================================
  4. Introduction
  5. ------------
  6. Out of the box GeoServer REST and OGC services support authentication via
  7. `HTTP Basic authentication <https://en.wikipedia.org/wiki/Basic_access_authentication>`__.
  8. One of the major downsides of basic auth is that it sends user passwords in
  9. plain text. `HTTP Digest authentication <https://en.wikipedia.org/wiki/Digest_access_authentication>`__ offers
  10. a more secure alternative that applies a cryptographic hash function to
  11. passwords before sending them over the network.
  12. This tutorial walks through the process of setting up digest authentication.
  13. Prerequisites
  14. -------------
  15. This tutorial uses the `curl <http://curl.haxx.se/>`_ utility to issue HTTP
  16. request that test authentication. Install curl before proceeding.
  17. .. note::
  18. Any utility that supports both basic and digest authentication can be used in
  19. place of curl. Most modern web browsers support both types of authentication.
  20. Configure the Digest authentication filter
  21. ------------------------------------------
  22. #. Start GeoServer and login to the web admin interface as the ``admin`` user.
  23. #. Click the ``Authentication`` link located under the ``Security`` section of
  24. the navigation sidebar.
  25. .. figure:: images/digest1.jpg
  26. :align: center
  27. #. Scroll down to the ``Authentication Filters`` panel and click the ``Add new`` link.
  28. .. figure:: images/digest2.jpg
  29. :align: center
  30. #. Click the ``Digest`` link.
  31. .. figure:: images/digest3.jpg
  32. :align: center
  33. #. Fill in the fields of the settings form as follows:
  34. * Set ``Name`` to "digest"
  35. * Set ``User group service`` to "default"
  36. .. figure:: images/digest4.jpg
  37. :align: center
  38. #. Save.
  39. #. Back on the authentication page scroll down to the ``Filter Chains`` panel.
  40. #. Select "Default" from the ``Request type`` drop down.
  41. #. Unselect the ``basic`` filter and select the ``digest`` filter. Position the
  42. the ``digest`` filter before the ``anonymous`` filter.
  43. .. figure:: images/digest5.jpg
  44. :align: center
  45. #. Save.
  46. Secure OGC service requests
  47. ---------------------------
  48. In order to test the authentication settings configured in the previous section
  49. a service or resource must be first secured. The ``Default`` filter chain is the
  50. chain applied to all OGC service requests so a service security rule must be
  51. configured.
  52. #. From the GeoServer home page and click the ``Services`` link located under the
  53. ``Security`` section of the navigation sidebar.
  54. .. figure:: images/digest6.jpg
  55. :align: center
  56. #. On the Service security page click the ``Add new rule`` link and add a catch all
  57. rule that secures all OGC service requests requiring the ``ROLE_ADMINISTRATOR``
  58. role.
  59. .. figure:: images/digest7.jpg
  60. :align: center
  61. #. Save.
  62. Test a digest authentication login
  63. ----------------------------------
  64. #. Ensure that basic authentication is disabled execute the following curl command::
  65. curl -v -u admin:geoserver -G "http://localhost:8080/geoserve/wfs?request=getcapabilities"
  66. The result should be a 401 response signaling that authentication is required. The output
  67. should look something like the following::
  68. * About to connect() to localhost port 8080 (#0)
  69. * Trying 127.0.0.1... connected
  70. * Connected to localhost (127.0.0.1) port 8080 (#0)
  71. * Server auth using Basic with user 'admin'
  72. > GET /geoserver/wfs?request=getcapabilities HTTP/1.1
  73. > Authorization: Basic YWRtaW46Z2Vvc2VydmVy
  74. > User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
  75. > Host: localhost:8080
  76. > Accept: */*
  77. >
  78. < HTTP/1.1 401 Full authentication is required to access this resource
  79. < Set-Cookie: JSESSIONID=1dn2bi8qqu5qc;Path=/geoserver
  80. < WWW-Authenticate: Digest realm="GeoServer Realm", qop="auth", nonce="MTMzMzQzMDkxMTU3MjphZGIwMWE4MTc1NmRiMzI3YmFiODhmY2NmZGQ2MzEwZg=="
  81. < Content-Type: text/html; charset=iso-8859-1
  82. < Content-Length: 1491
  83. < Server: Jetty(6.1.8)
  84. <
  85. <html>
  86. <head>
  87. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
  88. <title>Error 401 Full authentication is required to access this resource</title>
  89. </head>
  90. ...
  91. #. Execute the same command but specify the ``--digest`` option to tell curl to use
  92. digest authentication rather than basic authentication::
  93. curl --digest -v -u admin:geoserver -G "http://localhost:8080/geoserver/wfs?request=getcapabilities"
  94. The result should be a successful authentication and contain the normal WFS capabilities response.