mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🔒 内核接口 api/system/getConf 脱敏处理 Fix https://github.com/siyuan-note/siyuan/issues/6088
This commit is contained in:
parent
2fa3944459
commit
c048bde330
2 changed files with 35 additions and 1 deletions
|
|
@ -146,8 +146,15 @@ func getConf(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
|
maskedConf, err := model.GetMaskedConf()
|
||||||
|
if nil != err {
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = "get conf failed: " + err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
"conf": model.Conf,
|
"conf": maskedConf,
|
||||||
"start": start,
|
"start": start,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,6 +200,10 @@ func setAccessAuthCode(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
aac := arg["accessAuthCode"].(string)
|
aac := arg["accessAuthCode"].(string)
|
||||||
|
if model.MaskedAccessAuthCode == aac {
|
||||||
|
aac = model.Conf.AccessAuthCode
|
||||||
|
}
|
||||||
|
|
||||||
model.Conf.AccessAuthCode = aac
|
model.Conf.AccessAuthCode = aac
|
||||||
model.Conf.Save()
|
model.Conf.Save()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -582,6 +582,29 @@ func IsSubscriber() bool {
|
||||||
return nil != Conf.User && (-1 == Conf.User.UserSiYuanProExpireTime || 0 < Conf.User.UserSiYuanProExpireTime) && 0 == Conf.User.UserSiYuanSubscriptionStatus
|
return nil != Conf.User && (-1 == Conf.User.UserSiYuanProExpireTime || 0 < Conf.User.UserSiYuanProExpireTime) && 0 == Conf.User.UserSiYuanSubscriptionStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
MaskedUserData = ""
|
||||||
|
MaskedAccessAuthCode = "*******"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetMaskedConf() (ret *AppConf, err error) {
|
||||||
|
// 脱敏处理
|
||||||
|
data, err := gulu.JSON.MarshalIndentJSON(Conf, "", " ")
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("marshal conf failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ret = &AppConf{}
|
||||||
|
if err = gulu.JSON.UnmarshalJSON(data, ret); nil != err {
|
||||||
|
logging.LogErrorf("unmarshal conf failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.UserData = MaskedUserData
|
||||||
|
ret.AccessAuthCode = MaskedAccessAuthCode
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func clearWorkspaceTemp() {
|
func clearWorkspaceTemp() {
|
||||||
os.RemoveAll(filepath.Join(util.TempDir, "bazaar"))
|
os.RemoveAll(filepath.Join(util.TempDir, "bazaar"))
|
||||||
os.RemoveAll(filepath.Join(util.TempDir, "export"))
|
os.RemoveAll(filepath.Join(util.TempDir, "export"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue