mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
feat: 绑定 oauth2
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -21,6 +23,17 @@ const (
|
||||
ConfigCoverIgnoreAll
|
||||
)
|
||||
|
||||
type ConfigForGuests struct {
|
||||
Language string `json:"language"`
|
||||
SiteName string `json:"site_name"`
|
||||
CustomCode string `json:"custom_code,omitempty"`
|
||||
CustomCodeDashboard string `json:"custom_code_dashboard,omitempty"`
|
||||
Oauth2Providers []string `json:"oauth2_providers,omitempty"`
|
||||
|
||||
InstallHost string `json:"install_host,omitempty"`
|
||||
TLS bool `json:"tls,omitempty"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Debug bool `mapstructure:"debug" json:"debug,omitempty"` // debug模式开关
|
||||
RealIPHeader string `mapstructure:"real_ip_header" json:"real_ip_header,omitempty"` // 真实IP
|
||||
@@ -52,6 +65,11 @@ type Config struct {
|
||||
CustomCode string `mapstructure:"custom_code" json:"custom_code,omitempty"`
|
||||
CustomCodeDashboard string `mapstructure:"custom_code_dashboard" json:"custom_code_dashboard,omitempty"`
|
||||
|
||||
// oauth2 配置
|
||||
Oauth2 map[string]*Oauth2Config `mapstructure:"oauth2" json:"oauth2,omitempty"`
|
||||
// oauth2 供应商列表,无需配置,自动生成
|
||||
Oauth2Providers []string `yaml:"-" json:"oauth2_providers,omitempty"`
|
||||
|
||||
k *koanf.Koanf `json:"-"`
|
||||
filePath string `json:"-"`
|
||||
}
|
||||
@@ -132,6 +150,8 @@ func (c *Config) Read(path string, frontendTemplates []FrontendTemplate) error {
|
||||
}
|
||||
}
|
||||
|
||||
c.Oauth2Providers = slices.Collect(maps.Keys(c.Oauth2))
|
||||
|
||||
c.updateIgnoredIPNotificationID()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user