Secure, performant and effortless authentication.
Big WIP.
How will it look like?
func main() {
// Create a configuration.
config := hero.Config{
MasterKey: "secret",
Mailer: "smtp://user:secret@localhost:1025",
DatabaseDriver: "sqlite",
DatabaseLocation: "test.db",
}
// Initialize it.
auth, err := hero.Init(config)
if err != nil {
fmt.Println("failed to initialize hero: ", err)
}
// Create a router.
router := chi.NewRouter()
// Mount the route group.
router.Mount("/auth", auth)
// Protect your routes!
router.Group(func(r chi.Router) {
r.Use(hero.Protect)
r.Get("/data", handleGetData)
r.Post("/data", handlePostData)
})
// router.Get("/public")
// ...
// Serving.
http.ListenAndServe(":8080", router)
}