Introduction
In the case where integrations are third-party applications, meaning they are not built as part of Pleo or the target system, the integration would either have to keep its own login screen, which would be a suboptimal user experience, or rely on a “session handover” from Pleo. To solve for this, our solution consists of a custom process where Pleo will generate a JWT token that we will pass along with the request. The third-party application can then verify the token by validating the token. If the user isn’t authorized to manage the integration, the Pleo apps will manage the user experience, which means that the integration can assume that any request coming in with a valid token is authorized. Once the token is verified, the integration can create a local session for the user and show the integration, essentially treating the handover as a successful login.Session handover token != access tokenThe session handover token is not an access token. It is a token that is used to verify that the user is authorized to manage the integration. The integration should not use the token to access the Pleo API.
General flow
- From within Pleo, the User clicks on “Enable” or “Configure” for the integration
-
Pleo creates and signs a JWT containing key information such as
- Company ID
- User ID
- Locale
- Expire date
-
Pleo redirects the user to the integration with the JWT token attached in a query param (
pleo_id) - The integration verifies the JWT. Please note that before the token is confirmed valid, no information in the token should be trusted.
Implementation
As much as possible, this spec leans onto standards defined by OpenID Connect [OpenID.Core] set of specifications, for ease of comprehension, implementation, and migration.ID Token
Header Parameters
The Header Parameters for JWT ID Token were chosen to simplify implementation, and mitigate possible token misuse and token substitution attacks. The header MUST contain following Header Parameters:
Example:
Mandatory Claims
The following claims are mandatory and MUST be present on all ID Tokens.
A Client receiving the ID Token MUST validate these claims before using the token, as described in ID Token validation section below.
Example:
End-User Claims
The user personal information included in the claims.Additional Claims
Under theurn:pleo namespace you’ll find additional claims.
Company Information Claim
The Company Information Claim represents a legal entity.
Example:
ID Token validation
A Client receiving the ID Token MUST validate it before making use of any of the Claims that it contains. For reference, see Section 3.1.3.7 ID Token Validation of [OpenID.Core], from which the following algorithm was adapted.- JWT Header Parameters
- The
typJWT Header Parameter MUST bepleo_id+jwt. - The
algvalue of JWT Header Parameter MUST beRS256. - The public key identified by the
kidHeader Parameter MUST be present in public key set published in JWKS (see JWKS locations below) format by the Issuer. - The Client MUST validate the signature of all ID Tokens according to JWS [RFC7515] using the algorithm specified in the JWT
algHeader Parameter. The Client MUST use the keys provided by the Issuer.
- JWT Payload
- The Issuer Identifier presented by
issClaim MUST be a URL that belongs to a Pleo-controlled Issuer trusted by the Client. - The Client MUST validate that the
aud(audience) Claim contains itsclient_idvalue registered at the Issuer identified by theiss(issuer) Claim as an audience. - The current time MUST be before the time represented by the
expClaim. - The
iatClaim MAY be used to reject tokens that were issued too far in the past from the current time.
InfoWhen comparing timestamps, some small leeway MAY be allowed to account for clock skew.
JWKS location
Example of a full ID Token
Following is an example of a full ID Token, with line breaks for illustrative purposes only.JWT Header
sig-1696245492 Key ID for signature verification using RS256 algorithm.
JWT Payload
- In the
subclaim you find04fbc415-e5fc-4acc-937c-8964747ad43cwhich is the ID of a resource representing the user by the name of Jeppe Rindom - In the
audclaim you find67e70bba-088d-47c7-a542-e631bb8cca7fwhich is theclient_idof a hypothetical Client that receives this token - In the
subclaim underurn:pleo:companyyou find3f4d3cf9-806f-4f6f-8cb0-94b69d23109ewhich is the ID of a resource representing “Pleo Technologies A/S” company