|
|
@ -19,6 +19,7 @@ import {{.authImport}}
|
|
|
|
type Config struct {
|
|
|
|
type Config struct {
|
|
|
|
rest.RestConf
|
|
|
|
rest.RestConf
|
|
|
|
{{.auth}}
|
|
|
|
{{.auth}}
|
|
|
|
|
|
|
|
{{.jwtTrans}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
|
@ -26,6 +27,11 @@ type Config struct {
|
|
|
|
AccessSecret string
|
|
|
|
AccessSecret string
|
|
|
|
AccessExpire int64
|
|
|
|
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 {
|
|
|
|
for _, item := range authNames {
|
|
|
|
auths = append(auths, fmt.Sprintf("%s %s", item, jwtTemplate))
|
|
|
|
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)
|
|
|
|
authImportStr := fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceURL)
|
|
|
|
|
|
|
|
|
|
|
|
return genFile(fileGenConfig{
|
|
|
|
return genFile(fileGenConfig{
|
|
|
@ -53,6 +65,7 @@ func genConfig(dir string, cfg *config.Config, api *spec.ApiSpec) error {
|
|
|
|
data: map[string]string{
|
|
|
|
data: map[string]string{
|
|
|
|
"authImport": authImportStr,
|
|
|
|
"authImport": authImportStr,
|
|
|
|
"auth": strings.Join(auths, "\n"),
|
|
|
|
"auth": strings.Join(auths, "\n"),
|
|
|
|
|
|
|
|
"jwtTrans": strings.Join(jwtTransList, "\n"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|