mirror of https://github.com/jumpserver/jumpserver
Merge branch 'pam' of github.com:jumpserver/jumpserver into pam
commit
acbc3e1e44
|
@ -138,10 +138,12 @@ class BaseChangeSecretPushManager(AccountBasePlaybookManager):
|
||||||
|
|
||||||
account.secret = getattr(recorder, 'new_secret', account.secret)
|
account.secret = getattr(recorder, 'new_secret', account.secret)
|
||||||
account.date_updated = timezone.now()
|
account.date_updated = timezone.now()
|
||||||
|
account.date_change_secret = timezone.now()
|
||||||
|
account.change_secret_status = ChangeSecretRecordStatusChoice.success
|
||||||
|
|
||||||
with safe_db_connection():
|
with safe_db_connection():
|
||||||
recorder.save(update_fields=['status', 'date_finished'])
|
recorder.save(update_fields=['status', 'date_finished'])
|
||||||
account.save(update_fields=['secret', 'date_updated'])
|
account.save(update_fields=['secret', 'date_updated', 'date_change_secret', 'change_secret_status'])
|
||||||
|
|
||||||
self.summary['ok_accounts'] += 1
|
self.summary['ok_accounts'] += 1
|
||||||
self.result['ok_accounts'].append(
|
self.result['ok_accounts'].append(
|
||||||
|
|
|
@ -7,6 +7,7 @@ from django_filters import rest_framework as drf_filters
|
||||||
from assets.models import Node
|
from assets.models import Node
|
||||||
from common.drf.filters import BaseFilterSet
|
from common.drf.filters import BaseFilterSet
|
||||||
from common.utils.timezone import local_zero_hour, local_now
|
from common.utils.timezone import local_zero_hour, local_now
|
||||||
|
from .const.automation import ChangeSecretRecordStatusChoice
|
||||||
from .models import Account, GatheredAccount, ChangeSecretRecord, PushSecretRecord, IntegrationApplication
|
from .models import Account, GatheredAccount, ChangeSecretRecord, PushSecretRecord, IntegrationApplication
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,11 +105,11 @@ class AccountFilterSet(BaseFilterSet):
|
||||||
|
|
||||||
if name == "latest_secret_change_failed":
|
if name == "latest_secret_change_failed":
|
||||||
queryset = queryset.filter(date_change_secret__gt=date).exclude(
|
queryset = queryset.filter(date_change_secret__gt=date).exclude(
|
||||||
change_secret_status="ok"
|
change_secret_status=ChangeSecretRecordStatusChoice.success
|
||||||
)
|
)
|
||||||
|
|
||||||
if kwargs:
|
if kwargs:
|
||||||
queryset = queryset.filter(date_last_login__gte=date)
|
queryset = queryset.filter(**kwargs)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from simple_history.models import HistoricalRecords
|
from simple_history.models import HistoricalRecords
|
||||||
|
|
||||||
|
@ -167,6 +168,10 @@ class Account(AbsConnectivity, LabeledMixin, BaseAccount):
|
||||||
|
|
||||||
return escape(value)
|
return escape(value)
|
||||||
|
|
||||||
|
def update_last_login_date(self):
|
||||||
|
self.date_last_login = timezone.now()
|
||||||
|
self.save(update_fields=['date_last_login'])
|
||||||
|
|
||||||
|
|
||||||
def replace_history_model_with_mixin():
|
def replace_history_model_with_mixin():
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -11,6 +11,7 @@ from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from accounts.models import Account
|
||||||
from assets.models import Asset
|
from assets.models import Asset
|
||||||
from common.const.signals import OP_LOG_SKIP_SIGNAL
|
from common.const.signals import OP_LOG_SKIP_SIGNAL
|
||||||
from common.utils import get_object_or_none, lazyproperty
|
from common.utils import get_object_or_none, lazyproperty
|
||||||
|
@ -125,6 +126,10 @@ class Session(OrgModelMixin):
|
||||||
def user_obj(self):
|
def user_obj(self):
|
||||||
return User.objects.get(id=self.user_id)
|
return User.objects.get(id=self.user_id)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def account_obj(self):
|
||||||
|
return get_object_or_none(Account, pk=self.account_id)
|
||||||
|
|
||||||
def can_replay(self):
|
def can_replay(self):
|
||||||
return self.has_replay
|
return self.has_replay
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,11 @@ from terminal.models import Session
|
||||||
|
|
||||||
|
|
||||||
@receiver(pre_save, sender=Session)
|
@receiver(pre_save, sender=Session)
|
||||||
def on_session_pre_save(sender, instance,**kwargs):
|
def on_session_pre_save(sender, instance, **kwargs):
|
||||||
if instance.need_update_cmd_amount:
|
if instance.need_update_cmd_amount:
|
||||||
instance.cmd_amount = instance.compute_command_amount()
|
instance.cmd_amount = instance.compute_command_amount()
|
||||||
|
if instance.account_obj:
|
||||||
|
instance.account_obj.update_last_login_date()
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=Session)
|
@receiver(post_save, sender=Session)
|
||||||
|
@ -16,4 +18,3 @@ def on_session_finished(sender, instance: Session, created, **kwargs):
|
||||||
return
|
return
|
||||||
# 清理一次可能因 task 未执行的缓存数据
|
# 清理一次可能因 task 未执行的缓存数据
|
||||||
Session.unlock_session(instance.id)
|
Session.unlock_session(instance.id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue