]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/httpauth.pm
Merge commit 'fae59b07b02dbcaba892e96ff86f3f800e6ef54a' into sipb
[ikiwiki.git] / IkiWiki / Plugin / httpauth.pm
index 0bdc4a75423a4156f1312d2d20c3872c738d7514..7028130eefe8b62a0659588ec94d1fedc028eae8 100644 (file)
@@ -8,6 +8,7 @@ use IkiWiki 3.00;
 use Data::Dumper;
 
 sub import {
+       hook(type => "checkconfig", id => "httpauth", call => \&checkconfig);
        hook(type => "getsetup", id => "httpauth", call => \&getsetup);
        hook(type => "auth", id => "httpauth", call => \&auth);
        hook(type => "formbuilder_setup", id => "httpauth",
@@ -38,6 +39,19 @@ sub getsetup () {
                        rebuild => 0,
                },
 }
+
+sub checkconfig () {
+       if ($config{cgi} && defined $config{cgiauthurl} &&
+           keys %{$IkiWiki::hooks{auth}} < 2) {
+               # There are no other auth hooks registered, so avoid
+               # the normal signin form, and jump right to httpauth.
+               require IkiWiki::CGI;
+               inject(name => "IkiWiki::cgi_signin", call => sub ($$) {
+                       my $cgi=shift;
+                       redir_cgiauthurl($cgi, $cgi->query_string());
+               });
+       }
+}
                        
 sub redir_cgiauthurl ($;@) {
        my $cgi=shift;
@@ -86,19 +100,14 @@ sub formbuilder_setup (@) {
        }
 }
 
-sub test_httpauth_pagespec ($) {
-       my $page=shift;
-
-       return (
-       );
-}
-
 sub canedit ($$$) {
        my $page=shift;
        my $cgi=shift;
        my $session=shift;
 
        if (! defined $cgi->remote_user() &&
+           (! defined $session->param("name") ||
+             ! IkiWiki::userinfo_get($session->param("name"), "regdate")) &&
            defined $config{httpauth_pagespec} &&
            length $config{httpauth_pagespec} &&
            defined $config{cgiauthurl} &&