aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2010-02-11 17:26:09 -0500
committerJoey Hess <joey@gnu.kitenet.net>2010-02-11 17:26:09 -0500
commit046095552ac231366d71a3c7a84bdc6d46662212 (patch)
tree959e814144c3e92078960d37338958fa56e284b2 /IkiWiki/Plugin
parentf2d6d4f6b24bb399481c40dc6eb6f3fe25190c5d (diff)
downloadikiwiki-046095552ac231366d71a3c7a84bdc6d46662212.tar
ikiwiki-046095552ac231366d71a3c7a84bdc6d46662212.tar.gz
httpauth: When cgiauthurl is configured, httpauth can now be used alongside other authentication methods (like openid or anonok). Rather than always redirect to the cgiauthurl for authentication, there is now a button on the login form to use it.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/httpauth.pm35
-rw-r--r--IkiWiki/Plugin/openid.pm2
2 files changed, 32 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/httpauth.pm b/IkiWiki/Plugin/httpauth.pm
index a18f8ca54..d0d4da0b7 100644
--- a/IkiWiki/Plugin/httpauth.pm
+++ b/IkiWiki/Plugin/httpauth.pm
@@ -11,6 +11,8 @@ sub import {
hook(type => "auth", id => "httpauth", call => \&auth);
hook(type => "canedit", id => "httpauth", call => \&canedit,
last => 1);
+ hook(type => "formbuilder_setup", id => "httpauth",
+ call => \&formbuilder_setup);
}
sub getsetup () {
@@ -27,6 +29,14 @@ sub getsetup () {
rebuild => 0,
},
}
+
+sub redir_cgiauthurl ($$) {
+ my $cgi=shift;
+ my $params=shift;
+
+ IkiWiki::redirect($cgi, $config{cgiauthurl}.'?'.$params);
+ exit;
+}
sub auth ($$) {
my $cgi=shift;
@@ -43,14 +53,31 @@ sub canedit ($$$) {
my $session=shift;
if (! defined $cgi->remote_user() && defined $config{cgiauthurl}) {
- return sub {
- IkiWiki::redirect($cgi, $config{cgiauthurl}.'?'.$cgi->query_string());
- exit;
- };
+ return sub { redir_cgiauthurl($cgi, $cgi->query_string()) };
}
else {
return undef;
}
}
+sub formbuilder_setup (@) {
+ my %params=@_;
+
+ my $form=$params{form};
+ my $session=$params{session};
+ my $cgi=$params{cgi};
+ my $buttons=$params{buttons};
+
+ if ($form->title eq "signin" &&
+ ! defined $cgi->remote_user() && defined $config{cgiauthurl}) {
+ my $button_text="Login with HTTP auth";
+ push @$buttons, $button_text;
+
+ if ($form->submitted && $form->submitted eq $button_text) {
+ redir_cgiauthurl($cgi, "do=postsignin");
+ exit;
+ }
+ }
+}
+
1
diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm
index b60740c0e..382d8286f 100644
--- a/IkiWiki/Plugin/openid.pm
+++ b/IkiWiki/Plugin/openid.pm
@@ -56,7 +56,7 @@ sub formbuilder_setup (@) {
# OpenID fieldset.
$form->fieldsets("OpenID");
- $form->field(
+ $form->field(
name => "openid_url",
label => gettext("Log in with")." ".htmllink("", "", "ikiwiki/OpenID", noimageinline => 1),
fieldset => "OpenID",