⏪ Revert to use cached userinfo for security reason
This commit is contained in:
parent
f113ae6cba
commit
4a08fd8f1c
@ -6,10 +6,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/internal/cache"
|
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
|
"git.solsynth.dev/hypernet/nexus/pkg/internal/directory"
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
"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/nex/sec"
|
||||||
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
||||||
"github.com/gofiber/fiber/v2"
|
"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")
|
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)
|
service := directory.GetServiceInstanceByType(nex.ServiceTypeAuth)
|
||||||
if service != nil {
|
if service != nil {
|
||||||
conn, err := service.GetGrpcConn()
|
conn, err := service.GetGrpcConn()
|
||||||
|
@ -5,7 +5,8 @@ import "fmt"
|
|||||||
// Those constants are used to directly get the cached data from redis
|
// Those constants are used to directly get the cached data from redis
|
||||||
// Formatted like {prefix}#{key}
|
// Formatted like {prefix}#{key}
|
||||||
const (
|
const (
|
||||||
DAUserInfoPrefix = "userinfo"
|
DAAttachment = "attachment"
|
||||||
|
DAUser = "account"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FKey(prefix string, key any) string {
|
func FKey(prefix string, key any) string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user