https://github.com/mulesoft/data-weave-jwt-library
https://github.com/mulesoft/data-weave-jwt-library
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mulesoft/data-weave-jwt-library
- Owner: mulesoft
- License: bsd-3-clause
- Created: 2022-01-06T15:17:48.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-11-14T18:45:28.000Z (over 1 year ago)
- Last Synced: 2025-12-13T04:59:22.192Z (6 months ago)
- Language: DataWeave
- Size: 110 KB
- Stars: 4
- Watchers: 117
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# DataWeave JWT Library
[](https://github.com/mulesoft/data-weave-jwt-library/actions/workflows/master_workflow.yml)
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:
```dataweave
%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:
```dataweave
%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|
}
```
> **_NOTE:_** The `input` directive does not work within Mule because inputs there are managed by Mule itself. In that case, you would be able to reference the `payload` or `vars` directly.
## Contributions Welcome
Contributions to this project can be made through Pull Requests and Issues on the
[GitHub Repository](https://github.com/mulesoft/data-weave-jwt-library).
Before creating a pull request review the following:
* [LICENSE](https://github.com/mulesoft/data-weave-jwt-library/blob/master/LICENSE.txt)
* [SECURITY](https://github.com/mulesoft/data-weave-jwt-library/blob/master/SECURITY.md)
* [CODE_OF_CONDUCT](https://github.com/mulesoft/data-weave-jwt-library/blob/master/CODE_OF_CONDUCT.md)
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.