Skip to content

Commit ffc2cc3

Browse files
authored
Secure websocket logs admin api when authentication is enabled (#1206)
1 parent be277f7 commit ffc2cc3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

core/handlers/v2/logs_handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ func (this *LogsHandler) RegisterRoutes(mux *bone.Mux, am *handlers.AuthHandler)
3939
negroni.HandlerFunc(this.Options),
4040
))
4141

42-
mux.Get("/api/v2/ws/logs", http.HandlerFunc(this.GetWS))
42+
mux.Get("/api/v2/ws/logs", negroni.New(
43+
negroni.HandlerFunc(am.RequireTokenAuthentication),
44+
negroni.Wrap(http.HandlerFunc(this.GetWS)),
45+
))
4346
}
4447

4548
func (this *LogsHandler) Get(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {

functional-tests/hoverctl/start_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ var _ = Describe("hoverctl `start`", func() {
185185
response := functional_tests.DoRequest(sling.New().Get("http://localhost:8888/api/v2/hoverfly"))
186186
Expect(response.StatusCode).To(Equal(401))
187187

188+
response = functional_tests.DoRequest(sling.New().Get("http://localhost:8888/api/v2/ws/logs"))
189+
Expect(response.StatusCode).To(Equal(401))
190+
188191
response = functional_tests.DoRequest(sling.New().Post("http://localhost:8888/api/token-auth").BodyJSON(backends.User{
189192
Username: functional_tests.HoverflyUsername,
190193
Password: functional_tests.HoverflyPassword,

0 commit comments

Comments
 (0)