From 0e1fdf10a623331001b1fc05110ffed7aaa2b535 Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Fri, 13 Dec 2024 15:16:53 +0800 Subject: [PATCH] fix: Fix `local-auth` for api `/connect/:devid` Signed-off-by: Jianhui Zhao --- api.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index fac60ae..3878465 100644 --- a/api.go +++ b/api.go @@ -159,6 +159,10 @@ func apiStart(br *broker) { isConnect := false devid := "" + if !cfg.LocalAuth && isLocalRequest(c) { + return + } + if strings.HasPrefix(c.Request.URL.Path, "/connect/") { devid = c.Param("devid") if devid == "" { @@ -340,9 +344,9 @@ func apiStart(br *broker) { r.GET("/authorized/:devid", func(c *gin.Context) { devid := c.Param("devid") - authorized := false + authorized := !cfg.LocalAuth && isLocalRequest(c) - if devInWhiteList(devid, cfg) { + if !authorized && devInWhiteList(devid, cfg) { authorized = true }