eXist-db library to create and read JSON Web Tokens with arbitrary payloads.
Can be used to authorise requests with restxq and controller.xql.
As long as you keep your secret you can trust the information in valid tokens.
exist-JWT is implemented as an XQuery module and packaged as an eXist-db xar package which will be installed alongside your app.
Install the XAR and
import module namespace jwt="http://existsolutions.com/ns/jwt";
For more details look at examples and tests.
Payloads are serialised to JSON, and JSON object keys are always strings.
Use string keys in payload maps: map { "1": 2 }, not map { 1: 2 }.
Keys of a decoded payload are always xs:string, so look them up with
string keys ($payload?("1"), not $payload?1).
eXist-db versions before 7 also matched an integer key against a string
key. eXist-db 7 follows the spec and does not: ?1 looks up the
xs:integer 1 (XQuery 3.1 §3.11.3.1),
and an xs:string is never the same key as a number
(F&O 3.1 §17.1.1 op:same-key).
- eXist-db version 5.0.0+
- eXist-db crypto lib 1.0.0+
Prequisites:
- node 10+
- a running exist-db at localhost:8080
Clone this repository and
- Install dev dependencies
npm install
- Build and install the XAR package in your exist-db instance
npm start
- Run the testsuite
npm test
Prequisites:
- a running exist-db with jwt installed
Evaluate test/runner.xq
This interaction diagram shows how a token is created and used to access a restricted resource.
