28e53d90fc
- 统一 OpenAI 兼容 /v1 中继 + 渠道/额度/令牌/流水 - 各领域包:relay 模型网关、model 数据层、controller 管理 API
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package system_setting
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/QuantumNous/new-api/setting/config"
|
|
)
|
|
|
|
type OIDCSettings struct {
|
|
Enabled bool `json:"enabled"`
|
|
DisplayName string `json:"display_name"`
|
|
ClientId string `json:"client_id"`
|
|
ClientSecret string `json:"client_secret"`
|
|
WellKnown string `json:"well_known"`
|
|
AuthorizationEndpoint string `json:"authorization_endpoint"`
|
|
TokenEndpoint string `json:"token_endpoint"`
|
|
UserInfoEndpoint string `json:"user_info_endpoint"`
|
|
}
|
|
|
|
// 默认配置
|
|
var defaultOIDCSettings = OIDCSettings{}
|
|
|
|
func init() {
|
|
// 注册到全局配置管理器
|
|
config.GlobalConfig.Register("oidc", &defaultOIDCSettings)
|
|
}
|
|
|
|
func GetOIDCSettings() *OIDCSettings {
|
|
return &defaultOIDCSettings
|
|
}
|
|
|
|
// GetEffectiveDisplayName returns the admin-configured display name, or the
|
|
// literal "OIDC" when none has been set. Centralizing this fallback keeps the
|
|
// default in one place for both the OAuth provider name and the public
|
|
// status payload.
|
|
func (s *OIDCSettings) GetEffectiveDisplayName() string {
|
|
if trimmed := strings.TrimSpace(s.DisplayName); trimmed != "" {
|
|
return trimmed
|
|
}
|
|
return "OIDC"
|
|
}
|