-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
新增选择本地文件上传密钥,上传后将密钥信息保存到数据库,连接时从数据库读取 #1303
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1303 +/- ##
==========================================
- Coverage 78.00% 77.94% -0.07%
==========================================
Files 79 80 +1
Lines 12236 12265 +29
==========================================
+ Hits 9545 9560 +15
- Misses 2691 2705 +14
Continue to review full report at Codecov.
|
这个好像只适用于单机部署, 多实例的时候怎么办? |
有道理,我再改改 |
# Conflicts: # sql/models.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感谢贡献,这个还需要补充下变更sql,以及如何做到平滑升级的说明
顺便问下这个pr主要解决的问题是什么,因为这块我个人没有使用,可能不了解痛点,再次感谢
sql/models.py
Outdated
@@ -853,28 +864,3 @@ class Meta: | |||
index_together = ('hostname_max', 'ts_min') | |||
verbose_name = u'慢日志明细' | |||
verbose_name_plural = u'慢日志明细' | |||
|
|||
|
|||
class AuditEntry(models.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块应该是其他pr合并到主干的,注意冲突处理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原来的方式:将密钥上传至 archery 部署的服务器目录,如果是docker部署的还需要传到容器卷挂载的目录下,如 downloads logs这种目录里,然后在后台天上这个目录的绝对路径,当部署多实例的时候就无法使用了,而且使用起来也不是特别便捷
修改后:由后台页面的上传按钮直接上传到keys目录,然后读取pkey的内容写入数据库的pkey字段,实际上每次连接都是从数据库获取pkey来连接
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前使用这个功能的用户应该都是把密钥上传到了部署 archery 服务的服务器上,升级时需要把密钥下载到本地,更新版本后编辑对应条目,重新选择文件上传即可。
变更sql:
ALTER TABLE archery
.ssh_tunnel
ADD COLUMN pkey
longtext NULL AFTER password
;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前使用这个功能的用户应该都是把密钥上传到了部署 archery 服务的服务器上,升级时需要把密钥下载到本地,更新版本后编辑对应条目,重新选择文件上传即可。 变更sql: ALTER TABLE
archery
.ssh_tunnel
ADD COLUMNpkey
longtext NULL AFTERpassword
;
辛苦增加到1.8.3的sql文件中
sql/models.py
Outdated
@@ -99,14 +103,21 @@ class Tunnel(models.Model): | |||
port = models.IntegerField('端口', default=0) | |||
user = fields.EncryptedCharField(verbose_name='用户名', max_length=200, default='', blank=True, null=True) | |||
password = fields.EncryptedCharField(verbose_name='密码', max_length=300, default='', blank=True, null=True) | |||
pkey_path = fields.EncryptedCharField(verbose_name='密钥地址', max_length=300, default='', blank=True, null=True) | |||
pkey = models.TextField(verbose_name="密钥", blank=True, null=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否也采取加密存储的形式
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
密钥长度太长了,所以用了这个
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加密组件也支持text,可以调整下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯 改成 EncryptedTextField 了
# Conflicts: # src/init_sql/v1.8.3.sql
@@ -13,3 +13,6 @@ CREATE TABLE `audit_log` ( | |||
-- 新增my2sql菜单权限 | |||
set @content_type_id=(select id from django_content_type where app_label='sql' and model='permission'); | |||
INSERT INTO auth_permission (name, content_type_id, codename) VALUES ('菜单 My2SQL', @content_type_id, 'menu_my2sql'); | |||
|
|||
-- ssh 隧道功能修改 | |||
ALTER TABLE `ssh_tunnel` ADD COLUMN pkey longtext NULL AFTER password DEFAULT CHARSET=utf8mb4 COMMENT='密钥信息'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个语句存在语法错误,还有pkey_path变成了filefield,确认下是否需要调整字段格式
新增选择本地文件上传密钥,上传后将密钥信息保存到数据库,连接时从数据库读取