提交
This commit is contained in:
@@ -10,12 +10,12 @@ import (
|
||||
// SSOProvider SSO提供商配置
|
||||
// 支持 OAuth2.0 / CAS / LDAP / OIDC 等协议
|
||||
type SSOProvider struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
ID uint64 `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name" gorm:"size:64;not null"` // 提供商名称: 企业微信/钉钉/飞书
|
||||
Type string `json:"type" gorm:"size:32;not null"` // 协议类型: oauth2/cas/oidc/ldap
|
||||
DisplayName string `json:"display_name" gorm:"size:64;not null"` // 登录页显示名称
|
||||
Icon string `json:"icon" gorm:"size:512"` // 图标URL
|
||||
Config SSOConfig `json:"config" gorm:"type:json"` // 协议配置
|
||||
Config SSOConfig `json:"config" gorm:"type:text"` // 协议配置
|
||||
AutoCreate int8 `json:"auto_create" gorm:"default:1"` // 自动创建用户: 1=是 0=否
|
||||
DefaultRole string `json:"default_role" gorm:"size:32;default:viewer"` // 自动创建时的默认角色
|
||||
Status int8 `json:"status" gorm:"default:1"` // 1=启用 0=禁用
|
||||
@@ -63,7 +63,11 @@ type SSOConfig struct {
|
||||
|
||||
// Value 实现 driver.Valuer
|
||||
func (c SSOConfig) Value() (driver.Value, error) {
|
||||
return json.Marshal(c)
|
||||
b, err := json.Marshal(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return string(b), nil
|
||||
}
|
||||
|
||||
// Scan 实现 sql.Scanner
|
||||
@@ -71,8 +75,13 @@ func (c *SSOConfig) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
return nil
|
||||
}
|
||||
bytes, ok := value.([]byte)
|
||||
if !ok {
|
||||
var bytes []byte
|
||||
switch v := value.(type) {
|
||||
case []byte:
|
||||
bytes = v
|
||||
case string:
|
||||
bytes = []byte(v)
|
||||
default:
|
||||
return fmt.Errorf("SSOConfig.Scan: 无法将 %T 转换为 []byte", value)
|
||||
}
|
||||
return json.Unmarshal(bytes, c)
|
||||
@@ -81,7 +90,7 @@ func (c *SSOConfig) Scan(value interface{}) error {
|
||||
// SSOSession SSO会话记录
|
||||
// 记录SSO登录的来源和关联信息
|
||||
type SSOSession struct {
|
||||
ID uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
|
||||
ID uint64 `json:"id" gorm:"primaryKey"`
|
||||
UserID uint64 `json:"user_id" gorm:"index;not null"` // 关联的本地用户ID
|
||||
ProviderID uint64 `json:"provider_id" gorm:"not null"` // SSO提供商ID
|
||||
ExternalID string `json:"external_id" gorm:"size:256;not null"` // 外部系统用户ID
|
||||
|
||||
Reference in New Issue
Block a user