index.rst 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. .. _cas:
  2. CAS integration
  3. ===============
  4. The CAS module allows to integrate GeoServer with the `Central Authentication Service (CAS) <https://www.apereo.org/projects/cas>`_
  5. Single Sign On (SSO), in particular, using standard tickets and proxy tickets.
  6. Installation
  7. ------------
  8. To install the CAS module:
  9. #. Visit the :website:`website download <download>` page, locate your release, and download: :download_extension:`cas`
  10. The download link will be in the :guilabel:`Extensions` section under :guilabel:`Security`.
  11. .. warning:: Ensure to match plugin (example |release| above) version to the version of the GeoServer instance.
  12. #. Extract the files in this archive to the :file:`WEB-INF/lib` directory of your GeoServer installation.
  13. #. Restart GeoServer
  14. Configuration
  15. -------------
  16. The CAS integration is a authentication filter module, hence in order to use it one has to:
  17. * Go to the authentication page, add the CAS filter and configure it
  18. * Add it to the authentication chains, taking care of removing the other authentication methods
  19. (or the CAS authentication won't trigger and redirect users to the CAS login page)
  20. This page serves as a reference for configuration options, but a step by step tutorial is also
  21. available, see :ref:`security_tutorials_cas`.
  22. .. figure:: images/configuration.png
  23. :align: center
  24. .. list-table::
  25. :widths: 20 80
  26. :header-rows: 1
  27. * - Key
  28. - Description
  29. * - Name
  30. - Name of the filter
  31. * - CAS server URL including context root
  32. - The CAS server location (GeoServer will redirect to it, for example, in order to login, adding the necessary extra path elements)
  33. * - No single sign on
  34. - If checkecd, will send the "renew=true" options to the CAS server, forcing the user to login on the server at each request (unless session creation is allowed)
  35. * - Participate in single sign out
  36. - Whether GeoServer should receive and handle callbacks for Single Sign Out.
  37. * - URL in CAS loutput page
  38. - CAS logout page location
  39. * - Proxy callback URL
  40. - The URL CAS will call back to after proxy ticket authentication
  41. * - Role source
  42. - A choice of role sources for the user authenticated via CAS
  43. Specifically for the **role source**, the following options are available:
  44. .. list-table::
  45. :widths: 20 80
  46. :header-rows: 1
  47. * - Source
  48. - Description
  49. * - User group service
  50. - Locate the user in a the specified user group service, extract the roles from it.
  51. * - Role service
  52. - Locate user roles from the specified role service
  53. * - Header attribute
  54. - Look up the roles in the specified HTTP header of the CAS response
  55. * - Custom CAS attribute
  56. - Extract the roles from a CAS custom attribute in the ``<cas:serviceResponse>`` received from the server.
  57. The attributes must be configured, on the CAS side, via an attribute repository, and then released for publication in service configuration.
  58. Example CAS configuration
  59. -------------------------
  60. In order to use the CAS custom attributes the server must be configured to extract the attributes
  61. from a given attribute repository, and then allow their release in the GeoServer service configuration.
  62. For example, the following ``cas.properties`` file sets up a JDBC user source, as well as JDBC
  63. attribute repository (this configuration file might useful for testing purposes, but not setup for production):
  64. .. code-block:: none
  65. cas.server.name=https://localhost:8443
  66. cas.server.prefix=${cas.server.name}/cas
  67. server.ssl.key-store=file:/etc/cas/config/thekeystore
  68. server.ssl.key-store-password=changeit
  69. logging.config=file:/etc/cas/config/log4j2.xml
  70. # cas.authn.accept.users=
  71. cas.authn.jdbc.query[0].driver-class=org.postgresql.Driver
  72. cas.authn.jdbc.query[0].url=jdbc:postgresql://localhost:5432/cas_users
  73. cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.PostgreSQL95Dialect
  74. cas.authn.jdbc.query[0].driver-class=org.postgresql.Driver
  75. cas.authn.jdbc.query[0].user=theDbUser
  76. cas.authn.jdbc.query[0].password=theDbPassword
  77. cas.authn.jdbc.query[0].sql=SELECT * FROM users WHERE email = ?
  78. cas.authn.jdbc.query[0].password-encoder.type=BCRYPT
  79. cas.authn.jdbc.query[0].field-password=password
  80. cas.authn.jdbc.query[0].field-expired=expired
  81. cas.authn.jdbc.query[0].field-disabled=disabled
  82. cas.authn.attributeRepository.jdbc[0].driver-class=org.postgresql.Driver
  83. cas.authn.attributeRepository.jdbc[0].url=jdbc:postgresql://localhost:5432/cas_users
  84. cas.authn.attributeRepository.jdbc[0].dialect=org.hibernate.dialect.PostgreSQL95Dialect
  85. cas.authn.attributeRepository.jdbc[0].driver-class=org.postgresql.Driver
  86. cas.authn.attributeRepository.jdbc[0].user=theDbUser
  87. cas.authn.attributeRepository.jdbc[0].password=theDbPassword
  88. cas.authn.attributeRepository.jdbc[0].attributes.role=role
  89. cas.authn.attributeRepository.jdbc[0].singleRow=false
  90. cas.authn.attributeRepository.jdbc[0].columnMappings.attribute=value
  91. cas.authn.attributeRepository.jdbc[0].sql=SELECT * FROM roles WHERE {0}
  92. cas.authn.attributeRepository.jdbc[0].username=email
  93. cas.service-registry.json.location=classpath:/services
  94. The database has the following two tables for users and roles:
  95. .. code-block:: sql
  96. CREATE TABLE public.users (
  97. id bigint NOT NULL,
  98. disabled boolean,
  99. email character varying(40),
  100. first_name character varying(40),
  101. last_name character varying(40),
  102. expired boolean,
  103. password character varying(100)
  104. );
  105. CREATE TABLE public.roles (
  106. email character varying,
  107. attribute character varying,
  108. value character varying
  109. );
  110. A sample service configuration for GeoServer might look as follows (again, setup for testing
  111. and development only):
  112. .. code-block:: json
  113. {
  114. "@class" : "org.apereo.cas.services.RegexRegisteredService",
  115. "serviceId" : "^http(s)?://localhost:[\\d]+/geoserver/.*",
  116. "name" : "GeoServer",
  117. "id" : 1002,
  118. "logoutType" : "BACK_CHANNEL",
  119. "logoutUrl" : "https://localhost:8442/geoserver",
  120. "redirectUrl" : "https://localhost:8442/geoserver",
  121. "proxyPolicy" : {
  122. "@class" : "org.apereo.cas.services.RegexMatchingRegisteredServiceProxyPolicy",
  123. "pattern" : "^http(s)?://localhost:[\\d]+/geoserver/.*"
  124. },
  125. "attributeReleasePolicy" : {
  126. "@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
  127. }
  128. }
  129. Configuring the web chain
  130. -------------------------
  131. The CAS authentication can be included in the web filter chain, with different behavior depending
  132. on which filters are included. The following discusses three possible examples.
  133. As first case, let's consider having only the CAS authentication in the "web" filter chain:
  134. .. figure:: images/webCasOnly.png
  135. :align: center
  136. Since anonymous access is not allowed, any attempt to access the GeoServer web console will cause
  137. a redirect to the CAS server, for login. Once logged in, the user interface shows a button to initiate
  138. a CAS logout (the logout is shared among all examples, won't be repeated in the following text).
  139. .. figure:: images/webCasLogout.png
  140. :align: center
  141. A second option is to allow anonymous access in the web chain, allowing users to access the layer
  142. preview and other demo functionality without logging in:
  143. .. figure:: images/webCasAnonymous.png
  144. :align: center
  145. In this case the web console does not immediately redirect to the CAS server, but
  146. provides a CAS login button instead:
  147. .. figure:: images/webCasLogin.png
  148. :align: center
  149. As a final example, let's consider having both CAS and form login in the web chain:
  150. .. figure:: images/webCasFormAnonymous.png
  151. :align: center
  152. This allows both a CAS login, and a form based login using GeoServer local username/password.
  153. It could be useful to allow GeoServer administration while the CAS server is offline for any reason.
  154. In this case both the form login and the CAS login button appear at the same time:
  155. .. figure:: images/webCasFormLogin.png
  156. :align: center