X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/f55c7d13966ff1cd90ddf50e05829f6bb3eda557..c3e4f1d6736f7b4bd10ec5e46ab7db05b80cbbcb:/IkiWiki/Plugin/httpauth.pm?ds=sidebyside

diff --git a/IkiWiki/Plugin/httpauth.pm b/IkiWiki/Plugin/httpauth.pm
index cb488449d..76d574b2a 100644
--- a/IkiWiki/Plugin/httpauth.pm
+++ b/IkiWiki/Plugin/httpauth.pm
@@ -7,6 +7,7 @@ use strict;
 use IkiWiki 3.00;
 
 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",
@@ -37,6 +38,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;