mirror of https://github.com/jumpserver/jumpserver
perf: 修改完冲突了
parent
2168610ffe
commit
daf279304a
|
@ -1,37 +0,0 @@
|
||||||
# Generated by Django 3.2.14 on 2022-11-29 05:14
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
('assets', '0113_alter_accounttemplate_options'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='database',
|
|
||||||
name='allow_invalid_cert',
|
|
||||||
field=models.BooleanField(default=False, verbose_name='Allow invalid cert'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='database',
|
|
||||||
name='ca_cert',
|
|
||||||
field=models.TextField(blank=True, verbose_name='CA cert'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='database',
|
|
||||||
name='client_cert',
|
|
||||||
field=models.TextField(blank=True, verbose_name='Client cert'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='database',
|
|
||||||
name='client_key',
|
|
||||||
field=models.TextField(blank=True, verbose_name='Client key'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='database',
|
|
||||||
name='use_ssl',
|
|
||||||
field=models.BooleanField(default=False, verbose_name='Use SSL'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,12 +1,9 @@
|
||||||
# Generated by Django 2.1.7 on 2019-07-29 06:23
|
# Generated by Django 2.1.7 on 2019-07-29 06:23
|
||||||
|
|
||||||
import datetime
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
from django.utils.timezone import utc
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('authentication', '0001_initial'),
|
('authentication', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
@ -15,7 +12,7 @@ class Migration(migrations.Migration):
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='accesskey',
|
model_name='accesskey',
|
||||||
name='date_created',
|
name='date_created',
|
||||||
field=models.DateTimeField(auto_now_add=True, default=datetime.datetime(2019, 7, 29, 6, 23, 54, 115123, tzinfo=utc), verbose_name='Date created'),
|
field=models.DateTimeField(auto_now_add=True),
|
||||||
preserve_default=False,
|
preserve_default=False,
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import uuid
|
import uuid
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
import common.db.models
|
||||||
|
|
||||||
|
|
||||||
class AccessKey(models.Model):
|
class AccessKey(models.Model):
|
||||||
|
@ -11,7 +13,7 @@ class AccessKey(models.Model):
|
||||||
secret = models.UUIDField(verbose_name='AccessKeySecret',
|
secret = models.UUIDField(verbose_name='AccessKeySecret',
|
||||||
default=uuid.uuid4, editable=False)
|
default=uuid.uuid4, editable=False)
|
||||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='User',
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='User',
|
||||||
on_delete=models.CASCADE, related_name='access_keys')
|
on_delete=common.db.models.CASCADE_SIGNAL_SKIP, related_name='access_keys')
|
||||||
is_active = models.BooleanField(default=True, verbose_name=_('Active'))
|
is_active = models.BooleanField(default=True, verbose_name=_('Active'))
|
||||||
date_created = models.DateTimeField(auto_now_add=True)
|
date_created = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import uuid
|
import uuid
|
||||||
from django.utils.translation import ugettext_lazy as _
|
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from common.db.models import BaseCreateUpdateModel
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
from common.db.models import BaseCreateUpdateModel, CASCADE_SIGNAL_SKIP
|
||||||
|
|
||||||
|
|
||||||
class SSOToken(BaseCreateUpdateModel):
|
class SSOToken(BaseCreateUpdateModel):
|
||||||
|
@ -12,7 +13,8 @@ class SSOToken(BaseCreateUpdateModel):
|
||||||
"""
|
"""
|
||||||
authkey = models.UUIDField(primary_key=True, default=uuid.uuid4, verbose_name=_('Token'))
|
authkey = models.UUIDField(primary_key=True, default=uuid.uuid4, verbose_name=_('Token'))
|
||||||
expired = models.BooleanField(default=False, verbose_name=_('Expired'))
|
expired = models.BooleanField(default=False, verbose_name=_('Expired'))
|
||||||
user = models.ForeignKey('users.User', on_delete=models.CASCADE, verbose_name=_('User'), db_constraint=False)
|
user = models.ForeignKey('users.User', on_delete=CASCADE_SIGNAL_SKIP, verbose_name=_('User'),
|
||||||
|
db_constraint=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('SSO token')
|
verbose_name = _('SSO token')
|
||||||
|
|
|
@ -7,8 +7,8 @@ from django.db import models
|
||||||
from django.utils.encoding import force_text
|
from django.utils.encoding import force_text
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from common.utils import signer, crypto
|
|
||||||
from common.local import add_encrypted_field_set
|
from common.local import add_encrypted_field_set
|
||||||
|
from common.utils import signer, crypto
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"JsonMixin",
|
"JsonMixin",
|
||||||
|
@ -131,7 +131,7 @@ class EncryptMixin:
|
||||||
return signer.unsign(value) or ""
|
return signer.unsign(value) or ""
|
||||||
|
|
||||||
def from_db_value(self, value, expression, connection, context=None):
|
def from_db_value(self, value, expression, connection, context=None):
|
||||||
if not value:
|
if value is None:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
value = force_text(value)
|
value = force_text(value)
|
||||||
|
@ -148,7 +148,7 @@ class EncryptMixin:
|
||||||
return plain_value
|
return plain_value
|
||||||
|
|
||||||
def get_prep_value(self, value):
|
def get_prep_value(self, value):
|
||||||
if not value:
|
if value is None:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
# 先 json 再解密
|
# 先 json 再解密
|
||||||
|
|
|
@ -13,6 +13,9 @@ class UserMsgSubscription(JMSBaseModel):
|
||||||
)
|
)
|
||||||
receive_backends = models.JSONField(default=list, verbose_name=_('receive backend'))
|
receive_backends = models.JSONField(default=list, verbose_name=_('receive backend'))
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = _('User message')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _('{} subscription').format(self.user)
|
return _('{} subscription').format(self.user)
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ class Migration(migrations.Migration):
|
||||||
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
|
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
|
||||||
('org_id',
|
('org_id',
|
||||||
models.CharField(blank=True, db_index=True, default='', max_length=36, verbose_name='Organization')),
|
models.CharField(blank=True, db_index=True, default='', max_length=36, verbose_name='Organization')),
|
||||||
('is_periodic', models.BooleanField(default=False)),
|
('is_periodic', models.BooleanField(default=False, verbose_name='Periodic perform')),
|
||||||
('interval', models.IntegerField(blank=True, default=24, null=True, verbose_name='Cycle perform')),
|
('interval', models.IntegerField(blank=True, default=24, null=True, verbose_name='Cycle perform')),
|
||||||
('crontab', models.CharField(blank=True, max_length=128, null=True, verbose_name='Regularly perform')),
|
('crontab', models.CharField(blank=True, max_length=128, null=True, verbose_name='Regularly perform')),
|
||||||
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
# Generated by Django 2.2.5 on 2019-11-22 10:07
|
# Generated by Django 2.2.5 on 2019-11-22 10:07
|
||||||
|
|
||||||
import common.db.fields
|
|
||||||
from django.db import migrations, models
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
import common.db.fields
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('terminal', '0015_auto_20190923_1529'),
|
('terminal', '0015_auto_20190923_1529'),
|
||||||
]
|
]
|
||||||
|
@ -20,7 +21,8 @@ class Migration(migrations.Migration):
|
||||||
('date_created', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Date created')),
|
('date_created', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Date created')),
|
||||||
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
|
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
|
||||||
('name', models.CharField(max_length=32, unique=True, verbose_name='Name')),
|
('name', models.CharField(max_length=32, unique=True, verbose_name='Name')),
|
||||||
('type', models.CharField(choices=[('null', 'Null'), ('server', 'Server'), ('es', 'Elasticsearch')], default='server', max_length=16, verbose_name='Type')),
|
('type', models.CharField(choices=[('null', 'Null'), ('server', 'Server'), ('es', 'Elasticsearch')],
|
||||||
|
default='server', max_length=16, verbose_name='Type')),
|
||||||
('meta', common.db.fields.EncryptJsonDictTextField(default={})),
|
('meta', common.db.fields.EncryptJsonDictTextField(default={})),
|
||||||
('comment', models.TextField(blank=True, default='', max_length=128, verbose_name='Comment')),
|
('comment', models.TextField(blank=True, default='', max_length=128, verbose_name='Comment')),
|
||||||
],
|
],
|
||||||
|
@ -36,7 +38,10 @@ class Migration(migrations.Migration):
|
||||||
('date_created', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Date created')),
|
('date_created', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Date created')),
|
||||||
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
|
('date_updated', models.DateTimeField(auto_now=True, verbose_name='Date updated')),
|
||||||
('name', models.CharField(max_length=32, unique=True, verbose_name='Name')),
|
('name', models.CharField(max_length=32, unique=True, verbose_name='Name')),
|
||||||
('type', models.CharField(choices=[('null', 'Null'), ('server', 'Server'), ('s3', 'S3'), ('ceph', 'Ceph'), ('swift', 'Swift'), ('oss', 'OSS'), ('azure', 'Azure')], default='server', max_length=16, verbose_name='Type')),
|
('type', models.CharField(
|
||||||
|
choices=[('null', 'Null'), ('server', 'Server'), ('s3', 'S3'), ('ceph', 'Ceph'), ('swift', 'Swift'),
|
||||||
|
('oss', 'OSS'), ('azure', 'Azure')], default='server', max_length=16,
|
||||||
|
verbose_name='Type')),
|
||||||
('meta', common.db.fields.EncryptJsonDictTextField(default={})),
|
('meta', common.db.fields.EncryptJsonDictTextField(default={})),
|
||||||
('comment', models.TextField(blank=True, default='', max_length=128, verbose_name='Comment')),
|
('comment', models.TextField(blank=True, default='', max_length=128, verbose_name='Comment')),
|
||||||
],
|
],
|
||||||
|
|
|
@ -31,14 +31,16 @@ def init_storage_data(model):
|
||||||
name='null', type='null',
|
name='null', type='null',
|
||||||
defaults={
|
defaults={
|
||||||
'name': 'null', 'type': 'null',
|
'name': 'null', 'type': 'null',
|
||||||
'comment': "Do not save"
|
'comment': "Do not save",
|
||||||
|
'meta': '{}'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
model.objects.update_or_create(
|
model.objects.update_or_create(
|
||||||
name='default', type='server',
|
name='default', type='server',
|
||||||
defaults={
|
defaults={
|
||||||
'name': 'default', 'type': 'server',
|
'name': 'default', 'type': 'server',
|
||||||
'comment': "Store locally"
|
'comment': "Store locally",
|
||||||
|
'meta': '{}'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -55,6 +57,7 @@ def migrate_command_storage(apps, schema_editor):
|
||||||
tp = meta.pop("TYPE")
|
tp = meta.pop("TYPE")
|
||||||
if not tp or name in ['default', 'null']:
|
if not tp or name in ['default', 'null']:
|
||||||
continue
|
continue
|
||||||
|
print("- command storage Meta: ", meta)
|
||||||
model.objects.create(name=name, type=tp, meta=meta)
|
model.objects.create(name=name, type=tp, meta=meta)
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,7 +77,6 @@ def migrate_replay_storage(apps, schema_editor):
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('settings', '0001_initial'),
|
('settings', '0001_initial'),
|
||||||
('terminal', '0016_commandstorage_replaystorage'),
|
('terminal', '0016_commandstorage_replaystorage'),
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Terminal(StorageMixin, TerminalStatusMixin, models.Model):
|
||||||
replay_storage = models.CharField(max_length=128, verbose_name=_("Replay storage"), default='default')
|
replay_storage = models.CharField(max_length=128, verbose_name=_("Replay storage"), default='default')
|
||||||
user = models.OneToOneField(User, related_name='terminal', verbose_name=_('Application User'), null=True,
|
user = models.OneToOneField(User, related_name='terminal', verbose_name=_('Application User'), null=True,
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
is_deleted = models.BooleanField(default=False, verbose_name=_('Is deleted'))
|
is_deleted = models.BooleanField(default=False)
|
||||||
date_created = models.DateTimeField(auto_now_add=True)
|
date_created = models.DateTimeField(auto_now_add=True)
|
||||||
comment = models.TextField(blank=True, verbose_name=_('Comment'))
|
comment = models.TextField(blank=True, verbose_name=_('Comment'))
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,33 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
import uuid
|
|
||||||
import base64
|
import base64
|
||||||
import string
|
|
||||||
import random
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import random
|
||||||
|
import string
|
||||||
|
import uuid
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from django.db import models
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import timezone
|
|
||||||
from django.core.cache import cache
|
|
||||||
from django.contrib.auth.models import AbstractUser
|
|
||||||
from django.contrib.auth.hashers import check_password
|
from django.contrib.auth.hashers import check_password
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.contrib.auth.models import AbstractUser
|
||||||
|
from django.core.cache import cache
|
||||||
|
from django.db import models
|
||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
|
from django.utils import timezone
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from orgs.utils import current_org
|
|
||||||
from orgs.models import Organization
|
|
||||||
from rbac.const import Scope
|
|
||||||
from common.db import fields, models as jms_models
|
from common.db import fields, models as jms_models
|
||||||
from common.utils import (
|
from common.utils import (
|
||||||
date_expired_default, get_logger, lazyproperty, random_string, bulk_create_with_signal
|
date_expired_default, get_logger, lazyproperty,
|
||||||
|
random_string, bulk_create_with_signal
|
||||||
|
)
|
||||||
|
from orgs.utils import current_org
|
||||||
|
from rbac.const import Scope
|
||||||
|
from ..signals import (
|
||||||
|
post_user_change_password, post_user_leave_org, pre_user_leave_org
|
||||||
)
|
)
|
||||||
from ..signals import post_user_change_password, post_user_leave_org, pre_user_leave_org
|
|
||||||
|
|
||||||
__all__ = ['User', 'UserPasswordHistory']
|
__all__ = ['User', 'UserPasswordHistory']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue