Skip to content

Commit

Permalink
Add page for custom credentials to docs (#1295)
Browse files Browse the repository at this point in the history
* Add page for custom credentials to docs
* Add section about searching for custom credential types
  • Loading branch information
stevenvegt authored Jul 27, 2022
1 parent a9b4d2b commit 7b9a632
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Nuts documentation

pages/deployment/recommended-deployment.rst
pages/deployment/configuration.rst
pages/deployment/custom-credentials.rst
pages/deployment/monitoring.rst
pages/deployment/administering-your-node.rst
pages/deployment/backup-restore.rst
Expand Down
60 changes: 60 additions & 0 deletions docs/pages/deployment/custom-credentials.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.. _custom-credentials-configuration:

Custom Credential Configuration
###############################

Introduction
************

The Nuts node by default is configured to handle a set of Nuts credentials, such as `NutsAuthorizationCredential` and `NutsOrganizationCredential`. These credentials are accepted and indexed automatically. If you want to use custom credentials for your use-case, you have to tell your Nuts node how they are structured.
A Verifiable Credential is structured as a JSON-LD document. Adding extra fields to a JSON-LD document requires adding an extra `@context`-definition which describes these fields.

To configure your Nuts node to recognise these extra fields and custom types, you have to overwrite the JSON-LD configuration. This can be done using the `jsonld.contexts` config. More information about configuration options and its default values can be found at the :ref:`config documentation <nuts-node-config>`.

The node can fetch a context from a http endpoint, but only if this location is explicitly listed as safe. For this you use the `jsonld.contexts.remoteallowlist`.
Or it can fetch the context definition from disk, using a mapping from url to path relative to current directory, or just using absolute paths. For this use the `jsonld.contexts.localmapping`

.. note::

When configuring a list or map value, all values are replaced by your custom values. So if you want to just add an extra context and also use the Nuts context, make sure to add the default values to your config as well!

The default contexts can be accessed using the embedded file system `assets/contexts`. The contents of this directory can be found on Github: The default loaded contexts can be downloaded from the `Github repo <https://github.com/nuts-foundation/nuts-node/tree/master/vcr/assets/assets/contexts>`_.

Example configuration
*********************

Example configuration with an allowed remote context and another locally mapped context:

.. code-block:: yaml
jsonld:
contexts:
remoteallowlist:
- https://schema.org
- https://www.w3.org/2018/credentials/v1
- https://w3c-ccg.github.io/lds-jws2020/contexts/lds-jws2020-v1.json
- https://other-usecase-website.nl/use-case-context.ldjson
localmapping:
- https://nuts.nl/credentials/v1: "/abs/path/to/contexts/nuts.ldjson"
- https://yourdomain.nl/custom-context.ldjson: "/abs/path/to/contexts/custom-context.ldjson"
- https://default-context/v1.ldjson: "assets/contexts/lds-jws2020-v1.ldjson"
- https://relative-path-usage/v42/ldjson: "./data/vcr/contexts/v42.ldjson"
Fetching & Caching
******************

During startup of the node, remote contexts are fetched and cached. If the contents of a remote context changes, the node must be restarted in order for these changes to have effect. Only remote context listed in the `remoteallowlist` are fetched.
Local mappings can be used to pin a version of a context, so no unseen changes can be made. Working with local mappings is also useful for developing purposes when the remote context is older or non-existent. When you work with local mappings, make sure all nodes involved in the use-case have the same custom context configured.

Searching and indexing
**********************

Searching for custom credentials works just as Nuts provided credentials as described in :ref:`searching-vcs`. Note however that the extra fields in the `credentialSubject` added by the custom credential are not indexed by the credential store. Searching for these fields is notably slower (depending on the query and amount of custom credentials). If this becomes a problem, inform the Nuts development team so an appropriate solution can be found.

Resources
*********

- Introduction into JSON-LD: https://json-ld.org/
- The default loaded context definitions: https://github.com/nuts-foundation/nuts-node/tree/master/vcr/assets/assets/contexts
- Nuts node configuration options including the current default values: :ref:`config documentation <nuts-node-config>`
2 changes: 2 additions & 0 deletions docs/pages/integrating/vc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ Will be expanded by the node to:
The `visibility` property indicates the contents of the VC are published on the network, so it can be read by everyone.

.. _searching-vcs:

Searching VCs
*************

Expand Down

0 comments on commit 7b9a632

Please sign in to comment.