1 I've got a wiki where editing requires [[plugins/httpauth]] (with
2 `cgiauthurl` working nicely). I now want to let the general public
3 edit Discussion subpages, so I enabled [[plugins/anonok]] and set
4 `anonok_pagespec` to `'*/Discussion'`, but HTTP auth is still being
7 (Actually, what I'll really want to do is probably [[plugins/lockedit]]
8 and a whitelist of OpenIDs in `locked_pages`...)
12 > The only way I can see to support this combination is for httpauth with
13 > cgiauthurl to work more like other actual login types. Which would mean
14 > that on editing a page that needs authentication, ikiwiki would redirect
15 > them to the Signin page, which would then have a link they could follow
16 > to bounce through the cgiauthurl and actually sign in. This would be
17 > significantly different than the regular httpauth process, in which the
18 > user signs in in passing. --[[Joey]]
20 >> My primary userbase has grown accustomed to the seamlessness of
21 >> httpauth with SPNEGO, so I'd rather not reintroduce a seam into
22 >> their web-editing experience in order to let relatively few outsiders
23 >> edit relatively few pages. When is the decision made about whether
24 >> the current page can be edited by the current user (if any)? What
25 >> if there were a way to require particular auth plugins for particular
26 >> PageSpecs? --[[schmonz]]
28 >>> The decision about whether a user can edit a page is made by plugins
29 >>> such as signinedit and lockedit, that also use canedit hooks to redirect
30 >>> the user to a signin page if necessary.
32 >>> A tweak on my earlier suggestion would be to have httpauth notice when the
33 >>> Signin page is being built and immediatly redirect to the cgiauthurl
34 >>> before the page can be shown to the user. This would, though, not play
35 >>> well with other authentication methods like openid, since the user
36 >>> would never see the Signin form. --[[Joey]]
38 >>>> Would I be able to do what I want with a local plugin that
39 >>>> abuses canedit (and auth) to reach in and call the appropriate
40 >>>> plugin's auth method -- e.g., if the page matches */Discussion,
41 >>>> call `openid:auth()`, else `httpauth:auth()`? --[[schmonz]]
43 >>>>> That seems it would be
44 >>>>> annoying for httpauth users (who were not currently authed),
45 >>>>> as they would then see the openid signin form when going to edit a
46 >>>>> Discussion page.
49 >>>>>> I finally see the problem, I think. When you initially
50 >>>>>> suggested "a link they could follow to bounce through the
51 >>>>>> cgiauthurl", presumably this could _be_ the Edit link for
52 >>>>>> non-Discussion pages, so that the typical case of an httpauth
53 >>>>>> user editing an editable-only-by-httpauth page doesn't visibly
54 >>>>>> change. And then the Edit link for Discussion subpages could do
55 >>>>>> as you suggest, adding one click for the httpauth user, who won't
56 >>>>>> often need to edit those subpages. --[[schmonz]]
58 >> On reflection, I've stopped being bothered by the
59 >> redirect-to-signin-page approach. (It only needs to happen once per
60 >> browser session, anyway.) Can we try that? --[[schmonz]]
62 Here is an attempt. With this httpauth will only redirect to the
63 `cgiauth_url` when a page is edited, and it will defer to other plugins
64 like anonok first. I have not tested this. --[[Joey]]
67 diff --git a/IkiWiki/Plugin/httpauth.pm b/IkiWiki/Plugin/httpauth.pm
68 index 127c321..c181164 100644
69 --- a/IkiWiki/Plugin/httpauth.pm
70 +++ b/IkiWiki/Plugin/httpauth.pm
71 @@ -9,6 +9,8 @@ use IkiWiki 3.00;
73 hook(type => "getsetup", id => "httpauth", call => \&getsetup);
74 hook(type => "auth", id => "httpauth", call => \&auth);
75 + hook(type => "canedit", id => "httpauth", call => \&canedit,
80 @@ -33,10 +35,20 @@ sub auth ($$) {
81 if (defined $cgi->remote_user()) {
82 $session->param("name", $cgi->remote_user());
84 - elsif (defined $config{cgiauthurl}) {
92 + if (! defined $cgi->remote_user() && defined $config{cgiauthurl}) {
93 IkiWiki::redirect($cgi, $config{cgiauthurl}.'?'.$cgi->query_string());
104 > With `anonok` enabled, this works for anonymous editing of an
105 > existing Discussion page. auth is still needed to create one. --[[schmonz]]