aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/httpauth.pm
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki/Plugin/httpauth.pm')
-rw-r--r--IkiWiki/Plugin/httpauth.pm35
1 files changed, 31 insertions, 4 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