Changes

Jump to navigation Jump to search
184 bytes added ,  16:32, 27 February 2020
no edit summary
This page presents the web application permission layer of BaseX, which can be used along with [[RESTXQ]].
Non-trivial web applications require a user management: Users need to log in to a web site in order to get access to protected pages; Depending on their status (role, user group, …), they can be offered different views; etc. With {{Version|9.0}} of BaseX, a The light-weight permission layer has been added that simplifies permission checks a lot:
* Permission strings can be attached to RESTXQ functions.
With the {{Code|%perm:allow}} annotation, one or more permission strings can be attached to a RESTXQ function:
<pre classsyntaxhighlight lang="brush:xquery">
(:~ Login page (visible to everyone). :)
declare
</html>
};
</presyntaxhighlight>
The permission strings may denote ids, users, user groups, applications, or any other realms. It is completely up to the user which strings are used, and which functions will be annotated. In the given example code, only the last function has a {{Code|%perm:allow}} annotation.
** If no path argument is specified, {{Code|/}} is assigned instead.
* A variable can be specified in the second argument. A map with the following keys will be bound to that variable:
** {{Code|allow}}: Permission strings attached to the requested function; may be empty.
** {{Code|path}}: Original path of the client request.
** {{Code|method}}: Method of the client request ({{Code|GET}}, {{Code|POST}}, …).
** {{Code|authorization}}: Value of the HTTP Authorization header string; may be empty.
An example:
<pre classsyntaxhighlight lang="brush:xquery">
import module namespace Session = 'http://basex.org/modules/session';
return web:redirect('/main')
};
</presyntaxhighlight>
Some notes:
The following lines of code complete the image:
<pre classsyntaxhighlight lang="brush:xquery">
declare
%rest:path("/login-check")
web:redirect("/")
};
</presyntaxhighlight>
For a full round trip, check out the source code of the [[DBA]] that is bundled with BaseX.
=Changelog=
 
;Version 9.1
 
* Added: {{Code|authorization}} value in permissions map variable
The Module was introduced with Version 9.0.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu