From 022fb97153ce25c00dd66dec11b318ea95962d2a Mon Sep 17 00:00:00 2001 From: Klagarge Date: Thu, 21 May 2026 12:47:23 +0200 Subject: [PATCH] fix(db): remove authorization for battery status endpoint This endpoint is now publicly available without the need of an authorization Signed-off-by: Klagarge --- db/get-db.http | 1 - db/src/rest/rest.go | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/db/get-db.http b/db/get-db.http index f4acd9e..79a7889 100644 --- a/db/get-db.http +++ b/db/get-db.http @@ -18,4 +18,3 @@ Authorization: Basic {{username}} {{password}} ### GET battery status of all devices GET {{host}}/api/v1/battery -Authorization: Basic {{username}} {{password}} diff --git a/db/src/rest/rest.go b/db/src/rest/rest.go index 67d5654..a921ab9 100644 --- a/db/src/rest/rest.go +++ b/db/src/rest/rest.go @@ -63,6 +63,10 @@ func (g *RestGateway) setupRoutes() { g.engine.Use(cors.New(corsConfig)) v1 := g.engine.Group("/api/v1") + + // Public endpoints (no auth required) + v1.GET("/battery", g.getBattery) + if g.username != "" && g.password != "" { v1.Use(gin.BasicAuth(gin.Accounts{ g.username: g.password, @@ -73,7 +77,6 @@ func (g *RestGateway) setupRoutes() { v1.GET("/rooms", g.getRooms) v1.GET("/rooms/:room-id/current", g.getRoomCurrent) v1.GET("/rooms/:room-id/history", g.getRoomHistory) - v1.GET("/battery", g.getBattery) } g.engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))