mod_auth_tkt-2.1.0/ 0000755 0001604 0001604 00000000000 11225571413 013163 5 ustar gavin gavin mod_auth_tkt-2.1.0/Makedefs 0000644 0001604 0001604 00000000612 11225571413 014624 0 ustar gavin gavin #-------------------------------------------------------------------------
# Generated by configure, do not edit!
VERSION = 2.2
APXS = /usr/sbin/apxs
CFLAGS += -DAPACHE22
TARGET = mod_auth_tkt.la
BASEDIR = /home/gavin/work/mat/dev21
MANPATH = /usr/share/man
MAT_VERSION = 2.1.0
# Generated by configure, do not edit!
#-------------------------------------------------------------------------
mod_auth_tkt-2.1.0/cgi/ 0000755 0001604 0001604 00000000000 11153604227 013725 5 ustar gavin gavin mod_auth_tkt-2.1.0/cgi/AuthTktConfig.pm 0000644 0001604 0001604 00000002751 11146347412 017004 0 ustar gavin gavin #
# Config settings for mod_auth_tkt CGI scripts
#
# Customise as required
#
package AuthTktConfig;
use strict;
# CSS stylesheet to use (optional)
our $STYLESHEET = 'tkt.css';
# Page title (optional)
our $TITLE = '';
# Fixed back location, overriding any set via back cookie or back arg
our $FIXED_BACK_LOCATION = '';
# Default back location, if none set via back cookie or back arg
our $DEFAULT_BACK_LOCATION = '';
# Boolean flag, whether to fallback to HTTP_REFERER for back location
our $BACK_REFERER = 1;
# For autologin, mode to fallback to if autologin fails ('login' or 'guest')
our $AUTOLOGIN_FALLBACK_MODE = 'login';
# Additional cookies to clear on logout e.g. PHPSESSID
our @NUKE_COOKIES = qw();
# Debug flag
our $DEBUG = 0;
# Username/password validation for login mode
# (modify or point $validate_sub somewhere appropriate).
# The validation routine should return a true value (e.g. 1) if the
# given username/password combination is valid, and a false value
# (e.g. 0) otherwise.
# This version uses Apache::Htpasswd and a standard htpasswd file.
sub validate
{
my ($username, $password) = @_;
require Apache::Htpasswd;
my $ht = Apache::Htpasswd->new({
passwdFile => '/etc/httpd/conf/htpasswd', ReadOnly => 1 });
return $ht->htCheckPassword($username, $password);
}
our $validate_sub = \&validate;
# For guest mode (if used), setup guest username
# Could use a counter or a random suffix etc.
sub guest_user { return 'guest' }
our $guest_sub = \&guest_user;
1;
mod_auth_tkt-2.1.0/cgi/logout.cgi 0000755 0001604 0001604 00000006652 11153310452 015730 0 ustar gavin gavin #!/usr/bin/perl -w
#
# mod_auth_tkt sample logout script
#
# Note that this needs script needs to be available locally on all domains
# if using multiple domains (unlike login.cgi, which only needs to exist
# on one domain).
#
use File::Basename;
use lib dirname($ENV{SCRIPT_FILENAME});
use Apache::AuthTkt 0.03;
use AuthTktConfig;
use CGI qw(:standard);
use URI::Escape;
use URI;
use strict;
# ------------------------------------------------------------------------
# Configuration settings in AuthTktConfig.pm
# ------------------------------------------------------------------------
# Main code begins
my $at = Apache::AuthTkt->new(conf => $ENV{MOD_AUTH_TKT_CONF});
my $q = CGI->new;
my ($server_name, $server_port) = split /:/, $ENV{HTTP_HOST};
$server_name ||= $ENV{SERVER_NAME};
$server_port ||= $ENV{SERVER_PORT};
my $AUTH_DOMAIN = $at->domain || $server_name;
my $back = '';
$back = $AuthTktConfig::FIXED_BACK_LOCATION if $AuthTktConfig::FIXED_BACK_LOCATION;
$back ||= $q->cookie($at->back_cookie_name) if $at->back_cookie_name;
$back ||= $q->param($at->back_arg_name) if $at->back_arg_name;
$back = $AuthTktConfig::DEFAULT_BACK_LOCATION if $AuthTktConfig::DEFAULT_BACK_LOCATION;
$back ||= $ENV{HTTP_REFERER} if $ENV{HTTP_REFERER} && $AuthTktConfig::BACK_REFERER;
if ($back && $back =~ m!^/!) {
my $hostname = $server_name;
my $port = $server_port;
$hostname .= ':' . $port if $port && $port != 80 && $port != 443;
$back = sprintf "http%s://%s%s", ($port == 443 ? 's' : ''), $hostname, $back;
} elsif ($back && $back !~ m/^http/i) {
$back = 'http://' . $back;
}
$back = uri_unescape($back) if $back =~ m/^https?%3A%2F%2F/;
my $back_html = escapeHTML($back) if $back;
# Logout by resetting the auth cookie
my @cookies = cookie(-name => $at->cookie_name, -value => '', -expires => '-1h',
($AUTH_DOMAIN ? (-domain => $AUTH_DOMAIN) : ()));
push @cookies, map { cookie(-name => $_, -value => '', -expires => '-1h') } @AuthTktConfig::NUKE_COOKIES;
my $redirected = 0;
if ($back) {
my $b = URI->new($back);
# If $back domain doesn't match $AUTH_DOMAIN, add ticket reset to back
if ($b->host !~ m/\b$AUTH_DOMAIN$/i) {
$back .= $b->query ? '&' : '?';
$back .= $at->cookie_name . '=';
}
if ($AuthTktConfig::DEBUG) {
print $q->header(-cookie => \@cookies);
}
else {
# Set (local) cookie, and redirect to $back
print $q->header(
-cookie => \@cookies,
# -location => $back,
);
# For some reason, a Location: redirect doesn't seem to then see the cookie,
# but a meta refresh one does - weird
print $q->start_html(
-head => meta({
-http_equiv => 'refresh', -content => "0;URL=$back"
}));
$redirected = 1;
}
}
# If no $back, just set the auth cookie and hope for the best
else {
print $q->header(-cookie => \@cookies);
}
my @style = ();
@style = ( '-style' => { src => $AuthTktConfig::STYLESHEET } )
if $AuthTktConfig::STYLESHEET;
my $title = $AuthTktConfig::TITLE || "Logout Page";
unless ($redirected) {
# If here, either some kind of error or no back ref found
print $q->start_html(
-title => $title,
@style,
);
print <$title
EOD
if ($AuthTktConfig::DEBUG) {
print <