Handling Redirects
Backwards Compatibility NoteTo avoid breaking changes for customers,
redirectTokenvalidation is presently optional.If
redirectTokenis provided in a call toGetSessionResult, the Trinsic API will validate and reject invalid tokens, but its presence is not yet mandatory.
To disable this backwards-compatible behavior, set theenableRedirectBackwardsCompatibilityparameter tofalsewhen creating a Session. This will causeredirectTokenvalidation to be required as part of the core flow for redirect-based Sessions.
ValidatingredirectTokenwill become mandatory in the future.
Overview
A core component of most user journeys through Trinsic is the final redirect back to your application or website.
If you use Hosted Provider Sessions, every Session is redirect-based; if using Direct Provider Sessions, any session with a CaptureRedirect result-collection method is redirect-based.
Handling these redirects correctly and securely is critical for any integration with Trinsic.
Quick Guide
- When a Session is redirect-based, the user will come back to your Session's
redirectUrlwith a set of Success Parameters or Failure Parameters.- Sessions are redirect-based if they are either A) Hosted Provider Sessions or B) Direct Provider Sessions with a
collectionMethodofCaptureRedirect.
- Sessions are redirect-based if they are either A) Hosted Provider Sessions or B) Direct Provider Sessions with a
- Success Parameters:
sessionId,redirectToken, andpostRedirectAction- Check
sessionIdagainst the Session you actually created - Send
redirectTokento Trinsic when callingGetSessionResults postRedirectActionis always eitherfetchorpoll- If
fetch, results are available immediately. - If
poll, results are not yet available. PollGetSessionResults.
- If
- Failure Parameters:
sessionIdandredirectReasonredirectReasoncontains a reason the user was redirected backSessionFailedmeans the session failed at some point during the user's interaction with Trinsic or the Provider.- Call Trinsic's API to fetch the Session and inspect its error code for further information.
- See below for other possible values
Redirect Scenarios
There are three general scenarios in which a user will be redirected back to your application:
1) On Success or Pending
When a Session is successful, the user is redirected back with a set of Success Parameters.
If using Direct Provider Sessions, it is possible that the user is redirected back before a Session is finalized (e.g. because the Provider has not yet finished processing). In this case, Trinsic returns the user with a set of Success Parameters, even though the Session is incomplete. The Session must still be polled until it finalizes or until a time limit set by you is reached.
If using Hosted Provider Sessions, Trinsic performs any necessary polling using the Trinsic UI. Sessions are always complete before the user is redirected back to you in this mode.
You will always receive a redirectToken and a sessionId.
2) On Session Failure
If a user's journey ends with a Session-ending failure (a user refusing consent; a digital signature failing to validate; a Provider being unreachable; etc.) then the user is redirected back with a set of Failure Parameters.
The redirectReason for this scenario will always be SessionFailed.
3) On Non-Session-Ending Failure
If a user's journey ends in a non-Session-ending way, they will be redirected back to your application with a set of Failure Parameters.
For example: if an individual visits an expired or already-used Session launchUrl, Trinsic will immediately redirect them back to your redirectUrl. However, the Session itself will not necessarily fail.
The redirectReason for this scenario will never be SessionFailed.
Redirect Parameters
When a user is redirected back to your application, Trinsic will append either a set of Success Parameters or Failure Parameters to the redirectUrl configured during Session creation.
Success / Pending Parameters
These parameters are appended to your Redirect URL when a Session is successful, as well as for Direct Provider Sessions which require post-redirect polling. Every parameter is always present.
| Parameter | Description |
|---|---|
sessionId | The ID of the relevant Session, for which the user is being redirected. ⚠️Check this parameter against your database to ensure that it maps to the Session you actually created. |
redirectToken | A token, minted by Trinsic, which asserts that the user which is hitting your Redirect URL was actually redirected to you by Trinsic. Send this with the GetSessionResults call. |
postRedirectAction | Value will always be fetch or poll. If using Hosted Provider Sessions, the value of this parameter is always fetch.If poll, the Session's results are not yet available. You should poll GetSessionResults until and if the Session finalizes.If fetch, the Session's results are immediately available and no polling is necessary. |
Failure Parameters
These parameters are appended to your Redirect URL for all failure conditions (i.e., when a user is not being redirected for a Success reason).
| Parameter | Description |
|---|---|
sessionId | The ID of the relevant Session, for which the user is being redirected. |
redirectReason | The reason the user is being redirected back to your application. |
Handling redirectToken
redirectTokenThe redirectToken parameter, appended to your Redirect URL on Session success, helps secure the redirect chain against phishing attacks. It's an encrypted, opaque string that only Trinsic can create or decrypt.
Supply the redirectToken when calling GetSessionResults. If valid, the Session's results will unlock, and the redirectToken will not be required for future calls to GetSessionResults for that Session.
Redirect Reasons
Below are all the possible values of the redirectReason parameter. New values may be added to this list over time; unknown values should be handled by your integration (e.g., by defaulting to SessionFailed).
redirectReason Value | Description |
|---|---|
SessionFailed | The Session is in the Failed state and has an error code.This is the most common reason. |
LaunchFailed | Launching the user to the Provider failed. This typically occurs if the Provider's services are unreachable or unresponsive. |
LaunchUrlExhausted | The launchUrl was visited after it had already been used to launch the Session. |
LaunchUrlExpired | The launchUrl was visited after it was no longer usable (e.g. due to Session expiration or termination) |
InternalError | An internal error occurred. |
Binding User Sessions
redirectToken helps secure the redirect chain at the point where the user is coming back from Trinsic to your application. However, it could be the case (such as during a phishing attack) that the individual who requests a launchUrl to verify themselves while on your application is a different person than the individual who actually visits the launchUrl and performs the verification with Trinsic.
The degree to which these hypothetical attacks can be mitigated depends on a mixture of the Providers involved, your security posture, and the nature of your product.
Ideally, you should re-authenticate the user when they return to your application, requiring them to log in if they do not still have their session cookies. Ensure that the user who is visiting the Redirect URL for a Session is the same as the user who requested the Session's creation.
If your application does not have user authentication or long-term accounts, another possible mitigation is to recontextualize the user with the nature of the verification, and have them positively assert that they wish to share their identity data for the stated purpose.
Updated 17 days ago
