httpauth: When it's the only auth method, avoid a pointless and confusing signin form, and just right to the httpauthurl.

master
Joey Hess 2012-04-04 12:58:36 -04:00
parent d1849a4deb
commit 93bda514ba
2 changed files with 16 additions and 0 deletions

View File

@ -7,6 +7,7 @@ use strict;
use IkiWiki 3.00; use IkiWiki 3.00;
sub import { sub import {
hook(type => "checkconfig", id => "httpauth", call => \&checkconfig);
hook(type => "getsetup", id => "httpauth", call => \&getsetup); hook(type => "getsetup", id => "httpauth", call => \&getsetup);
hook(type => "auth", id => "httpauth", call => \&auth); hook(type => "auth", id => "httpauth", call => \&auth);
hook(type => "formbuilder_setup", id => "httpauth", hook(type => "formbuilder_setup", id => "httpauth",
@ -38,6 +39,19 @@ sub getsetup () {
}, },
} }
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 ($;@) { sub redir_cgiauthurl ($;@) {
my $cgi=shift; my $cgi=shift;

2
debian/changelog vendored
View File

@ -12,6 +12,8 @@ ikiwiki (3.20120204) UNRELEASED; urgency=low
* meta: Support keywords header. Closes: #664780 * meta: Support keywords header. Closes: #664780
Thanks, Martin Michlmayr Thanks, Martin Michlmayr
* passwordauth: Fix url in password recovery email to be absolute. * 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 -- Joey Hess <joeyh@debian.org> Wed, 21 Mar 2012 14:33:14 -0400