]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/inband_acl_data.mdwn
providing the .po file so that it can be included
[ikiwiki.git] / doc / todo / inband_acl_data.mdwn
1 it [[!tag wishlist]] would be nice to have acls that get their data from wiki pages.
2
3 a particular use case is the [debienna wiki](http://debienna.at/) (our local
4 debian usergroup), where there are few admins, but everyone who has been
5 granted edit rights to the wiki should be allowed to allow other people in.
6 those people can register their accounts on their own, but may only write to a
7 dedicated page where they request write privileges.
8
9 the setup file should look like this:
10
11     locked_pages: '!PleaseClearForEditing and !user_in_page(DebiennaGroup)'
12
13 and DebiennaGroup would contain
14
15     * \[[chrysn]]
16     * \[[albert]]
17     * \[[rhonda]]
18
19 etc.
20
21 a suggested implementation is published on
22 `git://prometheus.amsuess.com/ikiwiki-plugins` and is short enough to be quoted
23 here:
24
25 <!-- don't copy/paste from here, clone the git or copy/paste from the ikiwiki rendered version, i had to scape [ -->
26
27     #!/usr/bin/perl
28     # Ikiwiki "user_in_page" pagespec
29     # 
30     # The pagespec user_in_page(some_page) returns success if the currently logged
31     # in user is mentioned in a wikilink on some_page (which might be relative to
32     # the currently active page, which allows per-directory restrictions).
33     #
34     # To be precise, the string \[[${USERNAME}]] has to be present in the some_page
35     # source file.
36     
37     package IkiWiki::Plugin::user_in_page;
38     
39     package IkiWiki::PageSpec;
40     
41     sub match_user_in_page ($$;@) {
42         my $page=shift;
43         my $userlistpage=shift;
44         my %params=@_;
45         my $user=$params{user};
46     
47         # this is relative to page, but this is intentional
48         my $userlistpagename = IkiWiki::bestlink($page, $userlistpage);
49     
50         # FIXME: pagesources seems not to be defined in do=edit
51         my $userlistpagefile = "$userlistpagename/index.mdwn";
52     
53         my $userlistpagedata = IkiWiki::readfile(IkiWiki::srcfile($userlistpagefile));
54     
55         if ($userlistpagedata =~ /\Q\[[$user]]\E/ ) {
56                 return IkiWiki::SuccessReason->new("User $user is listed in $userlistpagename");
57         } else {
58                 return IkiWiki::FailReason->new("User $user is not listed in $userlistpagename");
59         }
60     }
61     
62     1
63
64 before i complete this as a proposed plugin, i'd like to know
65
66 * if you have better ideas to check for the delimited user name than the
67   \[[$user]] scheme?
68
69 * i had to manually expand `$pagename` to `$pagename/index.mdwn` as
70   %pagesources seems to be empty in the context of `?do=edit`. how is this
71   supposed to work?
72
73 --[[chrysn]]
74
75 > Just for the record, this seems to be a special case of [[todo/per_page_ACLs/]]. -- [[anarcat]]