Skip to content

Commit c701c86

Browse files
authored
Backport: Ratelimit APIs that publish to the nuts network (#3542)
* Ratelimit APIs that publish to the nuts network * release notes v6.0.1
1 parent 0b61a03 commit c701c86

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

docs/pages/release_notes.rst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22
Release notes
33
#############
44

5-
*******************
5+
***************
6+
Peanut (v6.0.1)
7+
***************
8+
9+
Release date: 2024-11-06
10+
11+
- disable rate limiting on APIs when supported DID methods does not include 'nuts'
12+
- add rate limiting to VDR v2 APIs
13+
14+
**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v6.0.0...v6.0.1
15+
16+
***************
617
Peanut (v6.0.0)
7-
*******************
18+
***************
819

920
Release date: 2024-10-25
1021

@@ -103,19 +114,19 @@ The following features have been deprecated:
103114
- Network v1 API, to be removed
104115
- VDR v1 API, replaced by VDR v2
105116

106-
************************
117+
*************************
107118
Hazelnut update (v5.4.11)
108-
************************
119+
*************************
109120

110121
Release date: 2024-09-24
111122

112123
- Fixed an issue where the deactivated status of a DID document could be resolved incorrectly
113124

114125
**Full Changelog**: https://github.com/nuts-foundation/nuts-node/compare/v5.4.10...v5.4.11
115126

116-
************************
127+
*************************
117128
Hazelnut update (v5.4.10)
118-
************************
129+
*************************
119130

120131
Release date: 2024-09-13
121132

http/engine.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@ import (
2222
"context"
2323
"errors"
2424
"fmt"
25-
"github.com/nuts-foundation/nuts-node/http/client"
2625
"net"
2726
"net/http"
2827
"os"
28+
"slices"
2929
"strings"
3030
"time"
3131

3232
"github.com/labstack/echo/v4"
3333
"github.com/labstack/echo/v4/middleware"
3434
"github.com/nuts-foundation/nuts-node/core"
3535
cryptoEngine "github.com/nuts-foundation/nuts-node/crypto"
36+
"github.com/nuts-foundation/nuts-node/http/client"
3637
"github.com/nuts-foundation/nuts-node/http/log"
3738
"github.com/nuts-foundation/nuts-node/http/tokenV2"
39+
"github.com/nuts-foundation/nuts-node/vdr/didnuts"
3840
)
3941

4042
const moduleName = "HTTP"
@@ -180,15 +182,19 @@ func matchesPath(requestURI string, path string) bool {
180182
}
181183

182184
func (h Engine) applyRateLimiterMiddleware(echoServer core.EchoRouter, serverConfig core.ServerConfig) {
183-
// Always enabled in strict mode
184-
if serverConfig.Strictmode || serverConfig.InternalRateLimiter {
185+
// Always enabled in strict mode, but only if did:nuts is enabled on the node
186+
if (serverConfig.Strictmode || serverConfig.InternalRateLimiter) && slices.Contains(serverConfig.DIDMethods, didnuts.MethodName) {
185187
echoServer.Use(newInternalRateLimiter(map[string][]string{
186188
http.MethodPost: {
187-
"/internal/vcr/v2/issuer/vc", // issuing new VCs
188-
"/internal/vdr/v1/did", // creating new DIDs
189-
"/internal/vdr/v1/did/:did/verificationmethod", // add VM to DID
190-
"/internal/didman/v1/did/:did/endpoint", // add endpoint to DID
191-
"/internal/didman/v1/did/:did/compoundservice", // add compound service to DID
189+
"/internal/vcr/v2/issuer/vc", // issuing new VCs
190+
"/internal/vdr/v1/did", // creating new DIDs
191+
"/internal/vdr/v1/did/:did/verificationmethod", // add VM to DID
192+
"/internal/didman/v1/did/:did/endpoint", // add endpoint to DID
193+
"/internal/didman/v1/did/:did/compoundservice", // add compound service to DID
194+
"/internal/vdr/v2/subject", // create new subject
195+
"/internal/vdr/v2/subject/:id/service", // add service to subject
196+
"/internal/vdr/v2/subject/:id/service/:serviceId", // update service for a subject
197+
"/internal/vdr/v2/subject/:id/verificationmethod", // create new verification method for subject
192198
},
193199
http.MethodPut: {
194200
"/internal/vdr/v1/did/:did", // updating DIDs

0 commit comments

Comments
 (0)