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 {
logLevle = hclog.Debug
}
for _, op := range conf.Conf.OAuth2 {
for _, op := range conf.Conf.Oauth2Plugins {
op.PluginFile, err = utils.OptFilePath(op.PluginFile)
if err != nil {
log.Fatalf("oauth2 plugin file path error: %v", err)

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

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

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

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

Loading…
Cancel
Save