feat: add useGroupPathInToken boolean field in app.conf (#4026)

This commit is contained in:
DacongDA
2025-08-02 01:40:26 +08:00
committed by GitHub
parent 387f5d58f7
commit a28b871a46
2 changed files with 59 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ import (
"strings"
"time"
"github.com/casdoor/casdoor/conf"
"github.com/casdoor/casdoor/util"
"github.com/golang-jwt/jwt/v5"
)
@@ -381,6 +382,14 @@ func generateJwtToken(application *Application, user *User, provider string, non
refreshExpireTime = expireTime
}
if conf.GetConfigBool("useGroupPathInToken") {
groupPath, err := user.GetUserFullGroupPath()
if err != nil {
return "", "", "", err
}
user.Groups = groupPath
}
user = refineUser(user)
_, originBackend := getOriginFromHost(host)