Exist-db-5-jwt-workaround

Workaround for JWT in eXist-db 5

In order to overcome an error in the JWT versioning as specific workaround should be followed.

  • Browse to the package manager: Now add libraries to the view by means of the three vertical dots at the top right of the page.
  • Remove the following packages (click the waste bin):
  1. EXPath Cryptographic Module Implementation
  2. jwt - create, read and verify JSON web tokens
  • Navigate, in eXide, to /db/apps/packageservice/configuration.xml and change the repository stanza back to what it was (but you may want to keep the DECOR-repository as a comment):
<repositories>
        <repository active="true" default="true">http://exist-db.org/exist/apps/public-repo</repository>
        <!--<repository active="true" default="true">http://decor.nictiz.nl/apps/public-repo-dev5</repository>-->
</repositories>
  • Browse to the package manager.

Maybe you need to refresh the Package Manager page.

  • Check installed packages:

Just to be sure, navigate to the Package Manager tab labeled Installed and select Show libraries using the menu at the three vertical dots at the top right of the window. Then, verify that library semver.xq version 2.3.0 is installed.

  • Install with the package manager, by first selecting Available:
  1. roaster - OpenAPI Router (version 1.1.5 or higher)
  2. JWT - Create, read and verify JSON Web Tokens (JWT) in exist-db (version 1.1.1 or maybe higher)

As a side effect of installing JWT, the depency “EXPath Cryptographic Module Implementation” has been installed, but we need a newer version. Proceed as follows:

  • Download the file expath-crypto-exist-lib-6.0.0RC1.xar from the following url:

https://github.com/chakl/crypto-exist-java-lib/raw/eXist-5.3.0/prebuilt/expath-crypto-exist-lib-6.0.0RC1.xar

  • Drag the downloaded file expath-crypto-exist-lib-6.0.0RC1.xar into the dropzone at the top of the Package Manager window. This will reinstall the EXPath Cryptographic Module Implementation we removed earlier, but now with another version.
  • Restart eXist-db

It appears that you need to restart eXist-db before all changes have effect, otherwise you will get an error message in the API saying:

err:XQST0034 error found while loading module jwt-auth: Error while loading module jwt-auth.xqm: error found while loading module jwt: Error while loading module : Prolog has more than one imported module that defines the function: {http://expath.org/ns/crypto}generate-signature#7 [at line 5, column 1]
  • End of workaround for JWT in eXist-db 5.