Not too long ago I wrote about authenticating within a Node.js API using Json Web Tokens (JWT). The basis of the example is around authenticating via a username and password and receiving a JWT for every future request against the API. While that example is incredibly useful and follows best practice, it doesn’t cover the scenario where you’d like to have a two-factor authentication (2FA) option for your users. In case you’re unfamiliar, 2FA is a second layer of protection for accounts made possible by a time-based token generated by a shared secret key.
We’re going to see how to add a two-factor authentication option to our Node.js API while continuing to use Json Web Tokens.
Read MoreOne of the highlights of the Go programming language is its ability to handle concurrency with minimal effort using what are called goroutines and channels. The beauty here versus other programming languages is that you don’t end up in a callback mess or locking hell. In fact, you can even create far more goroutines in Go than you can in a language such as Java with the same hardware.
We’re going to see an example where we have an application that starts several worker goroutines and shares a channel for accessing data.
Read MoreIf you’ve been working towards containerizing your web applications like I have, you might be at a point where you’re ready to start clustering your containers. Previously I had written about creating a container cluster with Docker Swarm and using NGINX as a reverse proxy for a few containers. The catch here is that neither of these previous tutorials were meant to work together. In the previous example we were using a reverse proxy for containers on a single server. While Docker Swarm offers it’s own load balancing, you’ll find it makes sense to have NGINX as well because not every container can run on the host as port 80.
We’re going to see how to create two service containers that are replicated across several nodes. These services will be a simple Apache and NGINX web applications. Then we’re going to throw an NGINX reverse proxy into the mix that keeps track of the upstream nodes for its own load balancing.
Read MoreI recently invested in yet another Raspberry Pi, this time the new Raspberry Pi Zero W, which has wireless and bluetooth. I also made a leap and bought the camera module with it because the new official case by Raspberry Pi has a camera attachment. Probably the most popular development technology for Raspberry Pi is Python, but I am not a fan at all. Instead, I’ve been doing a lot of Go development and figured that would be my best bet when it comes to developing a camera application for the Raspberry Pi. The problem with this is that if I were to compile a Go application on the Raspberry Pi Zero itself, it would probably take ten years (I joke).
Cross compiling is a thing and we’re going to see how to do this via a different operating system and architecture, yet have it be compatible on the Raspberry Pi.
Read MoreWhen developing an application with the Go programming language, you might find yourself needing to save data locally. If you’ve been keeping up you’ll remember that I’ve written about storing data remotely with Golang in a Couchbase NoSQL database, but never anything locally. Probably the easiest way to store data locally is with a SQLite database as it is a solid technology that has been around for a while.
We’re going to see how to use a SQLite database in our Golang application to read and write local data.
Read MoreNot too long ago I wrote about containerizing a bunch of web applications and putting them behind an NGINX reverse proxy. This is because I’ve been exploring the possibility of taking all my personal applications and turning them into Docker containers for easy maintenance and portability. I currently use Digital Ocean and if I had to guess, I’m going to be using it for a lot longer as it is a great service. So what does it take to get containerized applications on Digital Ocean or any other remote machine?
We’re going to take a look at creating and defining a remote machine in Docker and deploying containers on it.
Read MoreI personally think that Golang is a great development technology and one of the better that I’ve used. However, there is no such thing as a perfect development technology. That said, there are things to be desired in Golang out of the box. For example, I always find myself wishing that I could use type assertions to decode map values into a defined Go data structure.
Using a nifty package, this actually becomes a possibility and without much extra effort. We’re going to see how to take a map and convert it into a custom structure.
Read More