Featured

Verify Signed JWT using JWK and Node JS

Not sure why, but this took me some head scratching and research. I am sure someone right now will be screaming out: “thats simple”!

The scenario:

Signature validation required for an OAuth2 JWT token (access_token or OpenId token).

The setup:

I am using IdentityServer4 as the Security Token Service (STS).

The STS has a well-known configuration URL at: http://host:port/.well-known/openid-configuration/

Note: Your STS setup may have this URL at another location. Check the documentation.

The jwks url contains a json document. The json document lists an array of json web keys (jwk). The jwk’s describe the cryptography used to sign and/or encrypt tokens.

The jwk may also contain a certificate used to sign and/or encrypt the tokens and/or various other fields.

The ‘use’ field within a jwk gives the appropriate use of the key. In the case of signature verification, the ‘use’ field will have a value of ‘sig’.

I have done a very bare minimum walk through using node for validating an access_token using the keys supplied as part of the jwks URL.

See the code here.

Advertisements
Featured

DotNet Auto Run Tests in Rider (Jetbrains)

I have been trying out the Jetbrains Rider product – found here.

I wanted to automatically run tests when files had been saved. It took me a little bit to get this up and going (getting the right combination and setup). This may save someone the effort.

Note: Done on Mac OS X

  1. Within Rider
  2. Go to Preferences -> Tools -> File Watchers
  3. Add File Watcher -> Custom
  4. Enter a name. I called mine: “UnitTestWatcher”
  5. Set the FileType and Scope. Mine are: Any, All Places. You could be more restrictive
  6. Program: /usr/local/share/dotnet/dotnet (You can find this path under the Build, Execution, Deployment – in the Preferences screen we launched the File Watchers from)
  7. Arguments: test
  8. Other options -> Working directory: /Users/[your user]/[path to the location of your csproj file containing the tests]
  9. Further down the setup, uncheck “Immediate file synchronisation” (unless you want the unit tests to run every time the file is updated – and not necessarily saved)
  10. Click -> ‘Ok’
  11. Click -> ‘Save’

Now you should be able to execute unit tests every time you save a file.

Rider may require a restart.

Featured

CORS AND API GATEWAY LAMBDA PROXY INTEGRATION

Enabling CORS

To enable CORS when creating a Lambda Proxy Integration API, you must add the following code to the LAMBDA function:

headers: {
“Access-Control-Allow-Origin” : “*” // Required for CORS support to work
}

So an example payload might be:

var response = {
statusCode: 200,
headers: {
“Access-Control-Allow-Origin” : “*” // Required for CORS support to work
},
body: JSON.stringify({
payload: “My payload”
})
};

This took me a lot searching to find! This certainly helped: servless.com/…

Training and Education

IT/software is always moving.

The software world seems to be the fastest moving critter the world has known (that comment is completely un-researched, but it feels correct). The pace shows no sign of slowing.

Is this why anyone thinking of jumping into IT/software is met with: be prepared to learn, for the rest of your life!

It seems as soon as we settle on something, a disruption is forth coming.

If you want to keep up with the bleeding edge, training is, for me, the key!

Often training will come at your own expense, your own cost and your own time. But it can be oh so worth it.