diff --git a/pkg/internal/auth/userinfo.go b/pkg/internal/auth/userinfo.go index 2c8a7fe..46763eb 100644 --- a/pkg/internal/auth/userinfo.go +++ b/pkg/internal/auth/userinfo.go @@ -3,14 +3,15 @@ package auth import ( "context" "fmt" + "strconv" + "time" + "git.solsynth.dev/hypernet/nexus/pkg/internal/directory" "git.solsynth.dev/hypernet/nexus/pkg/nex" "git.solsynth.dev/hypernet/nexus/pkg/nex/sec" "git.solsynth.dev/hypernet/nexus/pkg/proto" "github.com/gofiber/fiber/v2" "github.com/rs/zerolog/log" - "strconv" - "time" ) func userinfoFetch(c *fiber.Ctx) error { @@ -29,7 +30,7 @@ func userinfoFetch(c *fiber.Ctx) error { defer cancel() sed, err := strconv.Atoi(claims.Session) if err != nil { - return fiber.NewError(fiber.StatusUnauthorized, fmt.Sprintf("invalid token payload")) + return fiber.NewError(fiber.StatusUnauthorized, "invalid token payload") } resp, err := proto.NewAuthServiceClient(conn).Authenticate(ctx, &proto.AuthRequest{ SessionId: uint64(sed), @@ -38,7 +39,7 @@ func userinfoFetch(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusUnauthorized, fmt.Sprintf("unable to load userinfo: %v", err)) } userinfo := sec.NewUserInfoFromProto(resp.Info.Info) - c.Locals("nex_user", userinfo) + c.Locals("nex_user", &userinfo) tk, err := IWriter.WriteUserInfoJwt(userinfo) if err != nil { return fiber.NewError(fiber.StatusInternalServerError, fmt.Sprintf("unable to sign userinfo: %v", err)) diff --git a/pkg/internal/http/api/index.go b/pkg/internal/http/api/index.go index 9592cb5..444be12 100644 --- a/pkg/internal/http/api/index.go +++ b/pkg/internal/http/api/index.go @@ -42,7 +42,7 @@ func MapAPIs(app *fiber.App) { } // WatchTower administration APIs - wt := app.Group("/watchtower").Name("WatchTower").Use(auth.ValidatorMiddleware) + wt := app.Group("/wt").Name("WatchTower").Use(auth.ValidatorMiddleware) { wt.Post("/maintenance/database", wtRunDbMaintenance) } diff --git a/pkg/internal/http/ws/ws.go b/pkg/internal/http/ws/ws.go index d5ddd75..75cc55c 100644 --- a/pkg/internal/http/ws/ws.go +++ b/pkg/internal/http/ws/ws.go @@ -15,14 +15,14 @@ import ( ) func Listen(c *websocket.Conn) { - user, ok := c.Locals("nex_user").(sec.UserInfo) + user, ok := c.Locals("nex_user").(*sec.UserInfo) if !ok { c.Close() return } // Push connection - clientId := ClientRegister(user, c) + clientId := ClientRegister(*user, c) // Event loop var mt int @@ -80,5 +80,5 @@ func Listen(c *websocket.Conn) { } // Pop connection - ClientUnregister(user, clientId) + ClientUnregister(*user, clientId) }