mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-10 03:32:57 +08:00
Add sslMode for syncer
This commit is contained in:
@@ -37,12 +37,13 @@ type Syncer struct {
|
|||||||
|
|
||||||
Organization string `xorm:"varchar(100)" json:"organization"`
|
Organization string `xorm:"varchar(100)" json:"organization"`
|
||||||
Type string `xorm:"varchar(100)" json:"type"`
|
Type string `xorm:"varchar(100)" json:"type"`
|
||||||
|
DatabaseType string `xorm:"varchar(100)" json:"databaseType"`
|
||||||
|
SslMode string `xorm:"varchar(100)" json:"sslMode"`
|
||||||
|
|
||||||
Host string `xorm:"varchar(100)" json:"host"`
|
Host string `xorm:"varchar(100)" json:"host"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
User string `xorm:"varchar(100)" json:"user"`
|
User string `xorm:"varchar(100)" json:"user"`
|
||||||
Password string `xorm:"varchar(100)" json:"password"`
|
Password string `xorm:"varchar(100)" json:"password"`
|
||||||
DatabaseType string `xorm:"varchar(100)" json:"databaseType"`
|
|
||||||
Database string `xorm:"varchar(100)" json:"database"`
|
Database string `xorm:"varchar(100)" json:"database"`
|
||||||
Table string `xorm:"varchar(100)" json:"table"`
|
Table string `xorm:"varchar(100)" json:"table"`
|
||||||
TableColumns []*TableColumn `xorm:"mediumtext" json:"tableColumns"`
|
TableColumns []*TableColumn `xorm:"mediumtext" json:"tableColumns"`
|
||||||
|
@@ -185,7 +185,11 @@ func (syncer *Syncer) initAdapter() {
|
|||||||
if syncer.DatabaseType == "mssql" {
|
if syncer.DatabaseType == "mssql" {
|
||||||
dataSourceName = fmt.Sprintf("sqlserver://%s:%s@%s:%d?database=%s", syncer.User, syncer.Password, syncer.Host, syncer.Port, syncer.Database)
|
dataSourceName = fmt.Sprintf("sqlserver://%s:%s@%s:%d?database=%s", syncer.User, syncer.Password, syncer.Host, syncer.Port, syncer.Database)
|
||||||
} else if syncer.DatabaseType == "postgres" {
|
} else if syncer.DatabaseType == "postgres" {
|
||||||
dataSourceName = fmt.Sprintf("user=%s password=%s host=%s port=%d sslmode=disable dbname=%s", syncer.User, syncer.Password, syncer.Host, syncer.Port, syncer.Database)
|
sslMode := "disable"
|
||||||
|
if syncer.SslMode != "" {
|
||||||
|
sslMode = syncer.SslMode
|
||||||
|
}
|
||||||
|
dataSourceName = fmt.Sprintf("user=%s password=%s host=%s port=%d sslmode=%s dbname=%s", syncer.User, syncer.Password, syncer.Host, syncer.Port, sslMode, syncer.Database)
|
||||||
} else {
|
} else {
|
||||||
dataSourceName = fmt.Sprintf("%s:%s@tcp(%s:%d)/", syncer.User, syncer.Password, syncer.Host, syncer.Port)
|
dataSourceName = fmt.Sprintf("%s:%s@tcp(%s:%d)/", syncer.User, syncer.Password, syncer.Host, syncer.Port)
|
||||||
}
|
}
|
||||||
|
@@ -239,7 +239,14 @@ class SyncerEditPage extends React.Component {
|
|||||||
{Setting.getLabel(i18next.t("syncer:Database type"), i18next.t("syncer:Database type - Tooltip"))} :
|
{Setting.getLabel(i18next.t("syncer:Database type"), i18next.t("syncer:Database type - Tooltip"))} :
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={22} >
|
<Col span={22} >
|
||||||
<Select virtual={false} style={{width: "100%"}} value={this.state.syncer.databaseType} onChange={(value => {this.updateSyncerField("databaseType", value);})}>
|
<Select virtual={false} style={{width: "100%"}} value={this.state.syncer.databaseType} onChange={(value => {
|
||||||
|
this.updateSyncerField("databaseType", value);
|
||||||
|
if (value === "postgres") {
|
||||||
|
this.updateSyncerField("sslMode", "disable");
|
||||||
|
} else {
|
||||||
|
this.updateSyncerField("sslMode", "");
|
||||||
|
}
|
||||||
|
})}>
|
||||||
{
|
{
|
||||||
[
|
[
|
||||||
{id: "mysql", name: "MySQL"},
|
{id: "mysql", name: "MySQL"},
|
||||||
@@ -247,11 +254,34 @@ class SyncerEditPage extends React.Component {
|
|||||||
{id: "mssql", name: "SQL Server"},
|
{id: "mssql", name: "SQL Server"},
|
||||||
{id: "oracle", name: "Oracle"},
|
{id: "oracle", name: "Oracle"},
|
||||||
{id: "sqlite3", name: "Sqlite 3"},
|
{id: "sqlite3", name: "Sqlite 3"},
|
||||||
].map((databaseType, index) => <Option key={index} value={databaseType.id}>{databaseType.name}</Option>)
|
].map((item, index) => <Option key={index} value={item.id}>{item.name}</Option>)
|
||||||
}
|
}
|
||||||
</Select>
|
</Select>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
{
|
||||||
|
this.state.syncer.databaseType !== "postgres" ? null : (
|
||||||
|
<Row style={{marginTop: "20px"}} >
|
||||||
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||||
|
{Setting.getLabel(i18next.t("syncer:SSL mode"), i18next.t("syncer:SSL mode - Tooltip"))} :
|
||||||
|
</Col>
|
||||||
|
<Col span={22} >
|
||||||
|
<Select virtual={false} style={{width: "100%"}} value={this.state.syncer.sslMode} onChange={(value => {this.updateSyncerField("sslMode", value);})}>
|
||||||
|
{
|
||||||
|
[
|
||||||
|
{id: "disable", name: "disable"},
|
||||||
|
// {id: "allow", name: "allow"},
|
||||||
|
// {id: "prefer", name: "prefer"},
|
||||||
|
{id: "require", name: "require"},
|
||||||
|
{id: "verify-ca", name: "verify-ca"},
|
||||||
|
{id: "verify-full", name: "verify-full"},
|
||||||
|
].map((item, index) => <Option key={index} value={item.id}>{item.name}</Option>)
|
||||||
|
}
|
||||||
|
</Select>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
}
|
||||||
<Row style={{marginTop: "20px"}} >
|
<Row style={{marginTop: "20px"}} >
|
||||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||||
{Setting.getLabel(i18next.t("provider:Host"), i18next.t("provider:Host - Tooltip"))} :
|
{Setting.getLabel(i18next.t("provider:Host"), i18next.t("provider:Host - Tooltip"))} :
|
||||||
|
Reference in New Issue
Block a user