Member-only story
Basic Authentication with Go.
Authenticate a User with the browser’s built-in login mechanisms.
Basic Authentication is a scheme in which “the user agent must authenticate itself with a user-ID and a password for each realm.” A realm would be a section of your web server and the user agent could be cURL or your web browser.
Basic Authentication is not suitable for public-facing applications due to security concerns. However, it remains a practical choice for intra-backend communication within tightly controlled networks.
If you’re also designing a Wifi router, accessed through a web server, it would make for a great authentication method.
I like Basic Authentication because I can skip writing an authentication system and rely on HTTP headers to tell the browser how I expect authentication to be handled. In this post, I want to write a Go web server that uses Basic Authentication as a method for granting access to a protected resource.
How it Works
From my experience, Basic Authentication starts with the client sending a request with a header named Authorization. This header holds a string that combines the user’s username and password, separated by a colon (:), encoded in Base64.










