mod_auth_tkt(3) | User Contributed Perl Documentation | mod_auth_tkt(3) |
mod_auth_tkt - apache ticket authentication module
mod_auth_tkt is a lightweight cookie-based authentication module, written in C, for apache versions 1.3.x, 2.0.x, and 2.2.x It implements a single-signon framework that works across multiple apache instances, different apache versions, and multiple machines.
mod_auth_tkt itself is completely repository-agnostic, as the actual authentication is done by a user-supplied CGI or script in your language of choice (examples are provided in Perl, with contrib libraries for use with python and PHP). This allows authentication against virtually any kind of user repository you can imagine (password files, ldap directories, databases, etc.)
mod_auth_tkt supports inactivity timeouts (including the ability to control how aggressively the ticket is refreshed), the ability to include arbitrary user data within the cookie, configurable cookie names and domains, token-based access to subsections of a site, and optional 'guest' access for unauthenticated users.
mod_auth_tkt is configured in your apache configuration files using the following set of directives (all mod_auth_tkt directives begin with 'TKTAuth'):
mod_auth_tkt supports two apache server-level directives, one required - TKTAuthDigest, the shared secret used for digest hashing - and one optional - TKTAuthDigestType, the type of digest to use in ticket hashes. Both may be global or specific to a virtual host.
TKTAuthSecret "w b@5b15#664038f.f9d8U19b7e25 664eY9ad2%4393e,a2ef"
The default is likely to change in a future version, so setting the digest type explicitly is encouraged.
Note that using one of the SHA digest types with the perl CGI scripts requires a version of Apache::AuthTkt >= 2.1.
All directory-level directives are optional, except that either TKTAuthLoginURL or TKTAuthGuestLogin (or both) must be set to cause mod_auth_tkt to be invoked for a particular directory. As usual, directory-level directives may be set in Directory or Location sections, or in .htaccess files.
AuthType None require valid-user # or require user1, user2, etc.
TKTAuthLoginURL https://www.example.com/auth/login.cgi
TKTAuthTimeoutURL https://www.example.com/auth/login.cgi?timeout=1
TKTAuthPostTimeoutURL https://www.example.com/auth/login.cgi?posttimeout=1
TKTAuthUnauthURL https://www.example.com/auth/login.cgi?unauth=1
TKTAuthGuestLogin on
TKTAuthGuestCookie on
Default is 'off', unless you use a TKTAuthGuestUser with a UUID (see next), in which case it's 'on'. Setting explicitly is recommended, however.
On apache 2.0.x and 2.2.x (but not on apache 1.3.x), the TKTAuthGuestUser may also contain a special sprintf-like pattern '%U', which is expanded to 36-character UUID, allowing individualised guest usernames. The %U may also include an integer <= 36 to limit the number of characters used in the UUID e.g. %12U, %20U etc.
Default: 'guest'. Examples:
TKTAuthGuestUser visitor TKTAuthGuestUser guest-%12U
Default: off.
Default: off.
The following units can also be specified on the timeout (with no spaces between timeout and unit): y/years, M/months, w/weeks, d/days, h/hours, m/minutes, and s/seconds.
This timeout is protected by the ticket hashing, so cannot be trivially modified, unlike the TKTAuthCookieExpires setting below.
Setting TKTAuthTimeout to 0 means never timeout, but this is strongly discouraged, as it allows for trivial replay attacks. Set it to a week or two if you really don't want timeouts.
Default: 2h. Examples:
TKTAuthTimeout 86400 TKTAuthTimeout 1w TKTAuthTimeout 1w 4d 3h
This is a politeness setting for those paranoid types who have their browsers set to confirm all cookies - refreshing every time quickly becomes VERY tedious. Default: 0.5. e.g.
TKTAuthTimeoutRefresh 0.66
The period until the cookie expires, used to set the 'expires' field on the ticket cookie, in seconds. This is useful if you want cookies to persist across browser sessions (and your login script must support it too, of course).
The following units can also be specified on the expiry period (with no spaces between period and unit): y/years, M/months, w/weeks, d/days, h/hours, m/minutes, and s/seconds.
Note that his is a client-side setting and is not protected by the ticket hashing, so you should always set a TKTAuthTimeout in addition to using an expiry. Cookie expiries are refreshed with tickets if TKTAuthTimeoutRefresh is set.
Default: none (not used).
e.g.
TKTAuthCookieExpires 86400 TKTAuthCookieExpires 1w TKTAuthCookieExpires 1w 3d 4h
back=http%3A%2F%2Fwww.example.com%2Findex.html
to the TKTAuthLoginURL it redirects to, allowing your login script to redirect back to the requested page upon successful login.
To omit altogether, set to the string None i.e.
TKTAuthBackArgName None
Default: 'back'.
Default: none (not used).
Note that this directive can be repeated, and the semantics are that any of the required tokens is sufficient for access i.e. the tokens are ORed.
Default: none (not used).
e.g.
TKTAuthToken finance TKTAuthToken admin
Default: 'off' i.e. ticket is only valid from the originating IP address.
e.g.
TKTAuthIgnoreIP on
TKTAuthRequireSSL on
See also TKTAuthCookieSecure below.
TKTAuthCookieSecure on
TKTAuthRequireSSL and TKTAuthCookieSecure are normally used together. One case where it makes sense to use them separately is where you are proxying through a separate SSL-equipped reverse proxy, where you would want to use TKTAuthCookieSecure by itself (since the proxied request will never be via SSL).
Note that you will also require apache 'LogLevel debug' set to see these messages.
Minimal config using logins:
<Location /secret1> AuthType None require valid-user TKTAuthLoginURL https://www.example.com/auth/login.cgi </Location>
Minimal config using guest logins (users can still login explicitly, of course):
<Location /secret2> AuthType None require valid-user TKTAuthGuestLogin on </Location>
Example internet configuration:
<Location /secret3> AuthType None require valid-user TKTAuthLoginURL https://www.example.com/auth/login.cgi TKTAuthTimeoutURL https://www.example.com/auth/login.cgi?timeout=1 TKTAuthPostTimeoutURL https://www.example.com/auth/login.cgi?timeout=1&post=1 TKTAuthIgnoreIP on TKTAuthTimeout 2h TKTAuthCookieExpires 2h </Location>
Example intranet configuration:
<Location /secret4> AuthType None require valid-user TKTAuthGuestLogin on TKTAuthLoginURL https://www.example.com/auth/login.cgi TKTAuthTimeoutURL https://www.example.com/auth/login.cgi?timeout=1 TKTAuthPostTimeoutURL https://www.example.com/auth/login.cgi?timeout=1&post=1 TKTAuthTimeout 4h TKTAuthCookieExpires 4h </Location>
Support is available on the mod_auth_tkt mailing list, courtesy of sourceforge:
Ticket payload should include IP address, to make debugging IP address problems easier.
Gavin Carr <gavin@openfusion.com.au>
mod_auth_tkt is licensed under the terms of the Apache Licence.
2019-01-26 | 2.3.99b1 |