dokufreaks / plugin-blogtng

http://dokuwiki.org/plugin:blogtng
GNU General Public License v2.0
36 stars 18 forks source link

Listings by Sqlite don't respect ACLs #92

Closed michitux closed 9 years ago

michitux commented 11 years ago

When you assign a page to a blog it will be displayed in that blog listing regardless of the permissions of the page. I think this is an issue for several reasons:

Klap-in commented 11 years ago

The commit (part of listingsacl branch) referenced above added acl checks in the queries of the <blog *> syntaxes. The new form syntax does already check acl.

Are there more cases which doesn't respect ACL?

michitux commented 11 years ago

What about comments in the recent comments syntax for pages the user can't view? I wonder if blogtng should also check if the page is hidden, i.e. if isHiddenPage($id) returns false (or isVisiblePage($id) returns true). I've seen that you've added ACL checks for the tag cloud. Unfortunately this slows down the tag cloud generation (see dokufreaks/plugin-cloud#20), but I don't know how bad it is in the case of blogtng compared to the tag/cloud plugin. A possibility is adding a configuration option if only public pages should be considered for the tag cloud and if an option should be enabled to chose for which user or group the ACLs should be checked (or if no ACLs should be checked) for wikis where write access is only given to trusted users and there should be a private and a public tag cloud. At least that are my ideas for the tag/cloud-plugin, I don't know if blogtng needs to support this variety of options.

Klap-in commented 11 years ago

The aclcheck for tag cloud generation are quite similar to that of the other queries of blogTNG, when it give performance penalties, i guess the other queries are affected too.

With respect to tag cloud, the tag cloud of blogTNG doesn't calculate counts for the tags. Maybe therefore this cloud is not that slow?

I wasn't aware that the auth_quickaclcheck() method can slow down the whole stuff. I have not a big data set here. Sofar i have seen in the <blog *.> stuff the caching is default disabled. I guess that enable caching will store stuff too long.

michitux commented 11 years ago

The tag cloud of blogtng does calculate counts for the tags which means that sqlite needs to execute the acl check for every page that is a blog post at least once (maybe even for each tag and page once). With the check for hidden pages this also includes one triggered event for each page. The load_by_blog-function returns tag-pid-pairs and for each of these pairs the acls need to be checked, and this function is used by xhtml_tagcloud.

I'm more worried about the tag cloud than the other queries because I hope that the function will only be executed for pages that might be returned as result which shouldn't be much more than the actually returned pages (unless the newest pages are all read-protected).

Klap-in commented 10 years ago

I'm looking to add a function for checking page access to the Sqlite plugin.

So far i have some questions:

                  WHERE '.$blog_query.$tag_query.'
                       AND CHECKACL(page) >= '.AUTH_READ.'
                  GROUP BY A.pid
    /**
     * Callback checks the permissions for the current user
     *
     * This function is registered as a SQL function named CHECKACL
     *
     * @param  string $pageid page ID (needs to be resolved and cleaned)
     * @return int permission level
     */
    public function _checkACL($pageid) {
        static $aclcache = array();

        if(isset($aclcache[$pageid])) {
            return $aclcache[$pageid];
        }

        if(isHiddenPage($pageid)) {
            $acl = AUTH_NONE;
        } else {
            $acl = auth_quickaclcheck($pageid);
        }
        $aclcache[$pageid] = $acl;
        return $acl;
    }

Let i mention @splitbrain and @Chris--S as well, your feedback is welcome too.

Klap-in commented 10 years ago

Any feedback at this idea for adding ACL and hidden checks to Sqlite plugin?

Klap-in commented 9 years ago

All the queries to sqlite-db are now checking per page the ACL.