mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-08-09 01:58:42 +00:00
perf: conn token add remote addr
This commit is contained in:
parent
4e33b5b478
commit
94ff9ee261
@ -0,0 +1,20 @@
|
||||
# Generated by Django 4.1.13 on 2025-08-04 06:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("authentication", "0006_connectiontoken_type"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="connectiontoken",
|
||||
name="remote_addr",
|
||||
field=models.CharField(
|
||||
blank=True, max_length=128, null=True, verbose_name="Remote addr"
|
||||
),
|
||||
),
|
||||
]
|
@ -57,6 +57,9 @@ class ConnectionToken(JMSOrgBaseModel):
|
||||
)
|
||||
face_monitor_token = models.CharField(max_length=128, null=True, blank=True, verbose_name=_("Face monitor token"))
|
||||
is_active = models.BooleanField(default=True, verbose_name=_("Active"))
|
||||
remote_addr = models.CharField(
|
||||
max_length=128, verbose_name=_("Remote addr"), blank=True, null=True
|
||||
)
|
||||
|
||||
type = models.CharField(
|
||||
max_length=16, choices=ConnectionTokenType.choices,
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from rest_framework import serializers
|
||||
|
||||
from common.utils import get_request_ip
|
||||
from common.serializers import CommonModelSerializer
|
||||
from common.serializers.fields import EncryptedField
|
||||
from perms.serializers.permission import ActionChoicesField
|
||||
@ -29,6 +30,7 @@ class ConnectionTokenSerializer(CommonModelSerializer):
|
||||
'is_active', 'is_reusable', 'from_ticket', 'from_ticket_info',
|
||||
'date_expired', 'date_created', 'date_updated', 'created_by',
|
||||
'updated_by', 'org_id', 'org_name', 'face_monitor_token',
|
||||
'remote_addr',
|
||||
]
|
||||
read_only_fields = [
|
||||
# 普通 Token 不支持指定 user
|
||||
@ -52,6 +54,12 @@ class ConnectionTokenSerializer(CommonModelSerializer):
|
||||
def get_user(self, attrs):
|
||||
return self.get_request_user()
|
||||
|
||||
def create(self, validated_data):
|
||||
request = self.context.get('request')
|
||||
if request:
|
||||
validated_data['remote_addr'] = get_request_ip(request)
|
||||
return super().create(validated_data)
|
||||
|
||||
def get_from_ticket_info(self, instance):
|
||||
if not instance.from_ticket:
|
||||
return {}
|
||||
|
@ -205,7 +205,7 @@
|
||||
"SelectCommand": "Please select the command to execute.",
|
||||
"Send command": "Send command",
|
||||
"Send text to all ssh terminals": "Send text to all ssh terminals",
|
||||
"SendCommandPlaceholder": "Input command here..., Enter for new line, Ctrl+Enter to send",
|
||||
"SendCommandPlaceholder": "Input command here, Enter for new line, Ctrl+Enter to send",
|
||||
"Session": "Session",
|
||||
"SessionIsBeingMonitored": "Session is being monitored",
|
||||
"SessionShare": "Session share",
|
||||
@ -283,4 +283,4 @@
|
||||
"success": "Success",
|
||||
"system user": "System user",
|
||||
"user": "User"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user