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.

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.

Vagrant with Docker Postgres

I know this is a very simple blog. However, when you are first starting out with some technology, sometimes its good to get something up and running to get a “feel” for how something works…

So, to get a basic Vagrant box up and running with Postgres hosted in a Docker container.

  1. Install Vagrant for your particular operating system
  2. Create a folder/directory, in this case I named my folder “v-docker-postgres” (horrible name?)
  3. Create a file within this folder named: Vagrantfile
  4. Inside the Vagrantfile, save the following content:Vagrant.configure(“2”) do |config|
    config.vm.box = “wesmcclure/ubuntu1404-docker”

    config.vm.define “acm-db” do |db|
    db.vm.provision “shell”, path: “./provision/db-setup.sh”
    db.vm.hostname = “acm-db”
    db.vm.network “private_network”, ip: “10.20.20.41”
    end
    end

  5. This box is provided by Wes, who has an excellent course on Vagrant on Pluralsight. Go check it out.
  6. With the above in place, create folder in “v-docker-postgres” called, “provision”
  7. Create a file within “provision” named “db-setup.sh”. This is the same name we used in the above Vagrantfile
  8. Inside the “db-setup” file save the following content:#!/usr/bin/env bash

    docker run -d \
    –name postgres \
    -p 5432:5432 \
    –restart unless-stopped \
    postgres:9.5.6-alpine

  9. With all of the above in place, you should now be able to fire this up by opening a terminal/command prompt/bash shell inside the “v-docker-postgres” folder/directory and execute the command: “vagrant up”
  10. If everything has gone well, you should now be able to connect to your database on IP: 10.20.20.40 PORT: 5432
Design a site like this with WordPress.com
Get started