model

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Connect      Action = "connect"
	DenyConnect  Action = "deny_connect"
	Download     Action = "download"
	DenyDownload Action = "deny_download"
	Upload       Action = "upload"
	DenyUpload   Action = "deny_upload"

	OneDay   Period = "1d"
	OneWeek  Period = "1w"
	OneMonth Period = "1m"
	OneYear  Period = "1y"
	Forever  Period = "ever"
)
View Source
const (
	//  0 机器没有密钥
	ServerPemStatusNone = iota
)

Variables

View Source
var (
	ConnectOnly        = ArrayString{string(Connect)}
	DownloadOnly       = ArrayString{string(Download)}
	UploadOnly         = ArrayString{string(Upload)}
	ConnectAndDownload = ArrayString{string(Connect), string(Download)}
	ConnectAndUpload   = ArrayString{string(Connect), string(Upload)}
	DownloadAndUpload  = ArrayString{string(Download), string(Upload)}
	DenyALL            = ArrayString{string(DenyConnect), string(DenyDownload), string(DenyUpload)}
	All                = ArrayString{string(Connect), string(Download), string(Upload)}

	DefaultPolicies = map[string]ArrayString{
		"All":                All,
		"ConnectOnly":        ConnectOnly,
		"DownloadOnly":       DownloadOnly,
		"UploadOnly":         UploadOnly,
		"ConnectAndDownload": ConnectAndDownload,
		"ConnectAndUpload":   ConnectAndUpload,
		"DownloadAndUpload":  DownloadAndUpload,
	}

	ExpireTimes = map[Period]time.Duration{
		OneDay:   time.Hour * 24,
		OneWeek:  time.Hour * 24 * 7,
		OneMonth: time.Hour * 24 * 30,
		OneYear:  time.Hour * 24 * 365,
		Forever:  time.Hour * 24 * 365 * 100,
	}
)

Functions

func FmtDingtalkApproveFile

func FmtDingtalkApproveFile(envType []string) string

审批表单目前只支持prod,dev,stage,none todo:判断策略属于审批的那个单子

func LoadYaml

func LoadYaml(configFile string)

load config from file

func MatchPolicy

func MatchPolicy(user User, inPutAction Action, server Server, dbPolicies []Policy, onlyIp bool) bool

对用户,策略,服务器,动作做权限判断 onlyIp 用来兼容策略对上传下载的判断,因为上传下载信息只会有 IP 信息。

func MatchPolicyOwner

func MatchPolicyOwner(user User, server Server) bool

Owner和用户一样则有权限

func MatchServerByFilter

func MatchServerByFilter(filter ServerFilterV1, server Server, onlyIp bool) bool

匹配服务器和过滤条件是否符合 支持多维度的并联匹配,ServerFilterV1如果属性没有为nil,则要进行联合匹配

func MatchUserGroup

func MatchUserGroup(user User, server Server) bool

用户组一致则有权限 admin有所有权限

func ServerListToMap

func ServerListToMap(s []Server) map[string]Server

ToMap convert to map with privateIp

Types

type Action

type Action string

func ReverseAction

func ReverseAction(action Action) Action

判断是否反向操作

type AddKeyRequest

type AddKeyRequest struct {
	IdentityFile *string `json:"identity_file" mapstructure:"identity_file"`              // 云上下载下来的名字,比如 jms-key.pem,private key file name
	PemBase64    *string `json:"pem_base64" binding:"required" mapstructure:"pem_base64"` // base64
	KeyID        *string `json:"key_id" binding:"required" mapstructure:"key_id"`         // 云上的key id,比如 skey-123456
	Profile      *string `json:"profile"`                                                 // 云账号的 profile,比如 aws, aliyun
}

type AddScpRecordRequest

type AddScpRecordRequest struct {
	Action *string `json:"action"` // download,upload
	From   *string `json:"from"`   // 来源
	To     *string `json:"to"`     // 目标
	User   *string `json:"user"`   // 用户
	Client *string `json:"client"` // 客户端
}

type AddSshLoginRequest

type AddSshLoginRequest struct {
	User         *string `json:"user"`          // 用户
	Client       *string `json:"client"`        // 客户端
	TargetServer *string `json:"target_server"` // 目标服务器
	InstanceID   *string `json:"instance_id"`   // 目标服务器实例ID
}

type ApprovalMut

type ApprovalMut struct {
	Users ArrayString `json:"users" binding:"required"`
	// Groups       ArrayString     `json:"groups"`
	Applicant    *string         `json:"applicant" binding:"required"` // 申请人AD名,或者email
	Name         *string         `json:"name"`
	Period       *Period         `json:"period"`  // 审批周期,默认一周
	Actions      []Action        `json:"actions"` // 申请动作,默认只有connect
	ServerFilter *ServerFilterV1 `json:"server_filter" binding:"required"`
}

func (*ApprovalMut) ToPolicyMut

func (a *ApprovalMut) ToPolicyMut() *PolicyRequest

type ApprovalResult

type ApprovalResult struct {
	Applicant *string `json:"applicant"`
	IsPass    *bool   `json:"is_pass"`
}

type ArrayString

type ArrayString []string

func (ArrayString) Contains

func (a ArrayString) Contains(findStr string) bool

支持*和! aaa* 写法

func (*ArrayString) Scan

func (a *ArrayString) Scan(value interface{}) error

func (ArrayString) Value

func (a ArrayString) Value() (driver.Value, error)

type AuthorizedKey

type AuthorizedKey struct {
	gorm.Model
	IsDelete  bool   `gorm:"column:is_delete;type:boolean;not null;default:false"`
	UUID      string `gorm:"column:uuid;type:varchar(36);unique_index;not null"`
	UserName  string `gorm:"column:user_name;type:varchar(255);not null"` // ad用户名
	PublicKey string `gorm:"column:public_key;type:text;not null"`
}

func (AuthorizedKey) TableName

func (AuthorizedKey) TableName() string

table name

type Broadcast

type Broadcast struct {
	gorm.Model
	Message string    `gorm:"column:message;type:text;not null"`
	Expires time.Time `gorm:"column:expires;type:timestamp;not null"`
}

func (Broadcast) TableName

func (Broadcast) TableName() string

type Config

type Config struct {
	Profiles     []CreateProfileRequest `mapstructure:"profiles"` // 云账号配置,用来自动同步云服务器信息
	Proxys       []CreateProxyRequest   `mapstructure:"proxies"`  // ssh代理
	Keys         Keys                   `mapstructure:"keys"`
	LocalServers []LocalServer          `mapstructure:"localServers"` // 支持人工加入的服务器
	WithVideo    WithVideo              `mapstructure:"withVideo"`    // 视频存储
	WithLdap     WithLdap               `mapstructure:"withLdap"`     // 配置ldap
	WithSSHCheck WithSSHCheck           `mapstructure:"withSSHCheck"` // 配置服务器SSH可连接性告警
	WithDB       WithPolicy             `mapstructure:"withDB"`       // 需要进行权限管理则启用该配置,启用后会使用数据库进行权限管理
	WithDingtalk WithDingtalk           `mapstructure:"withDingtalk"` // 配置钉钉审批流程
	Broadcast    string                 `mapstructure:"broadcast"`    // 配置广播消息
}

Config config

var Conf *Config

type CreateBroadcastRequest

type CreateBroadcastRequest struct {
	Messages *string `json:"messages" binding:"required"` // 消息内容
	KeepDays *int    `json:"keepDays"`                    // 保留天数,0 表示永久
}

type CreateProfileRequest

type CreateProfileRequest struct {
	Name    *string     `json:"name"`
	AK      *string     `json:"ak"`
	SK      *string     `json:"sk"`
	Cloud   *string     `json:"cloud"  default:"tencent"` // aws, aliyun, tencent
	Regions StringSlice `json:"regions"`
	Enabled bool        `json:"enabled" default:"true"` // 是否启用
}

type CreateProxyRequest

type CreateProxyRequest struct {
	Name         *string `json:"name" binding:"required" mapstructure:"name"` // 代理名称 唯一
	Host         *string `json:"host" mapstructure:"host"`
	Port         *int    `json:"port" mapstructure:"port"`
	IPPrefix     *string `json:"ip_prefix" mapstructure:"ip_prefix"`         // 适配哪些机器 IP 前缀使用 Proxy, 例如 192.168.1
	LoginUser    *string `json:"login_user" mapstructure:"login_user"`       // key超级用户 root ec2-user
	LoginPasswd  *string `json:"login_passwd" mapstructure:"login_passwd"`   // 密码或者key必须有一个, 优先使用密码
	KeyID        *string `json:"key_id" mapstructure:"key_id"`               // KeyID和IdentityFile都是用pem来验证,KeyID是唯一的,IdentityFile在名称命名时候不同账号可能会同名。当出现IdentityFile不唯一的时候可以用 keyID, 优先使用KeyID
	IdentityFile *string `json:"identity_file" mapstructure:"identity_file"` // KeyID和IdentityFile都是用pem来验证,KeyID是唯一的,IdentityFile在名称命名时候不同账号可能会同名。当出现IdentityFile不唯一的时候可以用 keyID, 优先使用KeyID
}

func (*CreateProxyRequest) ToProxy

func (req *CreateProxyRequest) ToProxy() (Proxy, error)

type CreateShellTaskRecordRequest

type CreateShellTaskRecordRequest struct {
	TaskID     *string `json:"task_id" binding:"required"`
	TaskName   *string `json:"task_name"`
	Shell      *string `json:"shell" binding:"required"`
	ServerIP   *string `json:"server_ip" binding:"required"`
	ServerName *string `json:"server_name"`
	CostTime   *string `json:"cost_time"`
	ExecTimes  *int    `json:"exec_times"`                    // 任务的执行次数,取自task的执行次数字段。
	IsSuccess  *bool   `json:"is_success" binding:"required"` // 任务是否执行成功
	Output     *string `json:"output" binding:"required"`
}

type CreateShellTaskRequest

type CreateShellTaskRequest struct {
	Name    *string         `json:"name" binding:"required"`    // 任务名称,唯一
	Shell   *string         `json:"shell" binding:"required"`   // 脚本内容
	Corn    *string         `json:"corn"`                       // corn表达式,支持定时执行任务,执行一次可以不传
	Servers *ServerFilterV1 `json:"servers" binding:"required"` // 执行的机器
}

type KV

type KV struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Key

type Key struct {
	gorm.Model `json:"-"`
	IsDelete   bool   `gorm:"column:is_delete;type:boolean;not null;default:false"`
	UUID       string `gorm:"column:uuid;type:varchar(36);unique_index;not null"`
	KeyID      string `gorm:"column:key_id;type:varchar(36);unique_index;not null"`
	KeyName    string `gorm:"column:key_name;type:varchar(255);unique_index;not null"`
	Profile    string `gorm:"column:profile;type:varchar(255);not null"`
	PemBase64  string `gorm:"column:pem_base64;type:text;not null"`
}

func (Key) TableName

func (Key) TableName() string

type Keys

type Keys []AddKeyRequest

func (Keys) ToMapWithID

func (k Keys) ToMapWithID() map[string]AddKeyRequest

ToMapWithID convert to map with keyID

func (Keys) ToMapWithName

func (k Keys) ToMapWithName() map[string]AddKeyRequest

type LocalServer

type LocalServer struct {
	Name   string `mapstructure:"name"`
	Host   string `mapstructure:"host"`
	Port   int    `mapstructure:"port"`
	User   string `mapstructure:"user"`
	Passwd string `mapstructure:"passwd"`
}

type MatchResult

type MatchResult int
const (
	// 后续处理下一个匹配
	MatchContinue MatchResult = 0
	// 直接返回 true
	MatchTrue MatchResult = 1
	// 直接 return false
	MatchFalse MatchResult = 2
)

type PGConfig

type PGConfig struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	Database string `mapstructure:"database"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
}

func (*PGConfig) GetUrl

func (c *PGConfig) GetUrl() string

type Period

type Period string

type Policy

type Policy struct {
	ID             string          `json:"id" gorm:"column:id;primary_key;not null"`
	CreatedAt      time.Time       `json:"created_at" gorm:"column:created_at"`
	UpdatedAt      time.Time       `json:"updated_at" gorm:"column:updated_at"`
	IsDeleted      bool            `json:"is_deleted" gorm:"column:is_deleted;default:false;not null"`
	Name           string          `json:"name" gorm:"column:name;not null"`
	Users          ArrayString     `json:"users" gorm:"column:users;type:json;not null"`
	ServerFilterV1 *ServerFilterV1 `json:"server_filter_v1" gorm:"column:server_filter_v1;type:json;"`
	ServerFilter   *ServerFilter   `json:"server_filter" gorm:"clumn:server_filter;type:json;"`
	Actions        ArrayString     `json:"actions" gorm:"column:actions;type:json;not null"`
	ExpiresAt      time.Time       `json:"expires_at" gorm:"column:expires_at;not null"`
	Approver       string          `json:"approver" gorm:"column:approver"`       // 审批人
	ApprovalID     string          `json:"approval_id" gorm:"column:approval_id"` // 审批ID
	IsEnabled      bool            `json:"is_enabled" gorm:"column:is_enabled;default:false;not null"`
}

func (*Policy) IsExpired

func (p *Policy) IsExpired() bool

func (Policy) TableName

func (Policy) TableName() string

type PolicyOld

type PolicyOld struct {
	ID           string       `json:"id" gorm:"column:id;primary_key;not null"`
	CreatedAt    time.Time    `json:"created_at" gorm:"column:created_at"`
	UpdatedAt    time.Time    `json:"updated_at" gorm:"column:updated_at"`
	IsDeleted    bool         `json:"is_deleted" gorm:"column:is_deleted;default:false;not null"`
	Name         string       `json:"name" gorm:"column:name;not null"`
	Users        ArrayString  `json:"users" gorm:"column:users;type:json;not null"`
	ServerFilter ServerFilter `json:"server_filter" gorm:"column:server_filter;type:json;not null"`
	Actions      ArrayString  `json:"actions" gorm:"column:actions;type:json;not null"`
	ExpiresAt    time.Time    `json:"expires_at" gorm:"column:expires_at;not null"`
	Approver     string       `json:"approver" gorm:"column:approver"`       // 审批人
	ApprovalID   string       `json:"approval_id" gorm:"column:approval_id"` // 审批ID
	IsEnabled    bool         `json:"is_enabled" gorm:"column:is_enabled;default:false;not null"`
}

func (PolicyOld) TableName

func (PolicyOld) TableName() string

type PolicyQueryRequest

type PolicyQueryRequest struct {
	User *string `json:"user"`
}

type PolicyRequest

type PolicyRequest struct {
	Name           *string         `json:"name" binding:"required"`
	Users          ArrayString     `json:"users"`
	Actions        ArrayString     `json:"actions"`
	ServerFilterV1 *ServerFilterV1 `json:"server_filter" binding:"required"`
	ExpiresAt      *time.Time      `json:"expires_at"` // time.Time
	IsEnabled      *bool           `json:"is_enabled"`
	ApprovalID     *string         `json:"approval_id"`
}

type Profile

type Profile struct {
	gorm.Model `json:"-"`
	UUID       string      `gorm:"column:uuid;type:varchar(36);unique_index;not null"`
	Name       string      `gorm:"column:name;type:varchar(255);not null"`
	AK         string      `gorm:"column:ak;type:varchar(255);not null"`
	SK         string      `gorm:"column:sk;type:varchar(255);not null"` // 经过加密
	IsDelete   bool        `gorm:"column:is_delete;type:boolean;not null;default:false"`
	Cloud      string      `gorm:"column:cloud;type:varchar(255);not null"`
	Regions    StringSlice `gorm:"column:regions;type:json;not null"`
	Enabled    bool        `gorm:"column:enabled;type:boolean;not null;default:true"`
}

func (Profile) TableName

func (Profile) TableName() string

type Proxy

type Proxy struct {
	gorm.Model   `json:"-"`
	IsDelete     bool   `gorm:"column:is_delete;type:boolean;not null;default:false"`
	UUID         string `gorm:"column:uuid;type:varchar(36);unique_index;not null"`
	KeyID        string `gorm:"column:key_id;type:varchar(255);default:''"`
	Name         string `gorm:"column:name;type:varchar(255);"`
	Host         string `gorm:"column:host;type:varchar(255);not null"`
	Port         int    `gorm:"column:port;type:integer;not null"`
	IPPrefix     string `gorm:"column:ip_prefix;type:varchar(255);not null"`
	LoginUser    string `gorm:"column:login_user;type:varchar(255);not null"`
	LoginPasswd  string `gorm:"column:login_passwd;type:varchar(255);"`
	IdentityFile string `gorm:"column:identity_file;type:varchar(255);"`
}

func (Proxy) TableName

func (Proxy) TableName() string

type QueryLoginRequest

type QueryLoginRequest struct {
	User     *string `json:"user"`
	Ip       *string `json:"ip"`
	Duration *int    `json:"duration" default:"24"` // 24 hours
}

type QueryRecordRequest

type QueryRecordRequest struct {
	TaskID   *string `json:"task_id"`   // 支持依据任务 ID 查询所有记录
	ServerIP *string `json:"server_ip"` // 支持依据服务器 IP 查询所有记录
}

type QueryScpRequest

type QueryScpRequest struct {
	Duration *int    `json:"duration" default:"24"` // 24 hours 默认
	KeyWord  *string `json:"keyWord"`
	User     *string `json:"user"`
	Action   *string `json:"action"`
}

type SSHAlert

type SSHAlert struct {
	RobotToken string `mapstructure:"robotToken"`
}

目前只支持钉钉机器人群告警

type SSHLoginRecord

type SSHLoginRecord struct {
	gorm.Model
	User             string `json:"user" gorm:"column:user;type:varchar(255);not null"`     // 用户
	Client           string `json:"client" gorm:"column:client;type:varchar(255);not null"` // 客户端
	Target           string `json:"target" gorm:"column:target;type:varchar(255);not null"` // 目标服务器
	TargetInstanceId string `json:"target_instance_id" gorm:"column:target_instance_id;type:varchar(255)"`
}

func (SSHLoginRecord) TableName

func (SSHLoginRecord) TableName() string

table name

type SSHUser

type SSHUser struct {
	UserName  string
	KeyName   string // pem file name, 这里是支持本地读取内容的
	Base64Pem string // base64 pem
	Password  string
}

SSHUser ssh user

type ScpRecord

type ScpRecord struct {
	gorm.Model
	Action string `json:"action" gorm:"column:action;type:varchar(255);not null"` // download,upload
	From   string `json:"from" gorm:"column:from;type:varchar(255);not null"`     // 来源
	To     string `json:"to" gorm:"column:to;type:varchar(255);not null"`         // 目标
	User   string `json:"user" gorm:"column:user;type:varchar(255);not null"`     // 用户
	Client string `json:"client" gorm:"column:client;type:varchar(255);not null"` // 客户端
}

func (ScpRecord) TableName

func (ScpRecord) TableName() string

table name

type Server

type Server struct {
	ID       string
	Name     string
	Host     string // 默认取私有 IP 第一个
	Port     int
	KeyPairs []*string // key pair name
	// Proxy    *CreateProxyRequest
	Profile  string
	Region   string
	Tags     model.Tags
	Status   model.InstanceStatus
	SSHUsers []SSHUser
}

Server server

type ServerFilter

type ServerFilter struct {
	Name    *string `json:"name"`     // 名字完全匹配,支持*
	IpAddr  *string `json:"ip_addr"`  // IP 地址完全匹配,支持* 匹配所有
	EnvType *string `json:"env_type"` // 机器 Tags 中的 EnvType,支持* 匹配所有
	Team    *string `json:"team"`     // 机器 Tags 中的 Team,支持* 匹配所有
}

func (*ServerFilter) Scan

func (a *ServerFilter) Scan(value interface{}) error

func (ServerFilter) ToString

func (a ServerFilter) ToString() string

func (ServerFilter) ToV1

func (a ServerFilter) ToV1() *ServerFilterV1

func (ServerFilter) Value

func (a ServerFilter) Value() (driver.Value, error)

type ServerFilterV1

type ServerFilterV1 struct {
	Name    []string `json:"name"`     // 名字完全匹配,支持*
	IpAddr  []string `json:"ip_addr"`  // IP 地址完全匹配,支持* 匹配所有
	EnvType []string `json:"env_type"` // 机器 Tags 中的 EnvType,支持* 匹配所有
	Team    []string `json:"team"`     // 机器 Tags 中的 Team,支持* 匹配所有
	KV      *KV      `json:"kv"`       // 支持自己指定特定的 KV 来过滤
}

可以预定义一些资产用来快速分配给其他策略c

func (*ServerFilterV1) Scan

func (a *ServerFilterV1) Scan(value interface{}) error

func (ServerFilterV1) ToString

func (a ServerFilterV1) ToString() string

func (ServerFilterV1) Value

func (a ServerFilterV1) Value() (driver.Value, error)

type Servers

type Servers []Server

func (Servers) SortByName

func (s Servers) SortByName()

按名称排序

type ShellTask

type ShellTask struct {
	gorm.Model `json:"-"`
	IsDeleted  bool           `json:"is_deleted" gorm:"column:is_deleted;default:false;not null"`
	UUID       string         `json:"uuid" gorm:"column:uuid;type:varchar(36);unique_index;not null"`
	Name       string         `json:"name" gorm:"column:name;not null,unique"`
	Shell      string         `json:"shell" gorm:"column:shell;not null"`
	Corn       string         `json:"corn" gorm:"column:cron;not null;default:''"`
	ExecTimes  int            `json:"exec_times" gorm:"column:exec_times;not null;default:0"` // 任务执行次数
	Status     Status         `json:"status" gorm:"column:status;not null"`
	ExecResult string         `json:"exec_result" gorm:"column:exec_result;type:text;not null;default:''"` // 任务执行结果信息
	Servers    ServerFilterV1 `json:"servers" gorm:"column:servers;type:json;not null"`
	SubmitUser string         `json:"submit_user" gorm:"column:submit_user;not null"` // 直接在token中获取
}

func (*ShellTask) TableName

func (s *ShellTask) TableName() string

type ShellTaskRecord

type ShellTaskRecord struct {
	gorm.Model `json:"-"`
	UUID       string `json:"uuid" gorm:"column:uuid;type:varchar(36);unique_index;not null"`
	ExecTimes  int    `json:"exec_times" gorm:"column:exec_times;not null"`
	TaskID     string `json:"task_id" gorm:"column:task_id;not null"`
	TaskName   string `json:"task_name" gorm:"column:task_name;not null"`
	Shell      string `json:"shell" gorm:"column:shell;type:text;not null"`
	ServerIP   string `json:"server_ip" gorm:"column:server_ip;type:varchar(255);not null"`
	ServerName string `json:"server_name" gorm:"column:server_name;type:varchar(255);not null"`
	CostTime   string `json:"cost_time" gorm:"column:cost_time;type:varchar(255);not null"`
	Output     string `json:"output" gorm:"column:output;type:text;not null"`
	IsSuccess  bool   `json:"is_success" gorm:"column:is_success;type:boolean;not null"`
}

ShellTaskRecord 记录执行的日志 使用 TEXT 类型记录日志标准输出,最大支持 1G 内容足够 支持服务器 IP 维度,方便后续统计和查询

func (*ShellTaskRecord) TableName

func (s *ShellTaskRecord) TableName() string

type Status

type Status string

"Pending", "Running", "Success", "Failed", "NotAllSuccess", "Cancelled"

const (
	StatusPending       Status = "Pending"
	StatusRunning       Status = "Running"
	StatusSuccess       Status = "Success"
	StatusFailed        Status = "Failed"
	StatusNotAllSuccess Status = "NotAllSuccess"
	StatusCancelled     Status = "Cancelled"
)

type StringSlice

type StringSlice []string

func (*StringSlice) Scan

func (ss *StringSlice) Scan(src interface{}) error

func (StringSlice) Value

func (ss StringSlice) Value() (driver.Value, error)

type User

type User struct {
	ID             string      `json:"id" gorm:"column:id;primary_key;not null"`
	CreatedAt      *time.Time  `json:"created_at" gorm:"column:created_at"`
	UpdatedAt      *time.Time  `json:"updated_at" gorm:"column:updated_at"`
	IsDeleted      *bool       `json:"is_deleted" gorm:"column:is_deleted;default:false;not null"`
	Username       *string     `json:"username" gorm:"column:username;not null"`
	Passwd         *string     `json:"passwd" gorm:"column:passwd"` // bas64
	Email          *string     `json:"email" gorm:"column:email"`
	DingtalkID     *string     `json:"dingtalk_id" gorm:"column:dingtalk_id"`
	DingtalkDeptID *string     `json:"dingtalk_dept_id" gorm:"column:dingtalk_dept_id"`
	Groups         ArrayString `json:"groups" gorm:"column:groups;type:json"` // 组不在 jms维护这里只需要和机器 tag:Team 匹配即可。
	IsLdap         *bool       `json:"is_ldap" gorm:"column:is_ldap;default:false;not null"`
}

func (User) TableName

func (User) TableName() string

type UserPatchMut

type UserPatchMut struct {
	Groups ArrayString `json:"groups"`
}

type UserRequest

type UserRequest struct {
	Username       *string     `json:"username" binding:"required"`
	Email          *string     `json:"email"`
	Groups         ArrayString `json:"groups"`
	DingtalkDeptID *string     `json:"dingtalk_dept_id"`
	DingtalkID     *string     `json:"dingtalk_id"`
	Passwd         *string     `json:"passwd"`
}

type WithDingtalk

type WithDingtalk struct {
	Enable      bool   `mapstructure:"enable"`
	AppKey      string `mapstructure:"appKey"`
	AppSecret   string `mapstructure:"appSecret"`
	ProcessCode string `mapstructure:"processCode"` // 审批流程编码
}

type WithLdap

type WithLdap struct {
	Enable           bool     `mapstructure:"enable"`
	BindUser         string   `mapstructure:"bindUser"`
	BindPassword     string   `mapstructure:"bindPassword"`
	Host             string   `mapstructure:"host"`
	Port             int      `mapstructure:"port"`
	BaseDN           string   `mapstructure:"baseDN"`
	UserSearchFilter string   `mapstructure:"userSearchFilter"`
	Attributes       []string `mapstructure:"attributes"`
}

type WithPolicy

type WithPolicy struct {
	Enable bool     `mapstructure:"enable"`
	DBFile string   `mapstructure:"dbFile"`
	PG     PGConfig `mapstructure:"pg"`
}

type WithSSHCheck

type WithSSHCheck struct {
	Enable bool     `mapstructure:"enable"`
	Alert  SSHAlert `mapstructure:"alert"`
	IPS    []string `mapstructure:"ips"`
}

type WithVideo

type WithVideo struct {
	Enable   bool   `mapstructure:"enable"`
	Cron     string `mapstructure:"cron"`     // 定时任务默认 "0 0 3 * * *" 表示每天凌晨 3 点触发
	Dir      string `mapstructure:"dir"`      // 日志目录,默认/opt/jms/audit/
	KeepDays int    `mapstructure:"keepDays"` // 保留天数,默认 3 个月
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL