DataWeave JWT Library icon

DataWeave JWT Library

(2 reviews)
JSON Web Token for DataWeave

home

DataWeave JWT Library

This library provides functionality to create signed JSON Web Tokens directly on DataWeave with RSA and HMAC signatures.

Overview

This is a simple example using an HMAC signature:

%dw 2.0
import jwt::HMAC
output application/json
---
HMAC::JWT({
        "firstName": "Michael",
        "lastName": "Jones"
    }, "d4t4w34v3!")

And this is a more complex example, where the key is an input to the transformation:

%dw 2.0
import * from jwt::RSA

output application/json
input key application/json
---
{
    token: JWT(
        {
            iss: "some@email.com",
            aud: 'https://oauth2.googleapis.com/token',
            scope: 'https://www.googleapis.com/auth/drive.readonly',
            iat: now() as Number { unit: 'seconds' },
            exp: (now() + |PT3600S|) as Number { unit: 'seconds' }
        },
        key
    ),
    expiration: now() + |PT3550S|
}

Contributions Welcome

Contributions to this project can be made through Pull Requests and Issues on the
GitHub Repository.

Before creating a pull request review the following:

When you submit your pull request, you are asked to sign a contributor license agreement (CLA) if we don't have one on file for you.


DataWeave Version

This library requires DataWeave version 2.4 or higher.

Modules

NameDescription
CommonThis module provides helper functions to create signed JSON Web Tokens.
HMACThis module provides functionality to create signed JSON Web Tokens using HMAC.
RSAThis module provides functionality to create signed JSON Web Tokens using RSA signatures.


Reviews

TypeDataWeave Library
OrganizationMuleSoft
Published by
MuleSoft Organization
Published onMar 23, 2022
Asset overview

Asset versions for 1.0.x

Asset versions
VersionActions
1.0.0