Skip to content

Commit

Permalink
支持配置goinception认证 (#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
nick2wang authored Dec 8, 2023
1 parent 86b217d commit 79fc811
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def go_inception(request):
result = {"status": 0, "msg": "ok", "data": []}
go_inception_host = request.POST.get("go_inception_host", "")
go_inception_port = request.POST.get("go_inception_port", "")
go_inception_user = request.POST.get("go_inception_user", "")
go_inception_password = request.POST.get("go_inception_password", "")
inception_remote_backup_host = request.POST.get("inception_remote_backup_host", "")
inception_remote_backup_port = request.POST.get("inception_remote_backup_port", "")
inception_remote_backup_user = request.POST.get("inception_remote_backup_user", "")
Expand All @@ -31,6 +33,8 @@ def go_inception(request):
conn = MySQLdb.connect(
host=go_inception_host,
port=int(go_inception_port),
user=go_inception_user,
password=go_inception_password,
charset="utf8mb4",
connect_timeout=5,
)
Expand Down
24 changes: 24 additions & 0 deletions common/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ <h6 style="color:red">注1:备份库的信息仅用于平台获取回滚语句
placeholder="goInception端口" />
</div>
</div>
<div class="form-group">
<label for="go_inception_user"
class="col-sm-4 control-label">GO_INCEPTION_USER</label>
<div class="col-sm-5">
<input type="text" class="form-control"
id="go_inception_user"
key="go_inception_user"
value="{{ config.go_inception_user }}"
placeholder="goInception用户(未启用认证可不填)" />
</div>
</div>
<div class="form-group">
<label for="go_inception_password"
class="col-sm-4 control-label">GO_INCEPTION_PASSWORD</label>
<div class="col-sm-5">
<input type="password" class="form-control"
id="go_inception_password"
key="go_inception_password"
value="{{ config.go_inception_password }}"
placeholder="goInception密码(未启用认证可不填)" />
</div>
</div>
</div>
<div class="form-group">
<label for="inception_remote_backup_host"
Expand Down Expand Up @@ -1430,6 +1452,8 @@ <h5 class="control-label text-bold">当前审批流程:<b id="workflow_auditor
data: {
go_inception_host: $("#go_inception_host").val(),
go_inception_port: $("#go_inception_port").val(),
go_inception_user: $("#go_inception_user").val(),
go_inception_password: $("#go_inception_password").val(),
inception_remote_backup_host: $("#inception_remote_backup_host").val(),
inception_remote_backup_port: $("#inception_remote_backup_port").val(),
inception_remote_backup_user: $("#inception_remote_backup_user").val(),
Expand Down
2 changes: 2 additions & 0 deletions common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ def test_go_inception_check(self, _conn):
data = {
"go_inception_host": "inception",
"go_inception_port": "6669",
"go_inception_user": "",
"go_inception_password": "",
"inception_remote_backup_host": "mysql",
"inception_remote_backup_port": 3306,
"inception_remote_backup_user": "mysql",
Expand Down
4 changes: 4 additions & 0 deletions sql/engines/goinception.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ def get_connection(self, db_name=None):
archer_config = SysConfig()
go_inception_host = archer_config.get("go_inception_host")
go_inception_port = int(archer_config.get("go_inception_port", 4000))
go_inception_user = archer_config.get("go_inception_user", "")
go_inception_password = archer_config.get("go_inception_password", "")
self.conn = MySQLdb.connect(
host=go_inception_host,
port=go_inception_port,
user=go_inception_user,
passwd=go_inception_password,
charset="utf8mb4",
connect_timeout=10,
)
Expand Down
5 changes: 5 additions & 0 deletions sql_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def debug(request):
# 敏感信息处理
secret_keys = [
"inception_remote_backup_password",
"go_inception_password",
"ding_app_secret",
"feishu_app_secret",
"mail_smtp_password",
Expand Down Expand Up @@ -120,6 +121,8 @@ def debug(request):
# Inception和goInception信息
go_inception_host = sys_config.get("go_inception_host")
go_inception_port = sys_config.get("go_inception_port", 0)
go_inception_user = sys_config.get("go_inception_user", "")
go_inception_password = sys_config.get("go_inception_password", "")
inception_remote_backup_host = sys_config.get("inception_remote_backup_host", "")
inception_remote_backup_port = sys_config.get("inception_remote_backup_port", "")
inception_remote_backup_user = sys_config.get("inception_remote_backup_user", "")
Expand All @@ -132,6 +135,8 @@ def debug(request):
goinc_conn = MySQLdb.connect(
host=go_inception_host,
port=int(go_inception_port),
user=go_inception_user,
passwd=go_inception_password,
connect_timeout=1,
cursorclass=MySQLdb.cursors.DictCursor,
)
Expand Down

0 comments on commit 79fc811

Please sign in to comment.