Skip to content

Commit

Permalink
fix: Fix local-auth for api /connect/:devid
Browse files Browse the repository at this point in the history
Signed-off-by: Jianhui Zhao <[email protected]>
  • Loading branch information
zhaojh329 committed Dec 13, 2024
1 parent 41d902d commit 0e1fdf1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 0e1fdf1

Please sign in to comment.