From the course: Secure Coding in Go

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Solution: Secure project

Solution: Secure project - Go Tutorial

From the course: Secure Coding in Go

Solution: Secure project

(upbeat music) - [Instructor] So here is my solution. I wrote a handler function called check authentication. These handler function check if you're under the prefix of /debug, it will look for the basic authentication and make sure it's valid. If it's not, it is going to return status of unauthorized. If you pass that meaning either the login is okay, or it's not on the /debug, it is going to call the DefaultServerMux with the original ResponseWriter and Request. In main(), we are going to convert the HandlerFunc to a handler, and we're going to pass it as the second parameter to ListenAndServe. Meaning every request is going to be directed through our checkAuth function. Let's have a look, So Run, Run Without Debugging and let's view the Debug Console and now we can check it out. So, curl -i http://localhost:8080/debug/vars and we get unauthorized. So let's pass the security information. So katie and the…

Contents