httpauth: When cgiauthurl is configured, httpauth can now be used alongside other...
authorJoey Hess <joey@gnu.kitenet.net>
Thu, 11 Feb 2010 22:26:09 +0000 (17:26 -0500)
committerJoey Hess <joey@gnu.kitenet.net>
Thu, 11 Feb 2010 22:26:09 +0000 (17:26 -0500)
IkiWiki/Plugin/httpauth.pm
IkiWiki/Plugin/openid.pm
debian/changelog
doc/bugs/anonok_vs._httpauth.mdwn
doc/plugins/httpauth.mdwn

index a18f8ca54619c146093498891f67057fd6c2b9e5..d0d4da0b74e6b7925ae8b85b6ef43d3cb6cff36c 100644 (file)
@@ -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
index b60740c0e0c1489e9e69f2847a1958fb9ab5732d..382d8286f73bd371010810e6b295aab5946a68e0 100644 (file)
@@ -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",
index 358a5dc5cc00d95aa88352ea36ef052e6c767f63..3dd68558eefe1833d276bcb102055181142f51f4 100644 (file)
@@ -15,6 +15,10 @@ ikiwiki (3.20100123) UNRELEASED; urgency=low
   * Fix color and format plugins to appear in the websetup interface.
   * amazon_s3: Fix to support the EU S3 datacenter, which is more picky
     about attempts to create already existing buckets.
+  * 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.
 
  -- Joey Hess <joeyh@debian.org>  Tue, 26 Jan 2010 22:25:33 -0500
 
index b738e3b6c9ed96d2b03fcfeccf6cf8e653f05391..bff37e18bc7f2bad326e997d7a08f7ed79a415f1 100644 (file)
@@ -114,3 +114,5 @@ index 127c321..a18f8ca 100644
 >> time that httpauth is redirecting to the cgiauthurl. As mentioned above,
 >> the only way to deal with that would be to add a link to the signin page
 >> that does the httpauth signin. --[[Joey]] 
+
+>>> That's dealt with in final version. [[done]] --[[Joey]] 
index 77796a3d7fda5a86d1e861c9e3d6a00dd3c292f0..a7aac558b535fed7830376c2086aa3f65185f875 100644 (file)
@@ -14,10 +14,11 @@ signed into the wiki. This method is suitable only for private wikis.
 ## separate cgiauthurl
 
 To use httpauth for a wiki where the content is public, and where
-the `ikiwiki.cgi` needs to be usable without authentication (for searching
-and so on), you can configure a separate url that is used for
-authentication, via the `cgiauthurl` option in the setup file. This
-url will then be redirected to whenever authentication is needed.
+the `ikiwiki.cgi` needs to be usable without authentication (for searching,
+or logging in using other methods, and so on), you can configure a separate
+url that is used for authentication, via the `cgiauthurl` option in the setup
+file. This url will then be redirected to when a user chooses to log in using
+httpauth.
 
 A typical setup is to make an `auth` subdirectory, and symlink `ikiwiki.cgi` 
 into it. Then configure the web server to require authentication only for