Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Controller] add email ntlm #4098

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion server/controller/db/mysql/migration/rawsql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ CREATE TABLE IF NOT EXISTS go_genesis_process (
vtap_id INTEGER NOT NULL DEFAULT 0,
pid INTEGER NOT NULL,
lcuuid CHAR(64) DEFAULT '',
name TEXT,
name TEXT,
process_name TEXT,
cmd_line TEXT,
user VARCHAR(256) DEFAULT '',
Expand Down Expand Up @@ -2424,6 +2424,9 @@ CREATE TABLE IF NOT EXISTS mail_server (
user TEXT NOT NULL,
password TEXT NOT NULL,
security TEXT Not NULL,
ntlm_enabled int,
ntlm_name TEXT,
ntlm_password TEXT,
lcuuid CHAR(64) DEFAULT ''
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
TRUNCATE TABLE mail_server;
Expand Down
7 changes: 7 additions & 0 deletions server/controller/db/mysql/migration/rawsql/issu/6.3.1.48.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ALTER TABLE mail_server
ADD COLUMN ntlm_enabled int,
ADD COLUMN ntlm_name TEXT,
ADD COLUMN ntlm_password TEXT;

UPDATE db_version SET version='6.3.1.48';

2 changes: 1 addition & 1 deletion server/controller/db/mysql/migration/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ package migration

const (
DB_VERSION_TABLE = "db_version"
DB_VERSION_EXPECTED = "6.3.1.47"
DB_VERSION_EXPECTED = "6.3.1.48"
)
19 changes: 11 additions & 8 deletions server/controller/db/mysql/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -1380,14 +1380,17 @@ func (Plugin) TableName() string {
}

type MailServer struct {
ID int `gorm:"primaryKey;column:id;type:int;not null" json:"ID"`
Status int `gorm:"column:status;type:int;not null" json:"STATUS"`
Host string `gorm:"column:host;type:text;not null" json:"HOST"`
Port int `gorm:"column:port;type:int;not null" json:"PORT"`
User string `gorm:"column:user;type:text;not null" json:"USER"`
Password string `gorm:"column:password;type:text;not null" json:"PASSWORD"`
Security string `gorm:"column:security;type:text;not null" json:"SECURITY"`
Lcuuid string `gorm:"unique;column:lcuuid;type:char(64)" json:"LCUUID"`
ID int `gorm:"primaryKey;column:id;type:int;not null" json:"ID"`
Status int `gorm:"column:status;type:int;not null" json:"STATUS"`
Host string `gorm:"column:host;type:text;not null" json:"HOST"`
Port int `gorm:"column:port;type:int;not null" json:"PORT"`
User string `gorm:"column:user;type:text;not null" json:"USER"`
Password string `gorm:"column:password;type:text;not null" json:"PASSWORD"`
Security string `gorm:"column:security;type:text;not null" json:"SECURITY"`
NtlmEnabled int `gorm:"column:ntlm_enabled;type:int" json:"NTLM_ENABLED"`
NtlmName string `gorm:"column:ntlm_name;type:text" json:"NTLM_NAME"`
NtlmPassword string `gorm:"column:ntlm_password;type:text" json:"NTLM_PASSWORD"`
Lcuuid string `gorm:"unique;column:lcuuid;type:char(64)" json:"LCUUID"`
}

func (MailServer) TableName() string {
Expand Down
24 changes: 15 additions & 9 deletions server/controller/http/service/mail_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ func GetMailServer(filter map[string]interface{}) (resp []model.MailServer, err
}
for _, mail := range mails {
mailResp := model.MailServer{
ID: mail.ID,
Status: mail.Status,
Host: mail.Host,
Port: mail.Port,
User: mail.User,
Password: mail.Password,
Security: mail.Security,
Lcuuid: mail.Lcuuid,
ID: mail.ID,
Status: mail.Status,
Host: mail.Host,
Port: mail.Port,
User: mail.User,
Password: mail.Password,
Security: mail.Security,
NtlmEnabled: mail.NtlmEnabled,
NtlmName: mail.NtlmName,
NtlmPassword: mail.NtlmPassword,
Lcuuid: mail.Lcuuid,
}
response = append(response, mailResp)
}
Expand All @@ -67,6 +70,9 @@ func CreateMailServer(mailCreate model.MailServerCreate) (model.MailServer, erro
mailServer.User = mailCreate.User
mailServer.Password = mailCreate.Password
mailServer.Security = mailCreate.Security
mailServer.NtlmEnabled = mailCreate.NtlmEnabled
mailServer.NtlmName = mailCreate.NtlmName
mailServer.NtlmPassword = mailCreate.NtlmPassword
mailServer.Lcuuid = uuid.New().String()
mysql.Db.Create(&mailServer)

Expand All @@ -88,7 +94,7 @@ func UpdateMailServer(lcuuid string, mailServerUpdate map[string]interface{}) (m

log.Infof("update mailServer(%s) config %v", mailServer.User, mailServerUpdate)

for _, key := range []string{"STATUS", "HOST", "PORT", "USER", "PASSWORD", "SECURITY"} {
for _, key := range []string{"STATUS", "HOST", "PORT", "USER", "PASSWORD", "SECURITY", "NTLM_ENABLED", "NTLM_NAME", "NTLM_PASSWORD"} {
if _, ok := mailServerUpdate[key]; ok {
dbUpdateMap[strings.ToLower(key)] = mailServerUpdate[key]
}
Expand Down
49 changes: 29 additions & 20 deletions server/controller/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,30 +837,39 @@ type Plugin struct {
}

type MailServerCreate struct {
Status int `json:"STATUS"`
Host string `json:"HOST" binding:"required"`
Port int `json:"PORT" binding:"required"`
User string `json:"USER" binding:"required"`
Password string `json:"PASSWORD" binding:"required"`
Security string `json:"SECURITY" binding:"required"`
Status int `json:"STATUS"`
Host string `json:"HOST" binding:"required"`
Port int `json:"PORT" binding:"required"`
User string `json:"USER" binding:"required"`
Password string `json:"PASSWORD" binding:"required"`
NtlmEnabled int `json:"NTLM_ENABLED"`
NtlmName string `json:"NTLM_NAME"`
NtlmPassword string `json:"NTLM_PASSWORD"`
Security string `json:"SECURITY" binding:"required"`
}

type MailServerUpdate struct {
Status int `json:"STATUS"`
Host string `json:"HOST"`
Port int `json:"PORT"`
User string `json:"USER"`
Password string `json:"PASSWORD"`
Security string `json:"SECURITY"`
Status int `json:"STATUS"`
Host string `json:"HOST"`
Port int `json:"PORT"`
User string `json:"USER"`
Password string `json:"PASSWORD"`
NtlmEnabled int `json:"NTLM_ENABLED"`
NtlmName string `json:"NTLM_NAME"`
NtlmPassword string `json:"NTLM_PASSWORD"`
Security string `json:"SECURITY"`
}

type MailServer struct {
ID int `json:"ID"`
Status int `json:"STATUS"`
Host string `json:"HOST"`
Port int `json:"PORT"`
User string `json:"USER"`
Password string `json:"PASSWORD"`
Security string `json:"SECURITY"`
Lcuuid string `json:"LCUUID"`
ID int `json:"ID"`
Status int `json:"STATUS"`
Host string `json:"HOST"`
Port int `json:"PORT"`
User string `json:"USER"`
Password string `json:"PASSWORD"`
Security string `json:"SECURITY"`
NtlmEnabled int `json:"NTLM_ENABLED"`
NtlmName string `json:"NTLM_NAME"`
NtlmPassword string `json:"NTLM_PASSWORD"`
Lcuuid string `json:"LCUUID"`
}
Loading