httpauth: When it's the only auth method, avoid a pointless and confusing signin...
authorJoey Hess <joey@kitenet.net>
Wed, 4 Apr 2012 16:58:36 +0000 (12:58 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 4 Apr 2012 16:58:36 +0000 (12:58 -0400)
IkiWiki/Plugin/httpauth.pm
debian/changelog

index cb488449dd680b2ae36aefde23636ba3fdfe6ab8..76d574b2a899df7e77cb71f2a4f27ee078e76b43 100644 (file)
@@ -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;
index 23c6dc5e38e6e49f400ecb6541888915c397db8e..dd7a5c3092a3720fe3ceeac3ae7fba4755a7718f 100644 (file)
@@ -12,6 +12,8 @@ ikiwiki (3.20120204) UNRELEASED; urgency=low
   * meta: Support keywords header. Closes: #664780
     Thanks, Martin Michlmayr
   * passwordauth: Fix url in password recovery email to be absolute.
+  * httpauth: When it's the only auth method, avoid a pointless and
+    confusing signin form, and just right to the httpauthurl.
 
  -- Joey Hess <joeyh@debian.org>  Wed, 21 Mar 2012 14:33:14 -0400