feat: add OIDC login support

- Introduced OIDC configuration options in config.example.yaml.
- Added OIDC client initialization and routes for OIDC login, callback, and exchange.
- Implemented OIDC login service to handle user authentication via OIDC.
- Created frontend components for OIDC login and callback handling.
- Updated user creation logic to support OIDC users and their identities.
- Enhanced error handling for OIDC login processes.
This commit is contained in:
mlogclub
2026-05-24 20:49:10 +08:00
parent 1dd9c835ed
commit eac039bba4
18 changed files with 870 additions and 6 deletions
+11
View File
@@ -17,6 +17,7 @@ type Config struct {
VectorDB VectorDBConfig `yaml:"vectorDB"`
MCP MCPConfig `yaml:"mcp"`
WxWork WxWorkConfig `yaml:"wxWork"`
OIDC OIDCConfig `yaml:"oidc"`
CustomerSession CustomerSessionConfig `yaml:"customerSession"`
}
@@ -135,6 +136,16 @@ type MCPServerConfig struct {
Headers map[string]string `yaml:"headers"`
}
type OIDCConfig struct {
Enabled bool `yaml:"enabled"`
Issuer string `yaml:"issuer"`
ClientID string `yaml:"clientId"`
ClientSecret string `yaml:"clientSecret"`
RedirectURL string `yaml:"redirectUrl"`
StateSecret string `yaml:"stateSecret"`
Scopes []string `yaml:"scopes"`
}
// WxWorkConfig 定义企业微信接入配置。
//
// 当前主要用于后台管理台的企业微信登录流程:
+4
View File
@@ -8,3 +8,7 @@ type LoginRequest struct {
type WxWorkExchangeRequest struct {
Ticket string `json:"ticket"`
}
type OIDCExchangeRequest struct {
Ticket string `json:"ticket"`
}
+3 -1
View File
@@ -63,13 +63,15 @@ type ThirdProvider string
const (
ThirdProviderWxWork ThirdProvider = "wxwork"
ThirdProviderDingtalk ThirdProvider = "dingtalk"
ThirdProviderOIDC ThirdProvider = "oidc"
)
var ThirdProviderValues = []ThirdProvider{ThirdProviderWxWork, ThirdProviderDingtalk}
var ThirdProviderValues = []ThirdProvider{ThirdProviderWxWork, ThirdProviderDingtalk, ThirdProviderOIDC}
var thirdProviderLabelMap = map[ThirdProvider]string{
ThirdProviderWxWork: "企业微信",
ThirdProviderDingtalk: "钉钉",
ThirdProviderOIDC: "OIDC",
}
func GetThirdProviderLabel(provider ThirdProvider) string {