From 4a08fd8f1c46f5f4b0458af3a33bbf821e767f92 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 29 Mar 2025 15:27:29 +0800 Subject: [PATCH] :rewind: Revert to use cached userinfo for security reason --- pkg/internal/auth/userinfo.go | 15 --------------- pkg/nex/cachekit/direct_const.go | 3 ++- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/pkg/internal/auth/userinfo.go b/pkg/internal/auth/userinfo.go index c93c2ac..46763eb 100644 --- a/pkg/internal/auth/userinfo.go +++ b/pkg/internal/auth/userinfo.go @@ -6,10 +6,8 @@ import ( "strconv" "time" - "git.solsynth.dev/hypernet/nexus/pkg/internal/cache" "git.solsynth.dev/hypernet/nexus/pkg/internal/directory" "git.solsynth.dev/hypernet/nexus/pkg/nex" - "git.solsynth.dev/hypernet/nexus/pkg/nex/cachekit" "git.solsynth.dev/hypernet/nexus/pkg/nex/sec" "git.solsynth.dev/hypernet/nexus/pkg/proto" "github.com/gofiber/fiber/v2" @@ -22,19 +20,6 @@ func userinfoFetch(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusUnauthorized, "user principal data was not found") } - if val, err := cachekit.Get[sec.UserInfo]( - cache.Kcc, - cachekit.FKey(cachekit.DAUserInfoPrefix, claims.Session), - ); err == nil { - c.Locals("nex_user", &val) - tk, err := IWriter.WriteUserInfoJwt(val) - if err != nil { - return fiber.NewError(fiber.StatusInternalServerError, fmt.Sprintf("unable to sign userinfo: %v", err)) - } - c.Locals("nex_token", tk) - return nil - } - service := directory.GetServiceInstanceByType(nex.ServiceTypeAuth) if service != nil { conn, err := service.GetGrpcConn() diff --git a/pkg/nex/cachekit/direct_const.go b/pkg/nex/cachekit/direct_const.go index 3702472..337fcbb 100644 --- a/pkg/nex/cachekit/direct_const.go +++ b/pkg/nex/cachekit/direct_const.go @@ -5,7 +5,8 @@ import "fmt" // Those constants are used to directly get the cached data from redis // Formatted like {prefix}#{key} const ( - DAUserInfoPrefix = "userinfo" + DAAttachment = "attachment" + DAUser = "account" ) func FKey(prefix string, key any) string {