This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/answer-plugins.git
The following commit(s) were added to refs/heads/main by this push:
new db916e8 fix state to random code
db916e8 is described below
commit db916e87ba12d63be47d8a5e4229b819de8e827c
Author: Neko <[email protected]>
AuthorDate: Fri Aug 29 17:47:49 2025 +0800
fix state to random code
---
connector-basic/basic.go | 13 ++++++++++++-
connector-basic/info.yaml | 2 +-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/connector-basic/basic.go b/connector-basic/basic.go
index 296a2cf..e3695fd 100644
--- a/connector-basic/basic.go
+++ b/connector-basic/basic.go
@@ -71,6 +71,16 @@ type ConnectorConfig struct {
LogoSVG string `json:"logo_svg"`
}
+var base64chars =
strings.Split("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_",
"")
+
+func randomString(length int) (ret string) {
+ l := len(base64chars)
+ for i := 0; i < length; i++ {
+ ret = ret + base64chars[rand.Intn(l)]
+ }
+ return
+}
+
func init() {
plugin.Register(&Connector{
Config: &ConnectorConfig{},
@@ -117,7 +127,8 @@ func (g *Connector) ConnectorSender(ctx *plugin.GinContext,
receiverURL string)
RedirectURL: receiverURL,
Scopes: strings.Split(g.Config.Scope, ","),
}
- return oauth2Config.AuthCodeURL("state")
+ state := randomString(24)
+ return oauth2Config.AuthCodeURL(state)
}
func (g *Connector) ConnectorReceiver(ctx *plugin.GinContext, receiverURL
string) (userInfo plugin.ExternalLoginUserInfo, err error) {
diff --git a/connector-basic/info.yaml b/connector-basic/info.yaml
index 4d5d423..8fe1184 100644
--- a/connector-basic/info.yaml
+++ b/connector-basic/info.yaml
@@ -17,6 +17,6 @@
slug_name: basic_connector
type: connector
-version: 1.2.9
+version: 1.2.10
author: answerdev
link: https://github.com/apache/answer-plugins/tree/main/connector-basic