]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/httpauth.pm
Merge commit '1a8cbf526cdc7e77bfa084e266b8633858b68a09' into sipb
[ikiwiki.git] / IkiWiki / Plugin / httpauth.pm
index 817c2b48719fcaf5cbcdd37d074cf6e301081411..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;