# JSON Web Token (JWT)

*This part of the iSHARE Scheme is considered normative and is therefore compliant with RFC 2119.*

A JSON Web Token (JWT) is used when non-repudiation between parties is required. A statement, of which the data is encoded in JSON, is digitally signed to protect the authenticity and integrity of the statement.

iSHARE uses signed JWTs in the following ways:

1. In a request for an OAuth Access Token or an OpenID Connect ID token the client sends a signed JWT. The client is authenticated based on the verification of the JWT's signature.
2. Delegation evidence is presented as a signed JWT. The signature of the Authorization Registry or Entitled Party provides proof to other parties.
3. In a response from a server iSHARE metadata is presented as a signed JWT. The signature is used to bind the iSHARE metadata (such as license information) in the JWT to the content of the response.
4. A service from an iSHARE Service Provider MAY require a request to be signed.

On this page the generic requirements for a signed iSHARE JWT are specified.

### General <a href="#jsonwebtoken-jwt-general" id="jsonwebtoken-jwt-general"></a>

All iSHARE JWTs MUST be signed using the [JWS specifications](https://tools.ietf.org/html/rfc7515).

### Header <a href="#jsonwebtoken-jwt-header" id="jsonwebtoken-jwt-header"></a>

For the header of an iSHARE signed JWT the following requirements apply:

* Signed JWTs MUST use and specify the `RS256` algorithm in the `alg` header parameter
* Singed JWTs MUST contain an array of the complete certificate chain that should be used for validating the JWT's signature in the `x5c` header parameter
* Certificates MUST be formatted as base64 encoded DER
* The certificate of the client MUST be the first in the array, the root certificate MUST be the last
* Except from the `alg`, `typ` and `x5c` parameter, the JWT header SHALL NOT contain other header parameters

Example JWT header

```
{
  "alg": "RS256",
  "typ": "JWT",
  "x5c": [ "MIIGCDCCA/CgAwIBAgICEAQwDQYJKoZIhvcNAQELBQAwgZAxCzAJBgNVBAYTAk5MMQswCQYDVQQIDAJOSDEPMA0GA1UECgwGaVNIQVJFMREwDwYDVQQLDAhTZWN1cml0eTEoMCYGA1UEAwwfaVNIQVJFIE5MIENlcnRpZmljYXRlIEF1dGhvcml0eTEmMCQGCSqGSIb3DQEJARYXaW5mb0Bpc2hhcmUtcHJvamVjdC5vcmcwHhcNMTcwNjI3MDgyOTIzWhcNMTgwNzA3MDgyOTIzWjCBnDEL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F8wgCOZd1pyfrBVu3f3SXbUgNjoe5tEW6xsOQsjjqNnQiJMJx6ea56L2kbW7E6kOs+Mck9Kz8ZQQB58iPGyx3ahMLOrxbPoItbqKuyDwco7AzLf7ea9zye0up8ubNDYFaKJfiIDsnVbUPA6FbTn4fSQpeeOK1fjrzSaUpeMOdOomj0Zjwt6K7W7ckxoIfOecW4dcPENpXImkBPQXsGxvClDf/6e/jPti3CPgxJF3747Hq6tBSH0GzCrYv4bForQu43MzqZKHbX8FF1PpHSaiXJK/Hu8WJDXXBq5Pedel/lJSajdTsUDsiFXkj/pY0uJ6M0x/EonozaCPcHwdPsvr6nrrHWQXo4ayP7ntegJA3GrGXcaP+peEQmF9nWgVwPq33C1TrPNaiMxHz5toxl0YhnbA+5eH2CTBjDFJnr2uaeh8BzbkdE29WkOsqJZAIUEMmRwxcxBW20JGAlhF6MPFADjPYG0Ljdjbwq2H+LQtRf+tE6Z7nwM/cAT4dEB7Me1uJrYucVjLLSNXCRKQaDKKZMoHhAciLeKLMrSgUDaAi0AUKXduCymUw3n"
]
}
```

### Payload <a href="#jsonwebtoken-jwt-payload" id="jsonwebtoken-jwt-payload"></a>

For the payload of an iSHARE signed JWT the following requirements apply:

* The JWT payload MUST conform to the `private_key_jwt` method as specified in OpenID Connect 1.0 [Chapter 9](http://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication) 1 2
* The JWT MUST always contain the `iat` claim
* The `iss` and `sub` claims MUST contain the valid [iSHARE identifier](https://framework.ishare.eu/version-2.0.1/glossary-and-legal-notices/glossary#glossary-eorieori) of the client 1
* The `aud` claim MUST contain only the valid [iSHARE identifier](https://framework.ishare.eu/version-2.0.1/glossary-and-legal-notices/glossary#glossary-eorieori) of the server. (Including multiple audiences creates a risk of impersonation and is therefore not allowed)
* The JWT MUST be set to expire in 30 seconds. The combination of `iat` and `exp` claims MUST reflect that. See Dates and times for requirements
* Depending on the use of the JWT other JWT payload data MAY be defined

#### Additional rationale <a href="#jsonwebtoken-jwt-additionalrationale" id="jsonwebtoken-jwt-additionalrationale"></a>

1 In OAuth 2.0 clients are generally pre-registered. Since in iSHARE servers interact with clients that have been previously unknown this is not a workable requirement. Therefore iSHARE implements a generic client identification and authentication scheme, based on iSHARE whitelisted [PKIs](https://framework.ishare.eu/version-2.0.1/readme/detailed-descriptions/technical/generic-technical-standards/pki).

2 Since OAuth 2.0 doesn't specify a PKI based authentication scheme, but OpenID Connect 1.0 does, iSHARE chooses to use the scheme specified by OpenID Connect in all use cases. This is preferred above defining a new proprietary scheme.

Example JWT payload:

```
{
  "iss": "EU.EORI.NL123456789",
  "sub": "EU.EORI.NL123456789",
  "aud": "NL.KVK.12345678",
  "jti": "378a47c4-2822-4ca5-a49a-7e5a1cc7ea59", // Note this is not necessary a GUID
  "exp": 1504683475, // Equals iat + 30 seconds
  "iat": 1504683445
}
```

### Processing a JWT <a href="#jsonwebtoken-jwt-processingajwt" id="jsonwebtoken-jwt-processingajwt"></a>

* A server SHALL NOT accept a JWT more than once for authentication of the Client. However within it's time to live a Service Provider MAY forward a JWT from a Service Consumer to one or more other servers (Entitled Party or Authorization Registry) to obtain additional evidence on behalf of the Service Consumer. These other servers SHALL accept the JWT for indirect authentication of the Service Consumer during the JWT's complete time to live
* A server SHALL only accept a forwarded JWT if the `aud` claim of the forwarded JWT matches the `iss` claim of the JWT from the client that forwards the JWT
* JWT contents that are not specified within the iSHARE scope SHOULD be ignored


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://framework.ishare.eu/version-2.0.1/readme/detailed-descriptions/technical/generic-technical-standards/json-web-token-jwt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
