Skip to content

Commit

Permalink
Log JWT details
Browse files Browse the repository at this point in the history
  • Loading branch information
bumi committed Apr 6, 2024
1 parent 8704dd1 commit a239f23
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/tokens/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/golang-jwt/jwt"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/labstack/gommon/log"
)

type jwtCustomClaims struct {
Expand Down Expand Up @@ -42,6 +43,15 @@ func Middleware(secret []byte) echo.MiddlewareFunc {
config.SuccessHandler = func(c echo.Context) {
token := c.Get("UserJwt").(*jwt.Token)
claims := token.Claims.(*jwtCustomClaims)
c.Logger().Warnj(log.JSON{
"msg": "JWT details",
"UserID": claims.ID,
"MaxSendVolume": claims.MaxSendVolume,
"MaxSendAmount": claims.MaxSendAmount,
"MaxReceiveVolume": claims.MaxReceiveVolume,
"MaxReceiveAmount": claims.MaxReceiveAmount,
"MaxAccountBalance": claims.MaxAccountBalance,
})
c.Set("UserID", claims.ID)
c.Set("MaxSendVolume", claims.MaxSendVolume)
c.Set("MaxSendAmount", claims.MaxSendAmount)
Expand Down

0 comments on commit a239f23

Please sign in to comment.