Opt: oauth2 plugins config

pull/39/head
zijiren233 2 years ago
parent e3c92fb7b4
commit 7b4c40c265

@ -27,7 +27,7 @@ func InitProvider(ctx context.Context) (err error) {
if flags.Dev { if flags.Dev {
logLevle = hclog.Debug logLevle = hclog.Debug
} }
for _, op := range conf.Conf.OAuth2 { for _, op := range conf.Conf.Oauth2Plugins {
op.PluginFile, err = utils.OptFilePath(op.PluginFile) op.PluginFile, err = utils.OptFilePath(op.PluginFile)
if err != nil { if err != nil {
log.Fatalf("oauth2 plugin file path error: %v", err) log.Fatalf("oauth2 plugin file path error: %v", err)

@ -17,8 +17,8 @@ type Config struct {
// Database // Database
Database DatabaseConfig `yaml:"database"` Database DatabaseConfig `yaml:"database"`
// OAuth2 // Oauth2Plugins
OAuth2 OAuth2Config `yaml:"oauth2"` Oauth2Plugins Oauth2Plugins `yaml:"oauth2_plugins"`
// RateLimit // RateLimit
RateLimit RateLimitConfig `yaml:"rate_limit"` RateLimit RateLimitConfig `yaml:"rate_limit"`
@ -46,7 +46,7 @@ func DefaultConfig() *Config {
Database: DefaultDatabaseConfig(), Database: DefaultDatabaseConfig(),
// OAuth2 // OAuth2
OAuth2: DefaultOAuth2Config(), Oauth2Plugins: DefaultOauth2Plugins(),
// RateLimit // RateLimit
RateLimit: DefaultRateLimitConfig(), RateLimit: DefaultRateLimitConfig(),

@ -1,12 +1,10 @@
package conf package conf
type OAuth2Config []Oauth2Plugin type Oauth2Plugins []struct {
type Oauth2Plugin struct {
PluginFile string `yaml:"plugin_file"` PluginFile string `yaml:"plugin_file"`
Args []string `yaml:"args"` Args []string `yaml:"args"`
} }
func DefaultOAuth2Config() OAuth2Config { func DefaultOauth2Plugins() Oauth2Plugins {
return nil return nil
} }

@ -25,16 +25,9 @@ import (
// //
// config.yaml: // config.yaml:
// //
// oauth2: // oauth2_plugins:
// providers: // - plugin_file: plugins/oauth2/feishuSSO
// feishuSSO: // args: ["OAuth2.0协议端点中的一串数字"]
// client_id: "App ID"
// client_secret: "App Secret"
// redirect_url: "登录回调地址"
// plugins:
// - plugin_file: plugins/oauth2/feishuSSO
// arges:
// - "OAuth2.0协议端点中的一串数字"
type FeishuProvider struct { type FeishuProvider struct {
config oauth2.Config config oauth2.Config
ssoid string // Your SSO Application ID in Feishu Anycross ssoid string // Your SSO Application ID in Feishu Anycross

@ -18,15 +18,8 @@ import (
// //
// config.yaml: // config.yaml:
// //
// oauth2: // oauth2_plugins:
// providers: // - plugin_file: plugins/oauth2/gitee
// gitee:
// client_id: xxx
// client_secret: xxx
// redirect_url: xxx
// plugins:
// - plugin_file: plugins/oauth2/gitee
// arges: []
type GiteeProvider struct { type GiteeProvider struct {
config oauth2.Config config oauth2.Config
} }

Loading…
Cancel
Save