mirror of https://github.com/gofiber/fiber.git
|
||
---|---|---|
.. | ||
README.md | ||
keyauth.go | ||
keyauth_test.go |
README.md
Key Authentication
Special thanks to József Sallai & Ray Mayemir
Install
go get -u github.com/gofiber/fiber/v3
go get -u github.com/gofiber/keyauth/v2
Example
package main
import (
"github.com/gofiber/fiber/v3"
"github.com/gofiber/keyauth/v2"
)
func main() {
app := fiber.New()
app.Use(keyauth.New(keyauth.Config{
KeyLookup: "cookie:access_token",
ContextKey: "my_token",
}))
app.Get("/", func(c fiber.Ctx) error {
token, _ := c.Locals("my_token").(string)
return c.SendString(token)
})
app.Listen(":3000")
}
Test
curl -v --cookie "access_token=hello_world" http://localhost:3000