BETA Shoulder is in beta — Findings may sometimes be wrong. Your feedback shapes what we fix next. Share feedback
Rules / Go

Gin Missing JWT Middleware

Description

API endpoints lack JWT authentication middleware protection.

What Shoulder detects

Gin application missing JWT authentication middleware

How to fix

Add JWT middleware to protect API routes.

```go
import jwt "github.com/appleboy/gin-jwt/v2"

auth, _ := jwt.New(&jwt.GinJWTMiddleware{
    Realm: "api",
    Key:   []byte(os.Getenv("JWT_SECRET")),
})
api := r.Group("/api")
api.Use(auth.MiddlewareFunc())
api.POST("/transfer", transferHandler)
```

Learn more: https://shoulder.dev/learn/go/cwe-306/jwt-middleware

Applies to

Languages

Frameworks

gin

Scan for this issue

Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=go-gin-missing-jwt .

Related rules