chore: use limits from JWT if available

This commit is contained in:
im-adithya
2023-12-05 15:58:45 +05:30
parent 62d7ffb7fe
commit e681e69fa2
24 changed files with 133 additions and 47 deletions

View File

@@ -153,8 +153,17 @@ func main() {
logMw := transport.CreateLoggingMiddleware(logger)
// strict rate limit for requests for sending payments
strictRateLimitMiddleware := transport.CreateRateLimitMiddleware(c.StrictRateLimit, c.BurstRateLimit)
secured := e.Group("", tokens.Middleware(c.JWTSecret), logMw)
securedWithStrictRateLimit := e.Group("", tokens.Middleware(c.JWTSecret), strictRateLimitMiddleware, logMw)
limits := &lnd.Limits{
MaxSendVolume: c.MaxSendVolume,
MaxSendAmount: c.MaxSendAmount,
MaxReceiveVolume: c.MaxReceiveVolume,
MaxReceiveAmount: c.MaxReceiveAmount,
MaxAccountBalance: c.MaxAccountBalance,
}
secured := e.Group("", tokens.Middleware(c.JWTSecret, limits), logMw)
securedWithStrictRateLimit := e.Group("", tokens.Middleware(c.JWTSecret, limits), strictRateLimitMiddleware, logMw)
transport.RegisterLegacyEndpoints(svc, e, secured, securedWithStrictRateLimit, strictRateLimitMiddleware, tokens.AdminTokenMiddleware(c.AdminToken), logMw)
transport.RegisterV2Endpoints(svc, e, secured, securedWithStrictRateLimit, strictRateLimitMiddleware, tokens.AdminTokenMiddleware(c.AdminToken), logMw)