Page cover
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Guide 2. Implement client

As explained in the authentication flow, The Client needs to perform a couple of steps in order to consume a data service:

  1. Generate a client_assertion JWT

  2. Request an access_token

  3. Access data service with access_token

  4. Consume a data service

  5. Validate a signed JWT

  6. Integrate with backoffice systems

JWT standard libraries

The JWT standard has been so widely accepted as to have implementations in nearly 40 languages.

Step 1. Generate a client_assertion JWT

A client assertion is generated in the form of a JSON Web Token (JWT). This token encompasses the JWT header and the JWT payload (payload) encoded in JSON format, digitally signed to protect the authenticity and integrity of its data content.

A JWT consists of three parts:

a. JWT Header

b. JWT Payload

c. Signature

Step 1a. JWT Header

The JWT Header of the client_assertion consists of the following data:

Please note : the x5c parameter contains an example value, but with correct formatting of the JSON array.

The following rules apply to the content of the JWT header:

  • Except from the alg, typ and x5c parameter, the JWT header SHALL NOT contain other header parameters.

  • Signed JWTs MUST use and specify the RS256 algorithm in the alg header parameter.

  • Signed JWTs MUST use and specify JWT in the typ header parameter.

  • Signed JWTs MUST use the following value in the x5c header parameter :

    • Contains the array of the complete certificate chain that is used for validating the JWTโ€™s signature, up until a root certificate that is listed on the DSGO Trusted List.

    • The leaf certificate of the Client (Party A in the example header above) MUST be the first in the array, the root certificate MUST be the last.

    • Certificates MUST be formatted as base64 encoded DER values, according to RFC 7515 ยง4.1.6

How to use a .PEM file to build the array with the certificate chain as shown in the example above:

  1. Start from your .PEM chain file (leaf + intermediates + root).

  2. For each cert:

    1. Remove -----BEGIN CERTIFICATE----- / -----END CERTIFICATE-----.

    2. Remove line breaks.

    3. Keep the base64 body as a single string.

    4. Insert them into x5c in order [leaf, intermediates, root].

Step 1b. JWT Payload

The JWT payload of the client_assertion consists of the following data:

The following rules apply to the content of the payload:

  • The JWT MUST always contain the iat claim

  • The JWT MUST be set to expire in 30 seconds. The combination of iat and exp claims MUST reflect that. Both iat and exp MUST be in seconds, NOT milliseconds. See UTC Time formatting for requirements.

  • The JWT MUST contain the jti claim for audit trail purposes. The jti is not necessary a GUID/UUID.

  • The iss and sub claims MUST contain the valid DSGO identifier of the Client (Party A).

  • The aud claim MUST contain only the valid DSGO identifier of the Server (Party B). Including multiple audiences creates a risk of impersonation and is therefore not allowed.

  • Depending on the use of the JWT other JWT payload data MAY be defined.

Step 1c. Signature

The client_assertion JWT must be signed with the private key from the electronic seal certificate. This is the eIDAS certificate or the iSHARE test certificate as explained in guide 1.

All JWTs MUST be signed using the JSON Web Signature (JWS) standard which can be found at RFC 7515.

Key vaults

It is recommended to use a key vault solution for securing access to private key information. For more information see the Certificates page.

Step 2. Request an access_token

The Client requests an access_token via a POST call to the /token endpoint of the data service provider. For more information see the /token endpoint within the API specifications.

The token request body consists of the following data:

The following rules apply to the content of this body:

  • The grant_type parameter MUST be client_credentials.

  • The scope parameter MUST be iSHARE.

  • The client_id MUST contain a valid DSGO identifier of the Client (in this example Party A).

  • The client_assertion_type MUST be urn:ietf:params:oauth:client-assertion-type:jwt-bearer

  • The client_assertion MUST be a signed JWT payload (see below).

When the token request is successful, Party B responds with a Bearer access_token.

Act as authorised data service consumer on behalf of a legal data service consumer (delegation)

As a data service consumer you can request a delegated_access_token from the authorisation server of the (authorized) data service provider. For more information about this concept see the learn the basics sections Delegation and fine grained authorisation, Authorisation flow and the implementation guidelines for the authorisation server.

Step 3. Access data service with access_token

The Bearer access_token is used by the data service consumer to request access to a service offered by the resource server of the data service provider.

OAuth 2.0 authorization based on bearer token. MUST contain โ€œBearer โ€œ + access token value. Must be provided if restricted endpoints are needed. See example below:

Step 4. Consume a data service

In consuming the data service a Client needs to implement a function to use a request (GET) or a processing (POST, PUT, DELETE) pattern. The data service provider provides a /dataServices and /capabilities endpoint in which all data services and technical capabilities the organisation offers are registered. The dataServiceInfo object includes information about the data service offered.

Non-repudiation

As a data service consumer you could sign your data service request with your electronic seal (AdES or QSeal) certificate. Non-repudiation assures that an operation or event cannot be denied now or later by the parties involved. For more information see Guide 8. Implement non-repudiation.

Step 5. validate a signed JWT

Besides your own client assertion JWT as described in step 1 above, two types of server-side signed JWTs are used in DSGO to make a data transaction fully auditable.

DSGO states that you SHOULD always validate a signed JWT in order to fully trust it contents.

Validation can be done (programmatically) in the following way:

  • Extract the x5c header parameter value from the JWT, which contains the array of the complete certificate chain in the order of [leaf, intermediates, root]. See step 1a above for an example x5c value

  • Iterate through the certificate chain and perform the following checks

    • Is the Organisation Identifier on the leaf certificate the same as the iss and sub values in the JWT payload for (example NTRNL-98765432)

    • are the dates valid

    • Check the path constraints (CA Flags). This validates if the issuer is allowed to sign

    • Cryptographic validation: did the issuer sign this certificate?

    • Validate -only- the root certificate agains the trusted list in the DSGO Participant Registry.

The trusted list in the DSGO Participant Registry can be retrieved through the /trustedList endpoint.

Validation goes as follows:

  • Make a SHA256 fingerprint of the extracted root certificate and check if that fingerprint is present in the trusted list.

  • Check if status is granted and validity is valid

Step 6. Integrate with backoffice systems

After consuming a data service the response consists of data (or processed data) you probably want to store for further processing within your backoffice systems. You therefore need to integrate this Client component within your software landscape. The DSGO focuses on data exchanges between organisations and not within a single organisation. Therefore no guidance is given on this aspect of the implementation.


Further reading

Source
Description
Author
Language

DSGO specification of the /capabilities endpoint.

digiGO

English

Developer portal documentation on client_assertion.

iSHARE

English

Github repository with code snippets for implementing iSHARE functionality.

iSHARE

English

DSGO specification of the /dataServices endpoint.

digiGO

English

Quick-guide for implementing the service consumer role within iSHARE.

iSHARE

English

Reference implementation of a data service consumer.

iSHARE

English

Detailed description of applying JSON Web Tokens within the DSGO framework.

digiGO

Dutch

Libraries for Token Signing/Verification.

jwt.io

English

Detailed description of signing JWT according to the DSGO framework.

digiGO

Dutch

Explanation of non-repudiation operations within the DSGO Trust Framework. Non-repudiation assures that an operation or event cannot be denied now or later by the parties involved.

digiGO

Dutch

A set of Postman collections to test your implementation.

iSHARE

English

DSGO specification of the /token endpoint.

digiGO

English

Last updated