-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增选择本地文件上传密钥,上传后将密钥信息保存到数据库,连接时从数据库读取 (#1303)
* # 新增 pkey 目录挂载 * # 修改显示名称,引导用户填写 pkey 文件的名称 * # 新增 ssh tunnel keys 默认存放文件夹 * # 将数据库的 pkey 名字与 pkey 目录拼接 * # 后台 django q 菜单改为中文 * # 对应增加 pkey 文本框 * # 通过 form 读取秘钥信息 * # 新增 pkey 字段存储密钥信息 * # 改为使用 pkey 文件对象进行登录 * # 新增 pkey 字段存储密钥信息 * # * # 改为传入 pkey * # 新增本地保存 pkey 的路径 * Update models.py * # 设置为相对路径 * # * # * # 修复当填写了秘钥路径,秘钥文件不存在时的异常 * # pkey 字段改为 EncryptedTextField * # ssh 隧道功能修改 Co-authored-by: 小圈圈 <rtttte@qq.com>
- Loading branch information
Showing
8 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/python | ||
# -*- coding:utf-8 -*- | ||
""" | ||
--------------------------------------------------------- | ||
@project: issacmarkArchery | ||
@file: form | ||
@date: 2021/12/30 17:43 | ||
@author: mayp | ||
--------------------------------------------------------- | ||
""" | ||
from django.forms import ModelForm, Textarea | ||
from sql.models import Tunnel | ||
from django.core.exceptions import ValidationError | ||
|
||
|
||
class TunnelForm(ModelForm): | ||
class Meta: | ||
model = Tunnel | ||
fields = "__all__" | ||
widgets = { | ||
'PKey': Textarea(attrs={'cols': 40, 'rows': 8}), | ||
} | ||
|
||
def clean(self): | ||
cleaned_data = super().clean() | ||
if cleaned_data.get('pkey_path'): | ||
try: | ||
pkey_path = cleaned_data.get('pkey_path').read() | ||
if pkey_path: | ||
cleaned_data['pkey'] = str(pkey_path, 'utf-8').replace(r'\r', '').replace(r'\n', '') | ||
except IOError: | ||
raise ValidationError("秘钥文件不存在, 请勾选秘钥路径的清除选项再进行保存") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters