* Patch from Alec Berryman adding a http_auth config item that allows
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Mon, 2 Oct 2006 22:56:09 +0000 (22:56 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Mon, 2 Oct 2006 22:56:09 +0000 (22:56 +0000)
  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

IkiWiki.pm
IkiWiki/CGI.pm
IkiWiki/Wrapper.pm
debian/changelog
doc/ikiwiki.setup
ikiwiki.pl

index 1a00f2dbd303894639cd52f3597f3cf2775f0e06..5c62c7f9bd5eb5deaa583228ded3040544ad0c64 100644 (file)
@@ -62,6 +62,7 @@ sub defaultconfig () { #{{{
        timeformat => '%c',
        locale => undef,
        sslcookie => 0,
+       httpauth => 0,
 } #}}}
    
 sub checkconfig () { #{{{
index f550b673a7acceaee1f35195565487b6857cab81..b424892101fbf1fdba85ea6235b1c2f3b0a32de0 100644 (file)
@@ -314,6 +314,11 @@ sub cgi_prefs ($$) { #{{{
        if (! is_admin($user_name)) {
                $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) {
                $form->field(name => "email", force => 1,
@@ -643,6 +648,7 @@ sub cgi () { #{{{
        
        # Everything below this point needs the user to be signed in.
        if (((! $config{anonok} || $do eq 'prefs') &&
+            (! $config{httpauth}) &&
             (! defined $session->param("name") ||
             ! userinfo_get($session->param("name"), "regdate"))) || $do eq 'signin') {
                cgi_signin($q, $session);
@@ -654,6 +660,22 @@ sub cgi () { #{{{
                
                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') {
                cgi_editpage($q, $session);
index 4a98af622cad0d68819fa059f7cc2c7a1d996bf4..a3ecccd5be131b3e745a8d79db869f84a5acf1a9 100644 (file)
@@ -28,7 +28,7 @@ sub gen_wrapper () { #{{{
        my @envsave;
        push @envsave, qw{REMOTE_ADDR QUERY_STRING REQUEST_METHOD REQUEST_URI
                       CONTENT_TYPE CONTENT_LENGTH GATEWAY_INTERFACE
-                      HTTP_COOKIE} if $config{cgi};
+                      HTTP_COOKIE REMOTE_USER} if $config{cgi};
        my $envsave="";
        foreach my $var (@envsave) {
                $envsave.=<<"EOF"
index a6c7821f5ab0d6e8660743f7da77efc51eeaf0d4..b037b517a95d1f7cfee8f0c6a3a638aeceaf2515 100644 (file)
@@ -1,8 +1,12 @@
 ikiwiki (1.29) UNRELEASED; urgency=low
 
   * 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
 
index a9d9414c0be584b18483ee9c541ba4b58749dd68..18c413e6fd8bc74c203f1f455328923ece2d51fb 100644 (file)
@@ -86,6 +86,8 @@ use IkiWiki::Setup::Standard {
        #locale => 'en_US.UTF-8',
        # Only send cookies over SSL connections.
        #sslcookie => 1,
+       # Use HTTP Authentication instead of Ikiwiki's.
+       #httpauth => 1,
        # Logging settings:
        verbose => 0,
        syslog => 0,
index b4cf0e64a959e57e88b862a00f85c5625e4b24d9..b9a0db7e4a35daadf28e2b829153e1958390af4c 100755 (executable)
@@ -47,6 +47,7 @@ sub getconfig () { #{{{
                        "adminemail=s" => \$config{adminemail},
                        "timeformat=s" => \$config{timeformat},
                        "sslcookie!" => \$config{sslcookie},
+                       "httpauth!" => \$config{httpauth},
                        "exclude=s@" => sub {
                                $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
                        },