mirror of
https://github.com/twofas/2fas-server.git
synced 2024-11-24 11:20:30 +01:00
limit request body for icon requests (discord requests)
This commit is contained in:
parent
1020898dd6
commit
2793b22c23
@ -174,5 +174,7 @@ func (m *IconsModule) RegisterRoutes(router *gin.Engine) {
|
||||
publicRouter.GET("/mobile/icons/collections/:collection_id", m.RoutesHandler.FindIconsCollection)
|
||||
publicRouter.GET("/mobile/icons/collections", m.RoutesHandler.FindAllIconsCollection)
|
||||
|
||||
publicRouter.POST("/mobile/icons/requests", m.RoutesHandler.CreateIconRequest)
|
||||
publicRouter.
|
||||
Use(httpsec.BodySizeLimitMiddleware(64*1000)).
|
||||
POST("/mobile/icons/requests", m.RoutesHandler.CreateIconRequest)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
"github.com/twofas/2fas-server/internal/common/logging"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -43,3 +44,11 @@ func CorrelationIdMiddleware() gin.HandlerFunc {
|
||||
c.Set(CorrelationIdKey, CorrelationId)
|
||||
}
|
||||
}
|
||||
|
||||
func BodySizeLimitMiddleware(requestBytesLimit int64) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
var w http.ResponseWriter = c.Writer
|
||||
|
||||
c.Request.Body = http.MaxBytesReader(w, c.Request.Body, requestBytesLimit)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user