SWIFT Security SDK Specification
SWIFT Security SDK Specification
6 January 2022
Table of Contents
Introduction ............................................................................................................................................... 3
SWIFT API offering .................................................................................................................................... 3
Installing the Postman Collection........................................................................................................ 5
JSON Web Token and Structure .......................................................................................................... 6
Header ..................................................................................................................................................... 6
Payload .................................................................................................................................................... 6
Signature ................................................................................................................................................. 7
Configuring the Postman Collection .................................................................................................. 8
Establishing a Secure Session with Postman................................................................................ 10
Creating a JWT signed with SWIFTNet PKI for Non-Repudiation ............................................. 12
Postman Runtime Requests and Responses ................................................................................. 13
Request ‘Get Token’ Analysis in Postman ....................................................................................... 13
Response ‘Get Token’ Analysis in Postman .................................................................................... 14
Request NR Signature Analysis in Postman.................................................................................... 14
Calling GPI API Samples ...................................................................................................................... 14
Calling SWIFT Messaging API ............................................................................................................ 16
JWT Debugger Runtime Requests .................................................................................................... 18
Request ‘Get Token’ Assertion in JWT debugger ........................................................................... 18
Request NR Signature in JWT debugger (X-SWIFT-Signature)................................................... 20
Legal Notices........................................................................................................................................... 22
SWIFT Security SDK Specification
Introduction
SWIFT API offering
To start, we will briefly summarize the four major offerings for SWIFT API connectivity.
1.) SWIFT Microgateway: provides simplified access to SWIFT API services. Known as an API call
concentrator, it enables configuration, management, and monitoring of multiple API
consuming applications. This document will not go into detail about SWIFT Microgateway;
however, more information is available on the Developer Portal: SWIFT Developer Portal |
SWIFT Microgateway
2.) SWIFT Software Development Kit (SDK): Java-based library that hides much of lower-level
application plumbing, including authentication, authorisation, signing and error handling. It
provides a Java-based library to facilitate integration of API-consuming applications. This
document will not go into detail about SWIFT SDK; however, more information is available
on the Developer Portal: SWIFT Developer Portal | SWIFT SDK
3.) SWIFT Security SDK: another Java-based library which is an underlying component of SWIFT
Microgateway and SWIFT SDK offerings. The component is responsible for secure API
session management, non-repudiation and Role-Based Access Control based on SWIFTNet
PKI. This document includes samples that illustrate the order and sequence of steps to
consume APIs. The samples will be the focus of this document. You can find the package on
the Developer Portal: SWIFT Developer Portal | SWIFT SDK
4.) Postman collection: packaged with SWIFT Security SDK containing runnable samples which
enable calls to SWIFT APIs using SWIFTNet PKI channel (software) certificates. It provides a
reference implementation which demonstrates application-level signing, optional non-
repudiation and implementation of oAuth 2.0 session establishment according to RFC 7523.
Understanding the Postman collection provided, similar logic and sequence can be used to
build an interface to SWIFT APIs in any other language or script. This document will explain
the SWIFT Security Specification showcased in the Postman collection.
SWIFT Security SDK Specification
Overview
We will be looking at the flows necessary for an API client to establish a secure session with the SWIFT
API Gateway and then make API calls. The diagram below highlights the major steps.
The postman collection will create a JSON Web Token claim with a signed assertion and retrieve an
oAuth token from the authorization server (1). This uses the configured software certificate issued by
SWIFT to authenticate and authorize the API client (2). Then the session token will accompany any
further calls to the API endpoints available on the SWIFT API Gateway.
SWIFT Security SDK Specification
Note the directories for ‘sample’, ‘session’ and ‘sandbox’. Also note that the Authorisation Type is set to
Bearer Token for authorisation. This is the method used to acquire an access_token to manage a secure
session with the SWIFT API Gateway.
SWIFT Security SDK Specification
Payload
The payload contains claims which are the pieces of information that comprise the JWT. There is
an example here with a few brief explanations of the claims that are dynamically handled by the
Postman collection. Those without explanation are covered in more detail in the following
sections, where they require some custom configuration.
SWIFT Security SDK Specification
Signature
The Header and Payload values are concatenated and Base46-encoded. A signature is calculated
using the privateKey specified and described in the following section. The publicCertificate is
included in the x5c claim in the header of the JWT. This gives the Service Provider everything
necessary to verify the authenticity and integrity of each JWT API request.
For more information about obtaining the privateKey and publicCertificate, see the SWIFT
Microgateway Getting Started Guide in the sections about keystore management and software
certificate creation, or the Developer Portal.
SWIFT Security SDK Specification
The base URL is populated with the address of the API Gateway. This could be in a sandbox
environment, in the Live environment or in a test environment (as shown above).
The session_scope is a mechanism in OAuth 2.0 to limit an application's access to a user's account up to
the granularity of API Services and RBAC roles. A possible value for scope may be ‘swift.apitracker’ or
‘swift.apitracker/FullViewer’.
The consumerKey and consumerSecret are application identifiers used for authentication. They are
available on the SWIFT Developer Portal once an application is created. Creating your own application
enables you to generate a consumerKey and consumerSecret to access the API products in the sandbox
and production environments. Applications can be promoted to other environments. Multiple
applications can be configured for different environments.
The aud is the name for the JSON Web Token (JWT) claim that identifies the recipient of the
authorisation tokens. In this case, it is a URL on the SWIFT API Gateway that will validate the tokens
when establishing a secure session.
The sub identifies the subject of the user. Because the authentication on the API calls uses SWIFTNet PKI
certificates for signing, this value is set to the distinguished name of the certificate obtained from the
SWIFT certificate authority (O2M).
SWIFT Security SDK Specification
Security officers can use O2M to generate privateKeys and publicCertificates. Once generated, the
privateKey can be configured in the Postman collection. The publicCertificate must be present as SWIFT
maintains multiple CA certificates, and the publicCertificate specified must be the one used when
generating the privateKey. Future enhancements will use Key Management Systems hosted either
locally or in the cloud.
(Important: the fact that Postman keeps a copy of the privateKey in clear text implies that this collection
is for testing purposes and must never be used in a production environment.)
The util-lib does not require any reconfiguration. The value must remain for internal use by the Postman
collection.
In the collection, these variables are duplicated for the sandbox environment. They are configurable in
the same way as the explanations above.
SWIFT Security SDK Specification
For more information about using a correct session scope, see the SWIFT Microgateway Getting Started
Guide. The session scope is also sometimes referred to as RBAC Scope.
The grant_type and scope are used to create an assertion which is stored as a Postman variable. These
values are not needed on subsequent API calls after successful session establishment.
To test Secure Session establishment, submit a request to ‘Get Token’ in the session examples of the
Postman collection. The HTTP Response Status will be 200, and the Response Body will resemble the
following:
The access_token is returned with its type and expiry. The Response Body also contains a refresh_token
and its expiry. This token can be used as a parameter to request another access_token within the
validity of the refresh_token.
The tokens are stored in Postman variables. At any time, another API call can be done to ‘Refresh Token’
or ‘Revoke Token’. The refresh will provide another session token. The revoke will unset the token
variables, meaning that it invalidates the Client API Secure Session with the SWIFT API Gateway.
These requests are signed with RS256. The procedure on how to make the request and sign it properly is
outlined in the Postman collection. It is very similar to the following example provided in this document:
‘Creating a JWT signed with SWIFTNet PKI for Non-Repudiation’. The major difference is that the ‘Get
Token’ request creates an assertion with authorisation and scope information, which are not required
for each subsequent API call.
SWIFT Security SDK Specification
More differences on the JWT used to establish a Secure Session and those used for non-repudiation will
be highlighted in the request and response traces.
The ‘Get Token’ will have a signed assertion in the HTTP Body:
assertion: "eyJ0eXAiOiJKV1QiL……CJhbGciOiJSUzI1Ni”
The NR Signature Request will have an identifiable SWIFT signature in the HTTP Header:
X-SWIFT-Signature: “eyJ0eXAiOiJK…………V1QiLCJhbGciOiJSUzI1NiIsI”
SWIFT Security SDK Specification
The result will resemble the following, notice uetr (unique transaction reference) is part of the response:
The uetr refence can be used as a parameter to other GPI API calls for example one to ‘Get Payment
Transaction Details’ on a single transaction
Response:
SWIFT Security SDK Specification
The response returns a message_cloud_refence, which confirms that and InterAct message was
accepted by Alliance Cloud.
Legal Notices
Copyright
SWIFT © 2023. All rights reserved.
Restricted Distribution
Do not distribute this publication outside your organisation unless your
subscription or orderexpressly grants you that right, in which case ensure
you comply with any other applicable conditions.
Disclaimer
The information in this publication may change from time to time. You must
always refer to thelatest available version.
Translations
The English version of SWIFT documentation is the only official and binding version.
Trademarks
SWIFT is the trade name of S.W.I.F.T. SC. The following are registered
trademarks of SWIFT: 3SKey, Innotribe, MyStandards, Sibos, SWIFT, SWIFTNet,
SWIFT Institute, the Standards Forum logo, the SWIFT logo, SWIFT gpi with logo,
the SWIFT gpi logo, and UETR. Other product, service, or company names in this
publication are trade names, trademarks, or registered trademarks of their
respective owners.