* Patch from Alec Berryman adding a http_auth config item that allows

using HTTP Authentication instead of ikiwiki's built in authentication.
  Useful for eg, large sites with their own previously existing user auth
  setup. Closes: #384534
master
joey 2006-10-02 22:56:09 +00:00
parent fb3a160f2d
commit 67b513e8c4
6 changed files with 32 additions and 2 deletions

View File

@ -62,6 +62,7 @@ sub defaultconfig () { #{{{
timeformat => '%c', timeformat => '%c',
locale => undef, locale => undef,
sslcookie => 0, sslcookie => 0,
httpauth => 0,
} #}}} } #}}}
sub checkconfig () { #{{{ sub checkconfig () { #{{{

View File

@ -315,6 +315,11 @@ sub cgi_prefs ($$) { #{{{
$form->field(name => "locked_pages", type => "hidden"); $form->field(name => "locked_pages", type => "hidden");
} }
if ($config{httpauth}) {
$form->field(name => "password", type => "hidden");
$form->field(name => "confirm_password", type => "hidden");
}
if (! $form->submitted) { if (! $form->submitted) {
$form->field(name => "email", force => 1, $form->field(name => "email", force => 1,
value => userinfo_get($user_name, "email")); value => userinfo_get($user_name, "email"));
@ -643,6 +648,7 @@ sub cgi () { #{{{
# Everything below this point needs the user to be signed in. # Everything below this point needs the user to be signed in.
if (((! $config{anonok} || $do eq 'prefs') && if (((! $config{anonok} || $do eq 'prefs') &&
(! $config{httpauth}) &&
(! defined $session->param("name") || (! defined $session->param("name") ||
! userinfo_get($session->param("name"), "regdate"))) || $do eq 'signin') { ! userinfo_get($session->param("name"), "regdate"))) || $do eq 'signin') {
cgi_signin($q, $session); cgi_signin($q, $session);
@ -655,6 +661,22 @@ sub cgi () { #{{{
return; return;
} }
if ($config{httpauth} && (! defined $session->param("name"))) {
if (! defined $q->remote_user()) {
error("Could not determine authenticated username.");
}
else {
$session->param("name", $q->remote_user());
if (!userinfo_get($session->param("name"),"regdate")) {
userinfo_setall($session->param("name"), {
email => "",
password => "",
regdate=>time,
});
}
}
}
if ($do eq 'create' || $do eq 'edit') { if ($do eq 'create' || $do eq 'edit') {
cgi_editpage($q, $session); cgi_editpage($q, $session);
} }

View File

@ -28,7 +28,7 @@ sub gen_wrapper () { #{{{
my @envsave; my @envsave;
push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI
CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE
HTTP_COOKIE} if $config{cgi}; HTTP_COOKIE REMOTE_USER} if $config{cgi};
my $envsave=""; my $envsave="";
foreach my $var (@envsave) { foreach my $var (@envsave) {
$envsave.=<<"EOF" $envsave.=<<"EOF"

6
debian/changelog vendored
View File

@ -1,8 +1,12 @@
ikiwiki (1.29) UNRELEASED; urgency=low ikiwiki (1.29) UNRELEASED; urgency=low
* Patch from Paul Tötterman to use CP in the Makefile. * Patch from Paul Tötterman to use CP in the Makefile.
* Patch from Alec Berryman adding a http_auth config item that allows
using HTTP Authentication instead of ikiwiki's built in authentication.
Useful for eg, large sites with their own previously existing user auth
setup. Closes: #384534
-- Joey Hess <joeyh@debian.org> Thu, 28 Sep 2006 19:10:58 -0400 -- Joey Hess <joeyh@debian.org> Mon, 2 Oct 2006 18:50:29 -0400
ikiwiki (1.28) unstable; urgency=low ikiwiki (1.28) unstable; urgency=low

View File

@ -86,6 +86,8 @@ use IkiWiki::Setup::Standard {
#locale => 'en_US.UTF-8', #locale => 'en_US.UTF-8',
# Only send cookies over SSL connections. # Only send cookies over SSL connections.
#sslcookie => 1, #sslcookie => 1,
# Use HTTP Authentication instead of Ikiwiki's.
#httpauth => 1,
# Logging settings: # Logging settings:
verbose => 0, verbose => 0,
syslog => 0, syslog => 0,

View File

@ -47,6 +47,7 @@ sub getconfig () { #{{{
"adminemail=s" => \$config{adminemail}, "adminemail=s" => \$config{adminemail},
"timeformat=s" => \$config{timeformat}, "timeformat=s" => \$config{timeformat},
"sslcookie!" => \$config{sslcookie}, "sslcookie!" => \$config{sslcookie},
"httpauth!" => \$config{httpauth},
"exclude=s@" => sub { "exclude=s@" => sub {
$config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/; $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
}, },