February 2020
Intermediate to advanced
404 pages
8h 42m
English
Let's build a secure API that gives access to clients only after logging in. In the process, we will define three endpoints:
/healthcheck is the data API, but it first has to log in using the /login endpoint. Our API should reject all unauthenticated requests. Create a project directory called simpleAuth, like this:
mkdir -p $GOPATH/src/github.com/git-user/chapter14/simpleAuthtouch $GOPATH/src/github.com/git-user/chapter14/simpleAuth/main.go
In the program, we can see how to enable session-based authentication to API endpoints using the gorilla/ sessions package. Follow these steps:
Read now
Unlock full access