Sat, Jan 29, 2022
So after a long time I thought I’d take another look at Go and whilst struggling to think what little app should I write to get back in the saddle with, the legend that is Christos Matskas mentioned he wanted to try using a Go api against Azure AD for authentication. So I fired up GoLand and got to work writing an API.
Setting up Azure AD
- You will need to create an Azure Directory in your account which is pretty straightforward. The only user in the directory will be you.
- Inside the directory you will then need to register an application, again pretty straightforward.
- Next under Certificates & Secrets, you will need to create a secret, this will be used as part of the auth handshake. Give it a name and Azure will create the value. Take a copy of it ready for your API
- On the Overview page take a copy of the Application (client) ID
- On the Overview page take a copy of the Directory (tenant) ID
- Go to Expose An API
- Click Add a scope
- Create something like “allow_user” and choose Admins and users
- Go to API Permissions and click Add a Permission
- Select My APIs and select your application/API
- Tick the scope you just created
- Now here’s a weird thing, if you don’t see your scope, try going to another tab in your browser or refresh you Azure Portal page. Something is broken IMO in that it takes time or needs refreshing for it to show up
- Click Manifest on the left hand side
- Change
accessTokenAcceptedVersion
to 2
and click Save
This page will list and describe common words and terms that you might come across as a software developer which you can refer to at a later date knowing there’s a place to go to when someone uses a term that you don’t know, are unsure of or can’t remember
Terms
Cohesion -
Composition Root -
Coupling -
Cross-Cutting -
KPI -
Lift & Shift -
OKR -
Orthogonal -
Projection -
Shift Left -
I was made aware of OpenTelemetry a while ago by a blog series Jimmy Bogard and put it in my favourites to read at a later date. Of course I didn’t really get back to it in depth and gave it a quick scan at the time although it is a well written in depth blog series so I suggest you do check it out. A while later I saw a blog post by Rehan Saeed which gives an introduction on what OpenTelemetry is and how it works and the concepts behind it and is definitely worth a read. At the same time I saw a YouTube video by Elton Stoneman that whilst more aimed at using tracing using Kubernetes he demonstrates a .NET app running and the tracing details appear in Jaeger
I recently wrote a single case discriminated union which is what I wanted but was also confused why it didn’t behave like a type alias and then learnt that these two are different things.
type CustomerId = int
type CustomerId = CustomerId of int
I was aware of both syntaxes and from a quick scan they look the same however they behave differently and rightly so. As I travel the F# road there is more emphasis on creating types for your functions.
After discussing something with Ian Russell he suggested I take some time to read through another fine blog post he has written and understand F# applicatives and custom operators. I found myself in familiar territory when reading F# blog posts and it’s something similar to the five stages of grief. Nod, Nod, I understand what’s going on, Umm, WTF is going on. As Ian did in his Intro to F# series he sets out a simple domain problem and goes about how to address it. We want to return a ValidatedUser
from a function but if the user fails validation we return a list of validation errors.
The code in the blog post was pretty self explanatory until, it wasn’t, which I have pasted below:
This blog post aims to explain map/bind in F# in a code only example. It took me a while so I’m writing it up here so I can come back to it and re-read it for the 100th time most likely!
Following on from Joe’s post I thought I’d see how one would do this in F# and Giraffe because why not? Turns out its quite simple. First, create a features.json
file: