Check one or more resources if given operation is allowed.
Name | Type | Description |
userid | string | either an integer user ID, "current", or "=" followed by a double uri-encoded user name |
Name | Type | Description |
mask | long? | Permission bit mask required for the pages |
verbose | bool? | Return verbose information on permitted pages (default: true |
authenticate | bool? | Force authentication for request (default: false) |
operations | string? | Comma separated list of operations to verify |
invert | bool? | Return filtered instead of allowed pages. Sets verbose to false (default: false |
Name | Value | Description |
OK | 200 | The request completed successfully |
Bad Request | 400 | Invalid input parameter or request body |
Not Found | 404 | Requested user could not be found |
Input:
<pages> <page id="{int}"/> ... </pages>
Output:
<pages> <page id="{int}" href="{uri}"> <title>{text}</title> <path>{text}</path> </page> ... </pages>
Use GET:site/operations to retrieve a list of all operations currently defined on the site.
The following code example checks whether the Anonymous user has LOGIN and READ access to pages with ID 29 and 31
Plug p = Plug.New("http://deki-hayes/@api/deki"); p.At("users", "authenticate").WithCredentials("admin", "password").Get(); XDoc pagesDoc = new XDoc("pages") .Start("page") .Attr("id", 29) .End() .Start("page") .Attr("id", 31) .End(); p.At("users", "=Anonymous", "allowed").With("operations", "LOGIN,READ").Post(pagesDoc);
Sample Response from executing Code
<?xml version="1.0"?> <pages> <page id="29" href="http://deki-hayes/@api/deki/pages/29"> <title>DekiWiki (Hayes)</title> <path/> </page> </pages>
The following curl command returns a sublist of pages user "foo" is allowed to access from a list of pages in "pages.xml".
curl -u username:password -H "Content-Type: application/xml" -d @pages.xml -i http://mindtouch.address/@api/deki/users/=foo/allowed
curl -u username:password -H "Content-Type: application/xml" -d @pages.xml -i http://mindtouch.address/@api/deki/users/=foo/allowed?operations="READ,UPDATE,LOGIN"
curl -u username:password -H "Content-Type: application/xml" -d @pages.xml -i http://mindtouch.address/@api/deki/users/=foo/allowed?mask="21"
NONE | 0 |
LOGIN | 1 |
BROWSE | 2 |
READ | 4 |
SUBSCRIBE | 8 |
UPDATE | 16 |
CREATE | 32 |
DELETE | 256 |
CHANGEPERMISSION | 1024 |
CONTROLPANEL | 2048 |
UNSAFECONTENT | 4096 |
ADMIN | 0x8000000000000000L |
The user "spock" has been given a "Viewer" role, giving him permissions LOGIN, BROWSE, READ, SUBSCRIBE. We want to see what pages in pages.xml Spock has permission to READ.
Content-Type: text/plain
<pages> <page id="565"/> <page id="562"/> <page id="563"/> <page id="564"/> <!-- This page has been set to Private --> </pages>
curl -u admin:password -H "Content-Type: application/xml" -d @pages.xml -i http://192.168.59.128/@api/deki/users/=spock/allowed?operations="READ"
HTTP/1.1 200 OK Date: Fri, 15 Jan 2010 22:11:23 GMT Server: Dream-HTTPAPI/1.7.2.17433 X-Deki-Site: id="default" Content-Type: application/xml; charset=utf-8 Content-Length: 661 Via: 1.1 dekiwiki
Content-Type: application/xml
<?xml version="1.0"?> <pages> <page id="565" href="http://192.168.59.128/@api/deki/pages/565?redirects=0"> <uri.ui>http://192.168.59.128/Bar</uri.ui> <title>Bar</title> <path>Bar</path> <namespace>main</namespace> </page> <page id="562" href="http://192.168.59.128/@api/deki/pages/562?redirects=0"> <uri.ui>http://192.168.59.128/Test</uri.ui> <title>Test</title> <path>Test</path> <namespace>main</namespace> </page> <page id="563" href="http://192.168.59.128/@api/deki/pages/563?redirects=0"> <uri.ui>http://192.168.59.128/Test/Foo</uri.ui> <title>Foo</title> <path>Test/Foo</path> <namespace>main</namespace> </page> </pages>
As you can see, page with ID = 564 is not included since it is marked private. Thus it can be gathered that user "spock" does not have privilege to READ said page.