| 1 |
======================================================================== |
| 2 |
MOD_AUTH_CAS 1.3 README |
| 3 |
======================================================================== |
| 4 |
Apache CAS Authentication Module for the JASIG/Apereo CAS Server. |
| 5 |
|
| 6 |
======================================================================== |
| 7 |
LICENSE |
| 8 |
======================================================================== |
| 9 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 |
you may not use this file except in compliance with the License. |
| 11 |
You may obtain a copy of the License at |
| 12 |
|
| 13 |
https://www.apache.org/licenses/LICENSE-2.0 |
| 14 |
|
| 15 |
Unless required by applicable law or agreed to in writing, software |
| 16 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 17 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 |
See the License for the specific language governing permissions and |
| 19 |
limitations under the License. |
| 20 |
|
| 21 |
======================================================================== |
| 22 |
INTRODUCTION |
| 23 |
======================================================================== |
| 24 |
The purpose of this module is to allow an Apache web server to interact |
| 25 |
with an authentication server that conforms to the CAS version 1 or 2 |
| 26 |
protocol or SAML protocol as used by the JASIG/Apereo CAS Server. |
| 27 |
At the time of this writing, the CAS protocol specification is here: |
| 28 |
|
| 29 |
https://apereo.github.io/cas/development/protocol/CAS-Protocol-Specification.html |
| 30 |
|
| 31 |
======================================================================== |
| 32 |
Getting Started |
| 33 |
======================================================================== |
| 34 |
|
| 35 |
-------------------------------------------------------------------- |
| 36 |
Linux Distribution Packaging |
| 37 |
-------------------------------------------------------------------- |
| 38 |
mod_auth_cas is available in most major Linux distributions, including |
| 39 |
Debian, Ubuntu, Fedora, and is available from EPEL for CentOS and RHEL. |
| 40 |
|
| 41 |
|
| 42 |
-------------------------------------------------------------------- |
| 43 |
Building from Source |
| 44 |
-------------------------------------------------------------------- |
| 45 |
|
| 46 |
The following development libraries and utilities must be installed: |
| 47 |
* OpenSSL - 0.9.8c or higher |
| 48 |
* Apache Portable Runtime - 1.5.0 or higher |
| 49 |
* Apache Portable Runtime Utilities - 1.3.0 or higher |
| 50 |
* Apache Web Server - 2.4 or higher |
| 51 |
* libcurl - 7.18.2 or higher |
| 52 |
* libpcre2 - 10 or higher |
| 53 |
|
| 54 |
Download the distribution via git or tarball. Because git does not |
| 55 |
preserve timestamps, autoconf may determine it is necessary to bootstrap |
| 56 |
the project. If building from source, please start with: |
| 57 |
|
| 58 |
autoreconf -ivf |
| 59 |
|
| 60 |
Build is performed with the standard Autoconf incantation: |
| 61 |
|
| 62 |
./configure && make && sudo make install |
| 63 |
|
| 64 |
Edit your Apache configuration to load the mod_auth_cas module: |
| 65 |
|
| 66 |
LoadModule auth_cas_module /path/to/mod_auth_cas.so |
| 67 |
|
| 68 |
Set a few required parameters in your Apache configuration: |
| 69 |
|
| 70 |
CASCookiePath /var/cache/apache2/mod_auth_cas/ |
| 71 |
CASLoginURL https://login.example.org/cas/login |
| 72 |
CASValidateURL https://login.example.org/cas/serviceValidate |
| 73 |
|
| 74 |
Protect a "Location" or "Directory" block in your Apache |
| 75 |
configuration: |
| 76 |
|
| 77 |
<Location /secured> |
| 78 |
AuthType CAS |
| 79 |
Require valid-user |
| 80 |
</Location> |
| 81 |
|
| 82 |
If attribute-based authorization is also desired, specify cas-attribute |
| 83 |
name:value in your Require rule (please note: both attribute name and value are |
| 84 |
case-sensitive): |
| 85 |
|
| 86 |
CASCookiePath /var/cache/apache2/mod_auth_cas/ |
| 87 |
CASLoginURL https://login.example.org/cas/login |
| 88 |
CASValidateURL https://login.example.org/cas/samlValidate |
| 89 |
CASValidateSAML On |
| 90 |
|
| 91 |
<Location /secured> |
| 92 |
AuthType CAS |
| 93 |
Require cas-attribute edupersonaffiliation:staff |
| 94 |
</Location> |
| 95 |
|
| 96 |
Both the CAS 2.0 and SAML 1.1 protocols support including additional attributes |
| 97 |
in the CAS validation response, which may also be added as HTTP headers (see |
| 98 |
CASAttributePrefix and CASAttributeDelimiter). This example uses the SAML |
| 99 |
protocol and requires that the 'edupersonaffiliation' attribute is set to |
| 100 |
'staff'. |
| 101 |
|
| 102 |
|
| 103 |
======================================================================== |
| 104 |
NEW FEATURES AND FUNCTIONS IN THIS RELEASE |
| 105 |
======================================================================== |
| 106 |
* CASCookieSameSite, specify the SameSite parameter. |
| 107 |
* CASCookieSecure, specify the optional 'Secure' attribute for cookies. |
| 108 |
* Use apr_pescape_urlencoded() to URL-encode. |
| 109 |
* Fix escaping for small chars in urlEncode(). |
| 110 |
* Add a random RequestID to the SAML payload. |
| 111 |
* Bump required APR versions. |
| 112 |
* Require Apache 2.4. |
| 113 |
https://github.com/apereo/mod_auth_cas/milestone/7?closed=1 |
| 114 |
|
| 115 |
======================================================================== |
| 116 |
KNOWN ISSUES |
| 117 |
======================================================================== |
| 118 |
* Autoconf does not work well on code freshly checked out of git. Autoconf |
| 119 |
artifacts must be rebuilt using `autoreconf -ivf` . |
| 120 |
|
| 121 |
======================================================================== |
| 122 |
KNOWN LIMITATIONS |
| 123 |
======================================================================== |
| 124 |
These limitations are known to exists in this release of the software: |
| 125 |
|
| 126 |
* CAS Proxy Validation is not implemented in this version. |
| 127 |
|
| 128 |
* CAS Ticket Validation can only be performed over an SSL connection. |
| 129 |
The CAS protocol does not explicitly require this, but to not do so |
| 130 |
leaves this system open to a man-in-the-middle attack. |
| 131 |
|
| 132 |
* CAS single sign out is currently not functional and disabled. It |
| 133 |
is only safe to use in the case where all requests are GET and not |
| 134 |
POST (the module inadvertently 'eats' some content of the POST |
| 135 |
request while determining if it should process it as a SAML logout |
| 136 |
request). |
| 137 |
|
| 138 |
* Reports of slow performance on some systems (particularly |
| 139 |
virtual machines) have been reported. This is related to the |
| 140 |
entropy that is gathered when creating a session cookie for |
| 141 |
the end user. To combat this, there are 3 solutions. The |
| 142 |
first is to upgrade the version of the Apache Portable Runtime |
| 143 |
on your system to >= 1.3.0. In that version, entropy is gathered |
| 144 |
from a nonblocking source. The second method would be to install |
| 145 |
a package such as rng-tools and feed random data from /dev/urandom |
| 146 |
to /dev/random("-r /dev/urandom"). The last way is to reduce |
| 147 |
the size of the CASCookieEntropy setting, reducing the demand on |
| 148 |
the pool. |
| 149 |
|
| 150 |
* Win32 support has been dropped (but not removed) due to lack of |
| 151 |
development resources, and seemingly minimal community usage. |
| 152 |
You are welcome to try it, but YMMV for success. |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
======================================================================== |
| 157 |
Configuration |
| 158 |
======================================================================== |
| 159 |
First, you must tell Apache to load the module. In your httpd.conf, |
| 160 |
add: |
| 161 |
|
| 162 |
LoadModule auth_cas_module /path/to/mod_auth_cas.so |
| 163 |
|
| 164 |
Then, in the location(s) you want to protect, use the following |
| 165 |
directive: |
| 166 |
|
| 167 |
AuthType CAS |
| 168 |
|
| 169 |
Be sure to set authorization parameters in the locations you |
| 170 |
are protecting(e.g. 'require valid-user', 'require group foo') |
| 171 |
|
| 172 |
The following are valid configuration options and their default: |
| 173 |
|
| 174 |
Valid Server/VirtualHost Directives |
| 175 |
----------------------------------- |
| 176 |
Directive: CASVersion |
| 177 |
Default: 2 |
| 178 |
Description: The version of the CAS protocol to adhere to (1 or 2). |
| 179 |
This affects whether Gateway mode is available and how |
| 180 |
the CAS validation response is parsed. |
| 181 |
|
| 182 |
Directive: CASDebug |
| 183 |
Default: Off |
| 184 |
Description: Enable or disable debugging mode for troubleshooting. Please |
| 185 |
note that LogLevel must be set to Debug for the VirtualHost in |
| 186 |
order for these logs to be visible. |
| 187 |
|
| 188 |
Directive: CASValidateDepth |
| 189 |
Default: 9 |
| 190 |
Description: This directive will set the maximum depth for chained certificate |
| 191 |
validation. The default (according to OpenSSL documentation) is 9. |
| 192 |
|
| 193 |
Directive: CASCertificatePath |
| 194 |
Default: /etc/ssl/certs/ |
| 195 |
Description: The path to the X509 certificate of the Certificate Authority for |
| 196 |
the server in CASLoginURL and CASValidateURL. This may be either |
| 197 |
a file, or a directory containing the certificate files linked to |
| 198 |
by their hashed names. |
| 199 |
|
| 200 |
Directive: CASLoginURL |
| 201 |
Default: NULL |
| 202 |
Description: The URL to redirect users to when they attempt to access a CAS |
| 203 |
protected resource and do not have an existing session. The |
| 204 |
'service', 'renew', and 'gateway' parameters will be appended to |
| 205 |
this by mod_auth_cas if necessary. Include 'http[s]://...' |
| 206 |
|
| 207 |
Directive: CASValidateURL |
| 208 |
Default: NULL |
| 209 |
Description: The URL to use when validating a ticket presented by a client in |
| 210 |
the HTTP query string (ticket=...). Must include 'https://' and |
| 211 |
must be an HTTPS URL. |
| 212 |
|
| 213 |
Directive: CASProxyValidateURL |
| 214 |
Default: NULL |
| 215 |
Description: The URL to use when performing a proxy validation. This is currently |
| 216 |
an unimplemented feature, so setting this will have no effect. |
| 217 |
|
| 218 |
Directive: CASRootProxiedAs |
| 219 |
Default: NULL |
| 220 |
Description: This URL represents the URL that end users may see in the event that |
| 221 |
access to this Apache server is proxied. This will override the |
| 222 |
automatic generation of service URLs and construct them using this |
| 223 |
prefix. As an example: If the site being protected is http://example.com/ |
| 224 |
and the Apache instance of this server is http://internal.example.com:8080, |
| 225 |
setting CASRootProxiedAs to http://example.com would result in proper |
| 226 |
service parameter generation. |
| 227 |
|
| 228 |
Directive: CASCookiePath |
| 229 |
Default: /dev/null |
| 230 |
Description: When users first authenticate to mod_auth_cas with a valid service ticket, |
| 231 |
a local session is established. Information about this session (the |
| 232 |
username, time of creation, last activity time, the resource initially |
| 233 |
requested, and whether or not the credentials were renewed) is stored |
| 234 |
in this directory. This location should be writable by the web server ONLY. |
| 235 |
Any user that can write to this location can falsify authentication information |
| 236 |
by creating a fake data file. |
| 237 |
NOTE : Some distributions purge the contents of /tmp/ on a reboot, including |
| 238 |
user created directories. This will prevent mod_auth_cas from storing |
| 239 |
cookie information until that directory is created. To avoid this, try |
| 240 |
using a different location, such as /var/cache/apache2/mod_auth_cas/ |
| 241 |
|
| 242 |
Directive: CASCookieEntropy |
| 243 |
Default: 32 |
| 244 |
Description: When creating a local session, this many random bytes are used to |
| 245 |
create a unique session identifier. Using large values for this |
| 246 |
field may result in delays when generating session IDs if not |
| 247 |
enough entropy is available. |
| 248 |
|
| 249 |
Directive: CASTimeout |
| 250 |
Default: 7200 (2 hours) |
| 251 |
Description: This is the hard limit, in seconds, for a mod_auth_cas session (whether |
| 252 |
it is idle or not). When a session has reached this age and a new |
| 253 |
request is made, the user is redirected to the CASLoginURL to |
| 254 |
obtain a new service ticket. When this new ticket is validated, |
| 255 |
they will be assigned a new mod_auth_cas session. Set this value to '0' |
| 256 |
in order to allow a non-idle session to not expire. |
| 257 |
|
| 258 |
Directive: CASIdleTimeout |
| 259 |
Default: 3600 (1 hour) |
| 260 |
Description: This is a limit, in seconds, of how long a mod_auth_cas session can be idle. |
| 261 |
When a request comes in, if it has been inactive for CASIdleTimeout |
| 262 |
seconds, the user is redirected to the CASLoginURL to obtain a new |
| 263 |
service ticket. |
| 264 |
|
| 265 |
Directive: CASCacheCleanInterval |
| 266 |
Default: 1800 (30 minutes) |
| 267 |
Description: This is the minimum amount of time that must pass inbetween cache |
| 268 |
cleanings. When a new ticket is issued, or when an expired session |
| 269 |
is presented, the time of the last cache clean is compared against |
| 270 |
this value. If CASCacheCleanInterval seconds have passed since the |
| 271 |
last cleaning, then all files in CASCookiePath are examined and if |
| 272 |
they have expired, they are removed. This is merely to prevent the |
| 273 |
file system from becoming excessively cluttered. |
| 274 |
|
| 275 |
Directive: CASCookieDomain |
| 276 |
Default: NULL |
| 277 |
Description: Specify the value for the 'Domain=' parameter in the Set-Cookie header. |
| 278 |
|
| 279 |
Directive: CASCookieSameSite |
| 280 |
Default: NULL |
| 281 |
Description: Specify the value for the 'SameSite=' parameter in the Set-Cookie header. |
| 282 |
Allowed values are 'None', 'Lax', and 'Strict'. |
| 283 |
|
| 284 |
Directive: CASCookieHttpOnly |
| 285 |
Default: On |
| 286 |
Description: Set the optional 'HttpOnly' flag for cookies issues by mod_auth_cas. |
| 287 |
Set the HttpOnly flag as described in in RFC 6265. This flag prevents the |
| 288 |
mod_auth_cas cookies from being accessed by client side Javascript. |
| 289 |
|
| 290 |
Directive: CASCookieSecure |
| 291 |
Default: Auto |
| 292 |
Description: Set the optional 'Secure' attribute for cookies issued by mod_auth_cas. |
| 293 |
Set the Secure attribute as described in in RFC 6265. This flag prevents the |
| 294 |
mod_auth_cas cookies from being sent over an unencrypted HTTP connection. |
| 295 |
By default, mod_auth_cas sets the 'Secure' attribute depending on information about |
| 296 |
the connection (the 'Auto' option). The options 'On' and 'Off' can be used to override |
| 297 |
the automatic behaviour. |
| 298 |
|
| 299 |
Directive: CASAuthoritative |
| 300 |
Default: Off |
| 301 |
Description: This directive determines whether an optional authorization directive |
| 302 |
(see 'Require cas-attribute') is authoritative and thus binding or |
| 303 |
if other authorization modules will also be applied. |
| 304 |
'On' means authoritative, 'Off' means not authoritative. |
| 305 |
NOTE: This directive is unavailable with Apache 2.4. See the RequireAny, |
| 306 |
RequireNone, and RequireAll directives instead. |
| 307 |
|
| 308 |
Directive: CASValidateSAML |
| 309 |
Default: Off |
| 310 |
Description: If enabled, the response from the CAS Server will be parsed for SAML |
| 311 |
attributes which will be associated with the user. Requires setting |
| 312 |
CASValidateURL appropriately; typical URLs are of the form |
| 313 |
https://login.example.org/cas/samlValidate. |
| 314 |
|
| 315 |
Directive: CASAttributePrefix |
| 316 |
Default: CAS_ (Apache < 2.4) |
| 317 |
CAS- (Apache 2.4) |
| 318 |
Description: The prefix to use when adding CAS or SAML attributes to the HTTP headers, |
| 319 |
which will be named <CASAttributePrefix><attr_name>. CASAuthNHeader |
| 320 |
must be set for this directive to be used. |
| 321 |
NOTE: In Apache 2.4 and newer, headers containing "invalid" characters |
| 322 |
(including underscores) are silently dropped, so you must set this to |
| 323 |
a "valid" name containing only alphabetic characters and hyphens. |
| 324 |
|
| 325 |
Directive: CASAttributeDelimiter |
| 326 |
Default: , |
| 327 |
Description: mod_auth_cas will set the value of the attribute header (as described |
| 328 |
in CASAttributePrefix) to <attrvalue><CASAttributeDelimiter><attrvalue> |
| 329 |
in the case of multiple attribute values. |
| 330 |
|
| 331 |
Directive: CASPreserveTicket |
| 332 |
Default: Off |
| 333 |
Description: This directive leaves CAS ticket parameters intact when a valid |
| 334 |
session cookie exists. This helps prevent infinite redirect loops when |
| 335 |
CAS protection is being used at multiple levels. |
| 336 |
|
| 337 |
Directive: CASGatewayCookieDomain |
| 338 |
Default: NULL |
| 339 |
Description: Specify the value for the 'Domain=' parameter in the Set-Cookie header |
| 340 |
when setting the CASGatewayCookie. |
| 341 |
|
| 342 |
Valid Directory/.htaccess Directives |
| 343 |
------------------------------------ |
| 344 |
Directive: CASScope |
| 345 |
Default: Off |
| 346 |
Description: Use this directive with an argument as a relative path (e.g. /application/) to specify |
| 347 |
the scope for which a mod_auth_cas cookie is valid. This is beneficial to prevent |
| 348 |
additional round trips to the CAS server. Assume someone authenticates to /application/subdir/ |
| 349 |
and then browses to /application/ - without CASScope set, each request would result in |
| 350 |
a round trip to the CAS server and a new cookie being created (one for each directory). |
| 351 |
CASScope would set one cookie, which will be presented on access to both directories. |
| 352 |
Note that if someone accessed /application/ and then /application/subdir/ this would not |
| 353 |
be an issue, but that order of access can not be guaranteed. To disable this feature, |
| 354 |
the special argument 'Off' will return to per-directory cookie paths for this directory |
| 355 |
and subdirectories. |
| 356 |
|
| 357 |
Directive: CASRenew |
| 358 |
Default: Off |
| 359 |
Description: Use this directive with an argument as a relative path (e.g. /application/secure/ |
| 360 |
for http://www.example.com/application/secure/*) to force a user to renew their |
| 361 |
credentials when accessing that directory. The argument MUST be a relative path. |
| 362 |
To disable this requirement, the special argument 'Off' will disable this requirement |
| 363 |
for this directory and subdirectories. |
| 364 |
|
| 365 |
Directive: CASGateway |
| 366 |
Default: Off |
| 367 |
Description: Use this directive with an argument as a relative path (e.g. /application/insecure/ |
| 368 |
for http://www.example.com/application/insecure/*) to allow anonymous access to that directory. |
| 369 |
The argument MUST be a relative path. To disable this feature, the special argument 'Off' |
| 370 |
will reinstate the requirement for authentication. |
| 371 |
|
| 372 |
Directive: CASCookie |
| 373 |
Default: MOD_AUTH_CAS |
| 374 |
Description: The name of the cookie used to store the session ID over HTTP connections. |
| 375 |
It should be changed if it will interfere with the application protected |
| 376 |
by mod_auth_cas. |
| 377 |
|
| 378 |
Directive: CASSecureCookie |
| 379 |
Default: MOD_AUTH_CAS_S |
| 380 |
Description: The name of the cookie used to store the session ID over HTTPS connections. |
| 381 |
It should be changed if it will interfere with the application protected |
| 382 |
by mod_auth_cas. |
| 383 |
|
| 384 |
Directive: CASGatewayCookie |
| 385 |
Default: MOD_AUTH_CAS_G |
| 386 |
Description: The name of the cookie used to store whether or not the user has attempted |
| 387 |
to access this resource before. It should be changed if it will interfere |
| 388 |
with the application protected by mod_auth_cas. |
| 389 |
|
| 390 |
Directive: CASAuthNHeader |
| 391 |
Default: None |
| 392 |
Description: If enabled, this will store the user returned by CAS in the specified |
| 393 |
HTTP header accessible to your web applications, and any additional |
| 394 |
attributes received in headers named according to CASAttributePrefix. |
| 395 |
This is in addition to the REMOTE_USER environment variable, which is |
| 396 |
always set to the CAS user. |
| 397 |
|
| 398 |
Directive: CASSSOEnabled |
| 399 |
Default: Off |
| 400 |
Description: If enabled, this activates support for Single Sign Out within the CAS |
| 401 |
protocol. Please note that this feature is currently experimental and |
| 402 |
may mangle POST data. |
| 403 |
|
| 404 |
Directive: CASScrubRequestHeaders |
| 405 |
Default: Off |
| 406 |
Description: mod_auth_cas will strip request inbound request headers that may have |
| 407 |
special meaning, such as those set with the CASAttributePrefix or the |
| 408 |
CASAuthNHeader value. |
| 409 |
|
| 410 |
Directive: Require cas-attribute <attribute>:<value> |
| 411 |
Default: NULL |
| 412 |
Description: Use this directive to authorize based on CAS or SAML attributes |
| 413 |
returned via the session validation call. Multiple directives |
| 414 |
are OR-ed. If directive is present with no attributes defined, |
| 415 |
the request is declined. If value has spaces, wrap the pair in quotes. |
| 416 |
See also CASAuthoritative. |
| 417 |
|
| 418 |
Directive: Require cas-attribute <attribute>~<value> |
| 419 |
Default: NULL |
| 420 |
Description: Use this form of the directive to authorize based on CAS or SAML |
| 421 |
attributes returned via the session validation call. Multiple |
| 422 |
directives are OR-ed. If directive is present with no attributes |
| 423 |
defined, the request is declined. The value is interpreted as a |
| 424 |
Perl-Compatible Regular Expression (PCRE) using case-sensitive |
| 425 |
matching. See also CASAuthoritative. |
| 426 |
|
| 427 |
======================================================================== |
| 428 |
CONTACT INFORMATION AND WEBSITE |
| 429 |
======================================================================== |
| 430 |
We welcome your feedback, suggestions and contributions. Contact us |
| 431 |
via email if you have questions, feedback, code submissions, |
| 432 |
and bug reports. To reach the development team, send an e-mail to: |
| 433 |
|
| 434 |
cas-user [at] apereo [dot] org |
| 435 |
|
| 436 |
Google Group link: |
| 437 |
|
| 438 |
https://groups.google.com/a/apereo.org/forum/#!forum/cas-user |
| 439 |
|
| 440 |
======================================================================== |