mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-12-24 13:02:37 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b30e329ab | ||
|
|
3dc853c7f2 | ||
|
|
932aed97d3 | ||
|
|
c464e95a21 | ||
|
|
0f0af19d49 | ||
|
|
6a54ff8714 | ||
|
|
1e0489bb96 | ||
|
|
980ddcd833 |
@@ -6,8 +6,8 @@ from rest_framework.status import HTTP_200_OK
|
||||
|
||||
from accounts import serializers
|
||||
from accounts.filters import AccountFilterSet
|
||||
from accounts.models import Account
|
||||
from accounts.mixins import AccountRecordViewLogMixin
|
||||
from accounts.models import Account
|
||||
from assets.models import Asset, Node
|
||||
from common.api.mixin import ExtraFilterFieldsMixin
|
||||
from common.permissions import UserConfirmation, ConfirmType, IsValidUser
|
||||
@@ -57,19 +57,19 @@ class AccountViewSet(OrgBulkModelViewSet):
|
||||
permission_classes=[IsValidUser]
|
||||
)
|
||||
def username_suggestions(self, request, *args, **kwargs):
|
||||
asset_ids = request.data.get('assets')
|
||||
node_ids = request.data.get('nodes')
|
||||
username = request.data.get('username')
|
||||
asset_ids = request.data.get('assets', [])
|
||||
node_ids = request.data.get('nodes', [])
|
||||
username = request.data.get('username', '')
|
||||
|
||||
assets = Asset.objects.all()
|
||||
if asset_ids:
|
||||
assets = assets.filter(id__in=asset_ids)
|
||||
accounts = Account.objects.all()
|
||||
if node_ids:
|
||||
nodes = Node.objects.filter(id__in=node_ids)
|
||||
node_asset_ids = Node.get_nodes_all_assets(*nodes).values_list('id', flat=True)
|
||||
assets = assets.filter(id__in=set(list(asset_ids) + list(node_asset_ids)))
|
||||
asset_ids.extend(node_asset_ids)
|
||||
|
||||
if asset_ids:
|
||||
accounts = accounts.filter(asset_id__in=list(set(asset_ids)))
|
||||
|
||||
accounts = Account.objects.filter(asset__in=assets)
|
||||
if username:
|
||||
accounts = accounts.filter(username__icontains=username)
|
||||
usernames = list(accounts.values_list('username', flat=True).distinct()[:10])
|
||||
|
||||
@@ -38,7 +38,8 @@ class VaultManagerMixin(models.Manager):
|
||||
return objs
|
||||
|
||||
def bulk_update(self, objs, fields, batch_size=None):
|
||||
objs = super().bulk_update(objs, fields, batch_size=batch_size)
|
||||
fields = ["_secret" if field == "secret" else field for field in fields]
|
||||
super().bulk_update(objs, fields, batch_size=batch_size)
|
||||
for obj in objs:
|
||||
post_save.send(obj.__class__, instance=obj, created=False)
|
||||
return objs
|
||||
|
||||
@@ -107,8 +107,9 @@ def create_app_nodes(apps, org_id):
|
||||
'key': next_key, 'value': name, 'parent_key': parent_key,
|
||||
'full_value': full_value, 'org_id': org_id
|
||||
}
|
||||
node, created = node_model.objects.get_or_create(
|
||||
node, __ = node_model.objects.get_or_create(
|
||||
defaults=defaults, value=name, org_id=org_id,
|
||||
parent_key=parent_key
|
||||
)
|
||||
node.parent = parent
|
||||
return node
|
||||
|
||||
@@ -36,7 +36,9 @@ def send_mail_async(*args, **kwargs):
|
||||
args[0] = (settings.EMAIL_SUBJECT_PREFIX or '') + args[0]
|
||||
from_email = settings.EMAIL_FROM or settings.EMAIL_HOST_USER
|
||||
args.insert(2, from_email)
|
||||
args = tuple(args)
|
||||
|
||||
args[3] = [mail for mail in args[3] if mail != 'admin@mycomany.com']
|
||||
args = tuple(args)
|
||||
|
||||
try:
|
||||
return send_mail(*args, **kwargs)
|
||||
@@ -50,6 +52,7 @@ def send_mail_attachment_async(subject, message, recipient_list, attachment_list
|
||||
attachment_list = []
|
||||
from_email = settings.EMAIL_FROM or settings.EMAIL_HOST_USER
|
||||
subject = (settings.EMAIL_SUBJECT_PREFIX or '') + subject
|
||||
recipient_list = [mail for mail in recipient_list if mail != 'admin@mycomany.com']
|
||||
email = EmailMultiAlternatives(
|
||||
subject=subject,
|
||||
body=message,
|
||||
|
||||
@@ -162,7 +162,7 @@ class Applet(JMSBaseModel):
|
||||
for host_id in using_host_ids.values():
|
||||
counts[host_id] += 1
|
||||
|
||||
hosts = list(sorted(hosts, key=lambda h: counts[h.id]))
|
||||
hosts = list(sorted(hosts, key=lambda h: counts[str(h.id)]))
|
||||
return hosts[0]
|
||||
|
||||
def select_host(self, user, asset):
|
||||
|
||||
18
poetry.lock
generated
18
poetry.lock
generated
@@ -1,4 +1,4 @@
|
||||
# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "adal"
|
||||
@@ -2655,14 +2655,8 @@ files = [
|
||||
[package.dependencies]
|
||||
google-auth = ">=2.14.1,<3.0.dev0"
|
||||
googleapis-common-protos = ">=1.56.2,<2.0.dev0"
|
||||
grpcio = [
|
||||
{version = ">=1.33.2,<2.0dev", optional = true, markers = "extra == \"grpc\""},
|
||||
{version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
||||
]
|
||||
grpcio-status = [
|
||||
{version = ">=1.33.2,<2.0.dev0", optional = true, markers = "extra == \"grpc\""},
|
||||
{version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""},
|
||||
]
|
||||
grpcio = {version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}
|
||||
grpcio-status = {version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}
|
||||
protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<5.0.0.dev0"
|
||||
requests = ">=2.18.0,<3.0.0.dev0"
|
||||
|
||||
@@ -3345,12 +3339,12 @@ reference = "tsinghua"
|
||||
|
||||
[[package]]
|
||||
name = "jms-storage"
|
||||
version = "0.0.51"
|
||||
version = "0.0.52"
|
||||
description = "Jumpserver storage python sdk tools"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
files = [
|
||||
{file = "jms-storage-0.0.51.tar.gz", hash = "sha256:47a50ac4d952a21693b0e2f926f42fa0d02bc1fa8e507a8284059743b2b81911"},
|
||||
{file = "jms-storage-0.0.52.tar.gz", hash = "sha256:15303281a1d1a3ac24a5a9fb0d78abda3aa1f752590aab867923647a485ccfbd"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -7276,4 +7270,4 @@ reference = "tsinghua"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "b7d8e793f247e91e1bd22404559ed495e619fe691fa92712cacf7bd146c0eb8f"
|
||||
content-hash = "bf72acdbac5e62c239033fd629835ad30788a3fcb07ac9a2dc2f15f321da6c30"
|
||||
|
||||
@@ -47,7 +47,7 @@ pynacl = "1.5.0"
|
||||
python-dateutil = "2.8.2"
|
||||
pyyaml = "6.0.1"
|
||||
requests = "2.31.0"
|
||||
jms-storage = "0.0.51"
|
||||
jms-storage = "0.0.52"
|
||||
simplejson = "3.19.1"
|
||||
six = "1.16.0"
|
||||
sshtunnel = "0.4.0"
|
||||
|
||||
Reference in New Issue
Block a user