Home

Awesome

fido2-postman-clients

This is a free, basic set of POSTMAN assets that demonstrate in Javascript how to build the data structures used for FIDO2 registration (aka attestation) and login (aka assertion) ceremonies described in the WebAuthn specification, and how to interact with either an IBM Security Verify SaaS service for FIDO2 operations, or a demonstration site I manage for testing FIDO2 operations that is built using IBM Security Verify Access. It would be trivial to modify the collection to test against other server implementations.

The assets make use of several other open source libraries for crypto and data encoding/decoding functions, and those libraries and their associated licenses are embedded in the source code files (in particular see globals/fidotools.js) in this repository so that everything you need to use the collection can be found in one place. I'd like to acknowledge and thank the authors of those libraries, as without them building this asset would have been much more work. These libraries are:

The example software-based authenticator built into this POSTMAN collection supports only EC256 keypairs, and it is possible to demonstrate fido-u2f, packed, and self attestation formats although because this is a software-based attestation with private keys included in the source you cannot really ever trust it. There is no attempt in the client code in POSTMAN to honour or validate the server options for attestation and assertion regarding permitted algorithms, rpId, user verification, etc. Please keep in mind that this is not a full-blooded client. The goal of this collection is to demonstrate how to construct well-formed attestation and assertion payloads and to test the happy path against a server implementation. It should be a useful starting point for anyone writing their own thick client or native mobile application to understand how to construct FIDO2 messages.

Clone the repository to you local file system to follow the instructions below for use.

Using the POSTMAN collections

As mentioned earlier, the POSTMAN collection can be demonstrated against either an IBM Security Verify SaaS tenant or the hosted testing site (not guaranteed to be always running!) built on top of IBM Security Verify Access. This section will take you through the configuration and usage of POSTMAN for each of these scenarios.

Common globals setup

This section is applicable regardless of whether or not you intend to use the API collection for IBM Security Verify SaaS, or the collection for the demonstration site built on IBM Security Verify Access.

Install POSTMAN (I used version 8.0.3 in preparing this documentation).

Import two global variables that contain Javascript helper functions called from within the POSTMAN collections. This respository contains both the original JS files for you to peruse, and a pre-bundled copy of them within a single importable JSON file that POSTMAN can ingest in one go.

From the the main POSTMAN window, click Import, then select and import the globals/FIDO.postman_globals.json file from this repository as shown here:

Import globals

For later reference, the fidotools global contains a copy of the contents of the globals/fidotools.js file from this repository and the fidoutils global contains a copy of the contents of the globals/fidoutils.js file from this repository. The differentiation between these files is as follows:

Using the IBM Security Verify collection

This section will demonstrate how to use the FIDO2 API collection against an IBM Security Verify SaaS tenant.

If you do not already have an IBM Security Verify tenant, you can find instructions to obtain a free trial here. Make sure you can login to your tenant, and for the purposes of this exercise navigate starting from the Application Launchpad (not the admin view) to the user's Profiles & settings -> Security page (typically the URL for this page is of the form):

https://<your_tenant>.verify.ibm.com/usc/settings/security

For the purposes of this document, I am going to use the tenant: fidodemo.verify.ibm.com

Next we are going to "lift" an access token from the browser for your user. This will be used in the POSTMAN environment to make API calls as your user. There are many other ways to legitimately obtain a user access token in IBM Security Verify, but for the purposes of this walk-through, this quick-and-dirty approach works fine. If you are obtaining an access token via another method, be sure you are getting an access token for a user, and not one for an administrative API Client. For example you could be using the OAuth 2.0 ROPC flow, or the OpenID Connect Authorization Code flow, however you would not be using the OAuth 2.0 Client Credentials flow.

In the browser when displaying the security settings page, open the Network inspector in developer tools and refresh the page. Pick one of the fetch-based APIs that is called when loading this page, look at the Request Headers, and extract the access token that is being used in the Authorization header. In my example below this access token value is jftdBqgFmFDZ2RfJ6n4rnH8hQUcXZGTn3ZHO0iYl. This will be used in the next steps.

Lift the access token from the browser

Next, install the POSTMAN environment and collection files for IBM Security Verify. These can be imported in an identical manner to the globals. Find the files at:

Next update the starting environment variables to match your tenant and user. See the diagram below for how to perform the edit.

The following variables should be updated:

Don't forget to save your changes!

Update the IBM Security Verify environment variables

Set the current environment to IBM Security Verify (top right of POSTMAN window), and then open the WhoAmI API in the collection and perform a request using the Send button:

IBM Security Verify - WhoAmI

You should see a 200 OK successful response with user information in the response body.

You can now exercise each API in the order shown in the collection from top to bottom. Study the Pre-request and Tests scripts (where they are present in APIs to see how calls are made to the functions declared in the fidoutils global. Once a credential is successfully created with the PostAttestationResult API, there is no need to run the FetchAttestationOptions/PostAttestationResult APIs again - you can just run the FetchAssertionoptions/PostAssertionResult pair as many times as you like.

If an API fails, the most likely reason is an expired access token. To fix this, login to the IBM Security Verify SaaS portal and re-retrieve an access token and update your environment variable as described earlier in this section.

Each API and a brief description of it's purpose is as follows:

Optional: Installing and using the metadata

The metadata subdirectory in this repository contains FIDO metadata statements that can be installed on your IBM Security Verify tenant for verifying the attestation statements. You can configure them into the IBM Security Verify FIDO2 relying party definition using the administration console as shown:

IBM Security Verify FIDO2 Metadata

Viewing created credentials in the user self care portal

From the Application Launchpad view in the IBM Security Verify portal, navigate back to your user's Profiles & settings -> Security page. You should now see the credential registered from POSTMAN, and if metadata has been uploaded you can expand the registration and see the description and icon from the matching metadata file:

IBM Security Verify FIDO2 Registration

Using the IBM Security Verify Access collection against the fidointerop demonstration site

This section will demonstrate how to use the FIDO2 API collection against a demonstration site I manage for testing FIDO2 operations that is built using IBM Security Verify Access.

Many of the instructions are similar to those for IBM Security Verify SaaS - the main difference is in how you obtain your access token, and the fact that the API endpoints are statically defined because the hosted demonstration site has an establised configuration. There is also a slight difference in how user information is shared with the server in the API calls themselves.

First let's get your access token. This can be retrieved from the demonstration site itself, in the Account Settings page. Access this page, login if needed, and retrieve your access token. You will need an IBM ID to login to this site - this can be easily self-created if you do not already have one. In the example below my access token is: F6eFOqSEuLqexnJanj8a6RY6cSgc2A.

FIDOInterop access token

Next, install the POSTMAN environment and collection files for IBM Security Verify Acess. These can be imported in an identical manner to the globals. Find the files at:

Next update the access_token environment variable to match your user. See the diagram below for how to perform the edit. This should be the only required edit although you can eyeball the remaining variables to confirm their values.

FIDOInterop environment

Don't forget to save your changes!

Set the current environment to FIDOInterop (top right of POSTMAN window), and then open the WhoAmI API in the collection and perform a request using the Send button:

FIDOInterop - WhoAmI

You should see a 200 OK successful response with user information in the response body.

You can now exercise each API in the order shown in the collection from top to bottom. Study the Pre-request and Tests scripts (where they are present in APIs to see how calls are made to the functions declared in the fidoutils global. Once a credential is successfully created with the PostAttestationResult API, there is no need to run the FetchAttestationOptions/PostAttestationResult APIs again - you can just run the FetchAssertionoptions/PostAssertionResult pair as many times as you like.

Each API has the same general purpose and description as those shown earlier for IBM Security Verfy SaaS. Please read those descriptions for a detailed explanation of what each API does.

Viewing created credentials in the demonstration site

The FIDO2 Registrations page of the demonstration site can be used to view FIDO2 registered credentials. You should now see the credential registered from POSTMAN. As I have already uploaded metadata to the demonstration site, you should noticed that the registration includes a description and icon from the matching metadata file:

FIDOInterop FIDO2 Registration

By pressing the Details button, you can see expanded details of the registration, including the COSE format of the credential public key. As an exercise, try using the POSTMAN console to capture an assertion flow, and verify the message payload using the COSE public key using the FIDO2 Viewer utility that I have also open-sourced.