My Community
YourCause®
Impact Edge™
All-Star Lounge
Member Lounge (Just for Fun)
Community News
Community Manager
Groups
Browse Products
Members
Community All-Stars
Monthly Challenges
Member Search
Jobs Board
Help
Using the Blackbaud Community
Blackbaud Support
Knowledgebase
Blackbaud University
Discussions
Categories
Groups
Home
SKY Developer
SKY Developer General Discussions
Add-in Single Sign-on with a Node.js backend
Gary Chamberlain
I'm following the instructions at
https://developer.blackbaud.com/skyapi/docs/addins/concepts/addin-sso
and they seem pretty straight-forward. However, I got to the point where I need to validate the UIT. The docs only give a C# example but we are using Node.
Do I need to use a third-party openId client?
Can someone point me to example code?
Find more posts tagged with
Comments
Gary Chamberlain
I've figured out how to do it myself and will list the steps here in case someone else is looking for this.
Client
Follow the Blackbaud's SSO instructions and get the Id Token by calling client.getUserIdentityToken()
POST to your Node server and pass the token in a header
Node (Express app middleware)
npm install jsonwebtoken --save
Get the PEM cert
await fetch('
https://oauth2.sky.blackbaud.com/.well-known/openid-configuration
')
Read the jwks_uri value
await fetch(jwks_uri)
Read the JWK set (array of keys)
Parse the token header
Split the token on a persiod
Base64 decode the first element and JSON parse
Extract the x5t and kid values
Loop through each key and take the first one that matches either the x5t or kid
Take the first element in the x5c as the cert
Prepend '-----BEGIN CERTIFICATE-----' to the cert
Append ''-----END CERTIFICATE-----" to the cert
Build an options POJO with expected algorithms, audience and issuer values.
Call jwt.verify(token, cert, options, function(err, decoded) { ... });
In the callback, decoded is the payload. Handle the error or call next()
Some links:
https://www.npmjs.com/package/jsonwebtoken
https://redthunder.blog/2017/06/08/jwts-jwks-kids-x5ts-oh-my/
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Help
Best Of