Fix/issue#1289 (#1460)
* fix #1289 * Add unit test case * fix `jwtTransKey` * fix `jwtTransKey` Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
@@ -19,6 +19,7 @@ import {{.authImport}}
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
{{.auth}}
|
||||
{{.jwtTrans}}
|
||||
}
|
||||
`
|
||||
|
||||
@@ -26,6 +27,11 @@ type Config struct {
|
||||
AccessSecret string
|
||||
AccessExpire int64
|
||||
}
|
||||
`
|
||||
jwtTransTemplate = ` struct {
|
||||
Secret string
|
||||
PrevSecret string
|
||||
}
|
||||
`
|
||||
)
|
||||
|
||||
@@ -40,6 +46,12 @@ func genConfig(dir string, cfg *config.Config, api *spec.ApiSpec) error {
|
||||
for _, item := range authNames {
|
||||
auths = append(auths, fmt.Sprintf("%s %s", item, jwtTemplate))
|
||||
}
|
||||
|
||||
jwtTransNames := getJwtTrans(api)
|
||||
var jwtTransList []string
|
||||
for _, item := range jwtTransNames {
|
||||
jwtTransList = append(jwtTransList, fmt.Sprintf("%s %s", item, jwtTransTemplate))
|
||||
}
|
||||
authImportStr := fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL)
|
||||
|
||||
return genFile(fileGenConfig{
|
||||
@@ -53,6 +65,7 @@ func genConfig(dir string, cfg *config.Config, api *spec.ApiSpec) error {
|
||||
data: map[string]string{
|
||||
"authImport": authImportStr,
|
||||
"auth": strings.Join(auths, "\n"),
|
||||
"jwtTrans": strings.Join(jwtTransList, "\n"),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user