index.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. .. _security_tutorials_httpheaderproxy:
  2. Configuring HTTP Header Proxy Authentication
  3. ============================================
  4. Introduction
  5. ------------
  6. Proxy authentication is used in multi-tier system. The user/principal authenticates
  7. at the proxy and the proxy provides the authentication information to other services.
  8. This tutorial shows how to configure GeoServer to accept authentication information
  9. passed by HTTP header attribute(s). In this scenario GeoServer will do no actual authentication itself.
  10. Prerequisites
  11. -------------
  12. This tutorial uses the `curl <http://curl.haxx.se/>`_ utility to issue HTTP
  13. request that test authentication. Install curl before proceeding.
  14. .. note::
  15. Any utility that supports setting HTTP header attributes can be used in
  16. place of curl.
  17. Configure the HTTP header filter
  18. --------------------------------
  19. #. Start GeoServer and login to the web admin interface as the ``admin`` user.
  20. #. Click the ``Authentication`` link located under the ``Security`` section of
  21. the navigation sidebar.
  22. .. figure:: images/digest1.jpg
  23. :align: center
  24. #. Scroll down to the ``Authentication Filters`` panel and click the ``Add new`` link.
  25. .. figure:: images/digest2.jpg
  26. :align: center
  27. #. Click the ``HTTP Header`` link.
  28. .. figure:: images/digest3.jpg
  29. :align: center
  30. #. Fill in the fields of the settings form as follows:
  31. * Set ``Name`` to "proxy"
  32. * Set ``Request header attribute to`` to "sdf09rt2s"
  33. * Set ``Role source`` to "User group service"
  34. * Set the name of the user group service to "default"
  35. Additional information about role services is here :ref:`security_rolesystem_rolesource`
  36. .. figure:: images/digest4.jpg
  37. :align: center
  38. .. warning::
  39. The tutorial uses the obscure "sdf09rt2s" name for the header attribute.
  40. Why not use "user" or "username" ?. In a proxy scenario a relationship
  41. of trust is needed between the proxy and GeoServer. An attacker could easily
  42. send an HTTP request with an HTTP header attribute "user" and value "admin"
  43. and operate as an administrator.
  44. One possibility is to configure the network infrastructure preventing such
  45. requests from all IP addresses except the IP of the proxy.
  46. This tutorial uses a obscure header attribute name which should be a shared
  47. secret between the proxy and GeoServer. Additionally, the use of SSL is recommended,
  48. otherwise the shared secret is transported in plain text.
  49. #. Save.
  50. #. Back on the authentication page scroll down to the ``Filter Chains`` panel.
  51. #. Select "Default" from the ``Request type`` drop down.
  52. #. Unselect the ``basic`` filter and select the ``proxy`` filter. Position the
  53. the ``proxy`` filter before the ``anonymous`` filter.
  54. .. figure:: images/digest5.jpg
  55. :align: center
  56. #. Save.
  57. Secure OGC service requests
  58. ---------------------------
  59. In order to test the authentication settings configured in the previous section
  60. a service or resource must be first secured. The ``Default`` filter chain is the
  61. chain applied to all OGC service requests so a service security rule must be
  62. configured.
  63. #. From the GeoServer home page and click the ``Services`` link located under the
  64. ``Security`` section of the navigation sidebar.
  65. .. figure:: images/digest6.jpg
  66. :align: center
  67. #. On the Service security page click the ``Add new rule`` link and add a catch all
  68. rule that secures all OGC service requests requiring the ``ADMIN``
  69. role.
  70. .. figure:: images/digest7.jpg
  71. :align: center
  72. #. Save.
  73. Test a proxy login
  74. ------------------
  75. #. Execute the following curl command::
  76. curl -v -G "http://localhost:8080/geoserver/wfs?request=getcapabilities"
  77. The result should be a 403 response signaling that access is denied. The output
  78. should look something like the following::
  79. * About to connect() to localhost port 8080 (#0)
  80. * Trying ::1... connected
  81. > GET /geoserver/wfs?request=getcapabilities HTTP/1.1
  82. > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
  83. > Host: localhost:8080
  84. > Accept: */*
  85. >
  86. < HTTP/1.1 403 Access Denied
  87. < Content-Type: text/html; charset=iso-8859-1
  88. < Content-Length: 1407
  89. < Server: Jetty(6.1.8)
  90. <
  91. <html>
  92. <head>
  93. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
  94. <title>Error 403 Access Denied</title>
  95. </head>
  96. ...
  97. #. Execute the same command but specify the ``--header`` option.::
  98. curl -v --header "sdf09rt2s: admin" -G "http://localhost:8080/geoserver/wfs?request=getcapabilities"
  99. The result should be a successful authentication and contain the normal WFS capabilities response.