Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
auth
✓ github.com/abbot/go-http-auth
Sets up HTTP Basic authentication for a web server.
package main
import (
"net/http"
"github.com/abbot/go-http-auth"
)
func Secret(user, realm string) string {
if user == "admin" {
return "$1$da$3cGG9D5Mh2xxv3e7CwPJp/"
}
return ""
}
func main() {
authenticator := auth.NewBasicAuthenticator("example.com", Secret)
http.HandleFunc("/", authenticator.Wrap(func(w http.ResponseWriter, r *auth.AuthenticatedRequest) {
w.Write([]byte("Hello, " + r.Username))
}))
http.ListenAndServe(":8080", nil)
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
0.4.0latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.