🔒 内核接口 api/system/getConf 脱敏处理 Fix https://github.com/siyuan-note/siyuan/issues/6088

This commit is contained in:
Liang Ding 2022-10-08 10:57:20 +08:00
parent 2fa3944459
commit c048bde330
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 35 additions and 1 deletions

View file

@ -582,6 +582,29 @@ func IsSubscriber() bool {
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() {
os.RemoveAll(filepath.Join(util.TempDir, "bazaar"))
os.RemoveAll(filepath.Join(util.TempDir, "export"))