mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-05 09:21:02 +00:00
feat: 账号密钥用vault储存 (#10830)
* feat: 账号密钥用vault储存 * perf: 优化 Vault * perf: 重构 Vault Backend 设计架构 (未完成) * perf: 重构 Vault Backend 设计架构 (未完成2) * perf: 重构 Vault Backend 设计架构 (未完成3) * perf: 重构 Vault Backend 设计架构 (未完成4) * perf: 重构 Vault Backend 设计架构 (未完成5) * perf: 重构 Vault Backend 设计架构 (已完成) * perf: 重构 Vault Backend 设计架构 (已完成) * perf: 重构 Vault Backend 设计架构 (已完成) * perf: 小优化 * perf: 优化 --------- Co-authored-by: feng <1304903146@qq.com> Co-authored-by: Bai <baijiangjie@gmail.com> Co-authored-by: feng626 <57284900+feng626@users.noreply.github.com>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from contextlib import contextmanager
|
||||
|
||||
from django.db import connections
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from common.utils import get_logger
|
||||
from common.utils import get_logger, signer, crypto
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
@@ -55,3 +56,19 @@ def safe_db_connection():
|
||||
close_old_connections()
|
||||
yield
|
||||
close_old_connections()
|
||||
|
||||
|
||||
class Encryptor:
|
||||
def __init__(self, value):
|
||||
self.value = force_text(value)
|
||||
|
||||
def decrypt(self):
|
||||
plain_value = crypto.decrypt(self.value)
|
||||
|
||||
# 如果没有解开,使用原来的signer解密
|
||||
if not plain_value:
|
||||
plain_value = signer.unsign(self.value) or ""
|
||||
return plain_value
|
||||
|
||||
def encrypt(self):
|
||||
return crypto.encrypt(self.value)
|
||||
|
Reference in New Issue
Block a user