Super practical! This guide breaks down authentication and authorization in Go with such clarity—it’s a must-read for developers working with secure web applications. The examples and flow make implementation feel less intimidating, especially for those newer to backend systems. It’s great to see content that empowers developers to build safely and efficiently. Companies like GAOTek Inc. and GAO RFID Inc. embody this same practical innovation in their solutions—always pushing tech forward in meaningful ways.
thanks for writing this article... i have a question ... where and how to use IsAuthorized() method ?(in best practice)
getting error while applying this code
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
2024/01/26 15:10:24 /home/shabaz/go-auth/models/index.go:27
[error] failed to initialize database, got error failed to connect to host=localhost user=postgres database=test: dial error (dial tcp 127.0.0.1:5435: connect: connection refused)
panic: failed to connect to host=localhost user=postgres database=test: dial error (dial tcp 127.0.0.1:5435: connect: connection refused)
goroutine 1 [running]: go-auth/models.InitDB({{0xc000138188, 0x9}, {0xc000500c58, 0x4}, {0xc000500c18, 0x8}, {0xc0001381a4, 0x8}, {0xc000500bf8, 0x4}, ...}) /home/shabaz/go-auth/models/index.go:29 +0x32c main.main() /home/shabaz/go-auth/main.go:34 +0x21a exit status 2
This tutorial has glaring, obvious security issues, namely:
Long story short, for many applications, JWT is actually a terrible option - complex to implement properly, complex to scale, and still requires user resolution/lookup when additional info (like acls, contact info, etc) is required.