Changes

Jump to navigation Jump to search
73 bytes removed ,  18:35, 1 December 2023
m
Text replacement - "<syntaxhighlight lang="xquery">" to "<pre lang='xquery'>"
With the {{Code|%perm:allow}} annotation, one or more permission strings can be attached to a RESTXQ function:
<syntaxhighlight pre lang="'xquery"'>
(:~ Login page (visible to everyone). :)
declare
</html>
};
</syntaxhighlightpre>
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.
An example:
<syntaxhighlight pre lang="'xquery"'>
import module namespace Session = 'http://basex.org/modules/session';
return web:redirect('/main')
};
</syntaxhighlightpre>
Some notes:
There are numerous ways how users can be authenticated in a web application (via OAuth, LDAP, …). The approach demonstrated on this page is pretty basic and straightforward:
* A login HTML page allows you to enter your credentials (user nameusername, password).
* A login check function checks if the typed in data matches one of the database users. If the input is valid, a session id will be set, and the user will be redirected to the main page. Otherwise, the redirection points back to the login page.
* A logout page deletes the session id.
The following lines of code complete the image:
<syntaxhighlight pre lang="'xquery"'>
declare
%rest:path("/login-check")
web:redirect("/")
};
</syntaxhighlightpre>
For a full round trip, check out the source code of the [[DBA]] that is bundled with BaseX.
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu