Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
satishbabariya authored Apr 10, 2022
1 parent bd9a322 commit 13c4ee2
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# go-fiber-auth0-middleware
Auth0 middleware for Go Fiber

```go
package main

import (
"log"
"net/http"
"os"

"github.com/auth0/go-jwt-middleware/v2/validator"
"github.com/gofiber/fiber/v2"
auth0 "github.com/satishbabariya/go-fiber-auth0-middleware"
)

func main() {
app := fiber.New()

app.Use(auth0.New(auth0.Config{
Issuer: os.Getenv("AUTH0_ISSUER"),
Audience: []string{os.Getenv("AUTH0_AUDIENCE")},
ErrorHandler: func(c *fiber.Ctx, err error) error {
return fiber.NewError(http.StatusUnauthorized, err.Error())
},
}))

app.Get("/", func(c *fiber.Ctx) error {
claims := c.Locals("claims").(*validator.ValidatedClaims)
return c.JSON(claims)
})

log.Fatal(app.Listen(":1203"))
}

```

0 comments on commit 13c4ee2

Please sign in to comment.