mirror of https://github.com/jumpserver/jumpserver
parent
632627db11
commit
338ab5c634
@ -0,0 +1,44 @@
|
||||
# Generated by Django 3.2.17 on 2023-04-25 09:04
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
import common.db.fields
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('acls', '0010_alter_commandfilteracl_command_groups'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='commandfilteracl',
|
||||
name='new_accounts',
|
||||
field=common.db.fields.JSONManyToManyField(default=dict, to='assets.Account', verbose_name='Accounts'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='commandfilteracl',
|
||||
name='new_assets',
|
||||
field=common.db.fields.JSONManyToManyField(default=dict, to='assets.Asset', verbose_name='Assets'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='commandfilteracl',
|
||||
name='new_users',
|
||||
field=common.db.fields.JSONManyToManyField(default=dict, to='users.User', verbose_name='Users'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='loginassetacl',
|
||||
name='new_accounts',
|
||||
field=common.db.fields.JSONManyToManyField(default=dict, to='assets.Account', verbose_name='Accounts'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='loginassetacl',
|
||||
name='new_assets',
|
||||
field=common.db.fields.JSONManyToManyField(default=dict, to='assets.Asset', verbose_name='Assets'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='loginassetacl',
|
||||
name='new_users',
|
||||
field=common.db.fields.JSONManyToManyField(default=dict, to='users.User', verbose_name='Users'),
|
||||
),
|
||||
]
|
@ -0,0 +1,42 @@
|
||||
# Generated by Django 3.2.17 on 2023-04-26 03:11
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def migrate_base_acl_users_assets_accounts(apps, *args):
|
||||
cmd_acl_model = apps.get_model('acls', 'CommandFilterACL')
|
||||
login_asset_acl_model = apps.get_model('acls', 'LoginAssetACL')
|
||||
|
||||
for model in [cmd_acl_model, login_asset_acl_model]:
|
||||
for obj in model.objects.all():
|
||||
user_names = (obj.users or {}).get('username_group', [])
|
||||
obj.new_users = {
|
||||
"type": "attrs",
|
||||
"attrs": [{"name": "username", "value": user_names, "match": "in"}]
|
||||
}
|
||||
|
||||
asset_names = (obj.assets or {}).get('name_group', [])
|
||||
asset_attrs = []
|
||||
if asset_names:
|
||||
asset_attrs.append({"name": "name", "value": asset_names, "match": "in"})
|
||||
asset_address = (obj.assets or {}).get('address_group', [])
|
||||
if asset_address:
|
||||
asset_attrs.append({"name": "address", "value": asset_address, "match": "ip_in", "rel": "or"})
|
||||
obj.new_assets = {"type": "attrs", "attrs": asset_attrs}
|
||||
|
||||
account_usernames = (obj.accounts or {}).get('username_group', [])
|
||||
obj.new_accounts = {
|
||||
"type": "attrs",
|
||||
"attrs": [{"name": "username", "value": account_usernames, "match": "in"}]
|
||||
}
|
||||
obj.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('acls', '0011_auto_20230425_1704'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migrate_base_acl_users_assets_accounts)
|
||||
]
|
@ -0,0 +1,66 @@
|
||||
# Generated by Django 3.2.17 on 2023-04-26 09:59
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
('acls', '0012_auto_20230426_1111'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='commandfilteracl',
|
||||
name='accounts',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='commandfilteracl',
|
||||
name='assets',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='commandfilteracl',
|
||||
name='users',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='loginassetacl',
|
||||
name='accounts',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='loginassetacl',
|
||||
name='assets',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='loginassetacl',
|
||||
name='users',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='commandfilteracl',
|
||||
old_name='new_accounts',
|
||||
new_name='accounts',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='commandfilteracl',
|
||||
old_name='new_assets',
|
||||
new_name='assets',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='commandfilteracl',
|
||||
old_name='new_users',
|
||||
new_name='users',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='loginassetacl',
|
||||
old_name='new_accounts',
|
||||
new_name='accounts',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='loginassetacl',
|
||||
old_name='new_assets',
|
||||
new_name='assets',
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='loginassetacl',
|
||||
old_name='new_users',
|
||||
new_name='users',
|
||||
),
|
||||
]
|
Loading…
Reference in new issue