fix(plugin): enhanced AES encryption security (#533)

This commit is contained in:
mrh997
2025-08-04 20:03:31 +08:00
committed by GitHub
parent 36923bd0a4
commit f80d4f757b
8 changed files with 230 additions and 22 deletions

View File

@@ -23,6 +23,7 @@ import (
"fmt"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"time"
@@ -1703,7 +1704,12 @@ func (p *PluginApplicationService) OauthAuthorizationCode(ctx context.Context, r
return nil, errorx.WrapByCode(err, errno.ErrPluginOAuthFailed, errorx.KV(errno.PluginMsgKey, "invalid state"))
}
stateBytes, err := utils.DecryptByAES(stateStr, utils.StateSecretKey)
secret := os.Getenv(utils.StateSecretEnv)
if secret == "" {
secret = utils.DefaultStateSecret
}
stateBytes, err := utils.DecryptByAES(stateStr, secret)
if err != nil {
return nil, errorx.WrapByCode(err, errno.ErrPluginOAuthFailed, errorx.KV(errno.PluginMsgKey, "invalid state"))
}