mod_auth_tkt(3)

πŸ“¦
version 2.3.99~b1 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu jammy

πŸ’– mod_auth_tkt β€” apache ticket authentication module πŸ’–

okay bestie, pull up a chair because we're about to talk about mod_auth_tkt(3), and honestly? it's giving quiet legend. it's part of the User Contributed Perl Documentation, but don't let that fool you β€” this thing is C, and it's been eating.


✨ NAME ✨

mod_auth_tkt β€” apache ticket authentication module 🎟️


🌸 DESCRIPTION 🌸

so, like, 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. she's been around. she's seen things. and she implements a single-signon framework that works across multiple apache instances, different apache versions, and multiple machines. multitasking queen. πŸ‘‘

here's the slay: mod_auth_tkt itself is completely repository-agnostic, because 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). which means you can authenticate against virtually any kind of user repository you can imagine β€” password files, ldap directories, databases, etc. no cap. limitless. πŸ’…

and the feature list?? 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
  • optional 'guest' access for unauthenticated users 🫢

it's literally the whole package.


πŸŽ€ CONFIGURATION πŸŽ€

mod_auth_tkt is configured in your apache configuration files using the following set of directives. and listen β€” all mod_auth_tkt directives begin with 'TKTAuth'. every single one. that's the family name. 🧚

⭐ Server Directives ⭐

mod_auth_tkt supports two apache server-level directives:

  • one required β€” TKTAuthDigest, the shared secret used for digest hashing πŸ”
  • one optional β€” TKTAuthDigestType, the type of digest to use in ticket hashes

both may be global or specific to a virtual host. your call, bestie.

  • TKTAuthSecret <secret> β€” String β€” the secret used for digest hashing. this should be kept secret and changed periodically. like, genuinely. don't be posting this in the group chat. e.g.
TKTAuthSecret "w b@5b15#664038f.f9d8U19b7e25 664eY9ad2%4393e,a2ef"
  • TKTAuthDigestType [ MD5 | SHA256 | SHA512 ] β€” String, one of MD5 | SHA256 | SHA512. the digest/hash type to use in tickets. the default is MD5, which is faster, but has now been shown to be vulnerable to collision attacks. 😬 such attacks are not directly applicable to mod_auth_tkt, which primarily relies on the security of the shared secret rather than the strength of the hashing scheme. more paranoid users will probably prefer to use one of the SHA digest types, however.

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.

πŸ¦‹ Directory Directives πŸ¦‹

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. iykyk.

  • AuthType None / require <users> β€” mod_auth_tkt requires the following standard apache authentication directives to trigger authentication:
AuthType None
require valid-user      # or require user1, user2, etc.
  • TKTAuthLoginURL <url> β€” Standard URL to which unauthenticated users are redirected. this is a required directive unless you are using guest mode via 'TKTAuthGuestLogin on'. e.g.
TKTAuthLoginURL https://www.example.com/auth/login.cgi
  • TKTAuthTimeoutURL <url> β€” URL to which users are redirected in the event their ticket times out. Default: TKTAuthLoginURL. e.g.
TKTAuthTimeoutURL https://www.example.com/auth/login.cgi?timeout=1
  • TKTAuthPostTimeoutURL <url> β€” URL to which users are redirected in the event their ticket times out during a POST operation. this case is distinguished to allow you to handle such cases specially β€” you probably don't want to redirect back to the referrer after login, for instance. Default: TKTAuthTImeoutURL. e.g.
TKTAuthPostTimeoutURL https://www.example.com/auth/login.cgi?posttimeout=1
  • TKTAuthUnauthURL <url> β€” URL to which users are redirected in the event that they are not authorised for a particular area, e.g. incorrect tokens. 🚫
TKTAuthUnauthURL https://www.example.com/auth/login.cgi?unauth=1
  • TKTAuthGuestLogin <boolean> β€” Flag to turn on 'guest' mode, which means that any user without a valid ticket is authenticated anyway as the TKTAuthGuestUser user. this is useful for allowing public access for guests and robots πŸ€–, while allowing more personalised or privileged access for users who login. Default: off. e.g.
TKTAuthGuestLogin on
  • TKTAuthGuestCookie <boolean> β€” Flag to indicate whether or not to issue a ticket cookie for guest users. issuing a cookie is primarily useful where you are using UUID-ed guest users, where you want them to keep the initial guest username you issue them for tracking purposes. e.g.
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. 😌

  • TKTAuthGuestUser <string> β€” Username to be used for the guest user (in the ticket uid, REMOTE_USER environment variable, etc).

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 a 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
  • TKTAuthGuestFallback <boolean> β€” Flag to indicate that a timed out user ticket should automatically fallback to 'guest' status, and issue a new guest ticket, instead of redirecting to the TKTAuthTimeoutURL. only makes sense with TKTAuthGuestLogin on, of course. πŸ™ˆ

Default: off.

  • TKTAuthGuestEmpty <boolean> β€” Flag to indicate that the guest username should be an empty string. useful for allowing applications to fallback to native authentication when REMOTE_USER is empty. (NOTE: REMOTE_USER must exist to satisfy Require valid-user, but will be empty.) only makes sense with TKTAuthGuestLogin on, of course.

Default: off.

  • TKTAuthTimeout <seconds> β€” The ticket timeout period, in seconds. after this period, the ticket is considered stale, and the user is redirected to the TKTAuthTimeoutURL (if set, else to the TKTAuthLoginURL). note that the ticket can be automatically refreshed, however, using the next setting. πŸ”„

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
  • TKTAuthTimeoutRefresh <decimal> β€” A number between 0 and 1 indicating whether and how to refresh ticket timestamps. 0 means never refresh (hard timeouts). 1 means refresh tickets every time. .33 (for example) means refresh if less than .33 of the timeout period remains.

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
  • TKTAuthCookieName <name> β€” The name used for the ticket cookie. Default: 'auth_tkt'. πŸͺ
  • TKTAuthDomain <domain> β€” The domain to use in ticket cookies, which defines the hosts for which the browser will submit this cookie. Default: the apache ServerName (either global or for a specific virtual host).
  • TKTAuthCookieExpires <seconds> β€” NB: this directive is not currently supported on apache 1.3.x! ⚠️

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 this 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
  • TKTAuthBackArgName <name> β€” The name used for the back GET parameter. if this is set, mod_auth_tkt will add a GET parameter to all redirect URLs containing a URI-escaped version of the current requested page. e.g. if the requested page is http://www.example.com/index.html and TKTAuthBackArgName is set to 'back', mod_auth_tkt will add a parameter like:
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'.

  • TKTAuthBackCookieName <name> β€” The cookie name to use for the back cookie. if this is set, mod_auth_tkt will set a back cookie containing a URI-escaped version of current requested page when redirecting (see TKTAuthBackArgName above), instead of using a GET parameter.

Default: none (not used).

  • TKTAuthToken <token> β€” String indicating a required token for the given location, implementing a simple form of token-based access control. if the user's ticket does not contain one or more of the required tokens in the ticket token list then mod_auth_tkt will redirect to the TKTAuthUnauthURL location (or TKTAuthLoginURL if not set). your login script is expected to set the appropriate token list up at login time, of course. 🎫
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
  • TKTAuthIgnoreIP <boolean> β€” bestie, this flag tells mod_auth_tkt to straight-up ignore the client IP address when it's authenticating tickets. ⚠️ But heads up: your login script has to support this too, by setting the client IP address to 0.0.0.0. This is lowkey required a lot out on the open internet, especially if you're using an HTTPS login page (as you should πŸ’…) and you've got more than a handful of users β€” the typical villain here being transparent HTTP proxies at ISPs. 😭

Default: 'off' i.e. ticket is only valid from the originating IP address.

e.g.

TKTAuthIgnoreIP on
  • TKTAuthRequireSSL <boolean> β€” this one says "no SSL, no ticket, periodt". It's a flag used to indicate that tickets should be refused except in SSL/HTTPS protected contexts (and if they're not, it redirects to TKTAuthLoginURL, which presumably would be using HTTPS). Default: 'off' (don't require SSL). e.g.
TKTAuthRequireSSL on

See also TKTAuthCookieSecure below. πŸ‘€

  • TKTAuthCookieSecure <boolean> β€” sets the 'secure' flag on all the ticket cookies issued, which tells the browser they should only ever be sent in SSL/HTTPS protected contexts. Default: 'off' (don't set 'secure' flag). e.g.
TKTAuthCookieSecure on

So like, TKTAuthRequireSSL and TKTAuthCookieSecure are normally used together β€” they're a duo, an iconic pair, πŸ’–. But there's one case where it makes sense to use them separately: when you're proxying through a separate SSL-equipped reverse proxy, you'd want TKTAuthCookieSecure by itself (since the proxied request will never be via SSL). Slay. ✨

  • TKTAuthDebug <integer> β€” turns on mod_auth_tkt debug output messages in your error log, and the verbosity goes up with higher integer values. Current range: 1-3. πŸ”
Ngl, you'll also need apache 'LogLevel debug' set to actually see these messages. No setting it, no messages. That's the vibe check.

🌈 EXAMPLES 🌈

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 β€” nobody's stopping them bestie):

<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 🫢

Need help? There's a whole support squad available on the mod_auth_tkt mailing list, courtesy of sourceforge. 🧚


πŸ’€ BUGS πŸ’€

icket payload should include IP address, to make debugging IP address problems easier. (Yes that's a real note, don't @ me, it's in the source.) πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

Gavin Carr <gavin@openfusion.com.au>


πŸŽ€ LICENCE πŸŽ€

mod_auth_tkt is licensed under the terms of the Apache Licence.


And that's the whole page, bestie β€” this was mod_auth_tkt(3), version 2.3.99b1, dated 2019-01-26. Go forth and auth your tickets, you absolute icon. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from