Revert to use cached userinfo for security reason

This commit is contained in:
LittleSheep 2025-03-29 15:27:29 +08:00
parent f113ae6cba
commit 4a08fd8f1c
2 changed files with 2 additions and 16 deletions

View File

@ -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()

View File

@ -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 {