Skip to content

Rhosys services use JWTs for authorization to your webhooks, here is an example on how to verify them.

License

Notifications You must be signed in to change notification settings

Standup-and-Prosper/TokenVerification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

External token verification for webhooks

Standup & Prosper use JWTs for authorization to your webhooks, here is an example on how to verify them.

This example applies to Prosper which allows for custom webhooks:

const axios = require('axios');
const jwtManager = require('jsonwebtoken');
const jwkConverter = require('jwk-to-pem');

async validateToken(authorizationHeader) {
  let token = authorizationHeader.split(' ')[1];
  let unverifiedToken = jwtManager.decode(token, { complete: true });
  let response = await axios.get('https://api.standup-and-prosper.com/.well-known/jwks');
  let jwk = response.data.keys.find(key => key.kid === unverifiedToken.header.kid);
  let key = jwkConverter(jwk);
  let identity = await jwtManager.verify(token, key, { algorithms: ['RS256'], audience: 'TARGET_SERVICE_URL' });
}

The TARGET_SERVICE_URL should match the value specified in the webhook.

About

Rhosys services use JWTs for authorization to your webhooks, here is an example on how to verify them.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published