Commit a5a57a1b authored by Janoš Guljaš's avatar Janoš Guljaš Committed by GitHub

forbid PSS API endpoints in the Gateway mode (#1004)

parent 78848e99
...@@ -48,6 +48,11 @@ func TestGatewayMode(t *testing.T) { ...@@ -48,6 +48,11 @@ func TestGatewayMode(t *testing.T) {
jsonhttptest.Request(t, client, http.MethodGet, "/tags", http.StatusForbidden, forbiddenResponseOption) jsonhttptest.Request(t, client, http.MethodGet, "/tags", http.StatusForbidden, forbiddenResponseOption)
}) })
t.Run("pss endpoints", func(t *testing.T) {
jsonhttptest.Request(t, client, http.MethodPost, "/pss/send/test-topic/ab", http.StatusForbidden, forbiddenResponseOption)
jsonhttptest.Request(t, client, http.MethodGet, "/pss/subscribe/test-topic", http.StatusForbidden, forbiddenResponseOption)
})
t.Run("pinning", func(t *testing.T) { t.Run("pinning", func(t *testing.T) {
headerOption := jsonhttptest.WithRequestHeader(api.SwarmPinHeader, "true") headerOption := jsonhttptest.WithRequestHeader(api.SwarmPinHeader, "true")
......
...@@ -90,14 +90,20 @@ func (s *server) setupRouting() { ...@@ -90,14 +90,20 @@ func (s *server) setupRouting() {
), ),
}) })
handle(router, "/pss/send/{topic}/{targets}", jsonhttp.MethodHandler{ handle(router, "/pss/send/{topic}/{targets}", web.ChainHandlers(
"POST": web.ChainHandlers( s.gatewayModeForbidEndpointHandler,
jsonhttp.NewMaxBodyBytesHandler(swarm.ChunkSize), web.FinalHandler(jsonhttp.MethodHandler{
web.FinalHandlerFunc(s.pssPostHandler), "POST": web.ChainHandlers(
), jsonhttp.NewMaxBodyBytesHandler(swarm.ChunkSize),
}) web.FinalHandlerFunc(s.pssPostHandler),
),
})),
)
handle(router, "/pss/subscribe/{topic}", http.HandlerFunc(s.pssWsHandler)) handle(router, "/pss/subscribe/{topic}", web.ChainHandlers(
s.gatewayModeForbidEndpointHandler,
web.FinalHandlerFunc(s.pssWsHandler),
))
handle(router, "/tags", web.ChainHandlers( handle(router, "/tags", web.ChainHandlers(
s.gatewayModeForbidEndpointHandler, s.gatewayModeForbidEndpointHandler,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment