From 1a8f3fb18a994675768a953c3e1ab92ae6ca1b4b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 10 Dec 2018 10:49:50 +0100 Subject: [PATCH] Cleanup migrations (again) --- passbook/core/migrations/0001_initial.py | 42 +++++++++++++++++-- .../migrations/0002_auto_20181125_1638.py | 19 --------- passbook/core/migrations/0003_rule_order.py | 18 -------- .../migrations/0004_auto_20181127_1341.py | 40 ------------------ .../migrations/0005_auto_20181127_1522.py | 18 -------- passbook/core/migrations/0006_user_uuid.py | 20 --------- passbook/core/migrations/0007_debugrule.py | 28 ------------- passbook/core/views/overview.py | 4 +- passbook/ldap/migrations/0001_initial.py | 6 +-- .../migrations/0002_auto_20181127_1341.py | 18 -------- .../oauth_client/migrations/0001_initial.py | 2 +- passbook/saml_idp/migrations/0001_initial.py | 17 +++++--- .../migrations/0002_auto_20181126_1509.py | 32 -------------- .../migrations/0003_auto_20181126_1514.py | 17 -------- .../migrations/0004_auto_20181209_2202.py | 41 ------------------ 15 files changed, 57 insertions(+), 265 deletions(-) delete mode 100644 passbook/core/migrations/0002_auto_20181125_1638.py delete mode 100644 passbook/core/migrations/0003_rule_order.py delete mode 100644 passbook/core/migrations/0004_auto_20181127_1341.py delete mode 100644 passbook/core/migrations/0005_auto_20181127_1522.py delete mode 100644 passbook/core/migrations/0006_user_uuid.py delete mode 100644 passbook/core/migrations/0007_debugrule.py delete mode 100644 passbook/ldap/migrations/0002_auto_20181127_1341.py delete mode 100644 passbook/saml_idp/migrations/0002_auto_20181126_1509.py delete mode 100644 passbook/saml_idp/migrations/0003_auto_20181126_1514.py delete mode 100644 passbook/saml_idp/migrations/0004_auto_20181209_2202.py diff --git a/passbook/core/migrations/0001_initial.py b/passbook/core/migrations/0001_initial.py index cd29052c0..9f3b0b662 100644 --- a/passbook/core/migrations/0001_initial.py +++ b/passbook/core/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.1.3 on 2018-11-25 10:39 +# Generated by Django 2.1.4 on 2018-12-10 09:15 import uuid @@ -33,6 +33,7 @@ class Migration(migrations.Migration): ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('uuid', models.UUIDField(default=uuid.uuid4, editable=False)), ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), ], @@ -60,6 +61,7 @@ class Migration(migrations.Migration): ('name', models.TextField(blank=True, null=True)), ('action', models.CharField(choices=[('allow', 'allow'), ('deny', 'deny')], max_length=20)), ('negate', models.BooleanField(default=False)), + ('order', models.IntegerField(default=0)), ], options={ 'abstract': False, @@ -93,23 +95,38 @@ class Migration(migrations.Migration): ('launch_url', models.URLField(blank=True, null=True)), ('icon_url', models.TextField(blank=True, null=True)), ('skip_authorization', models.BooleanField(default=False)), - ('provider', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='passbook_core.Provider')), + ('provider', models.OneToOneField(default=None, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='passbook_core.Provider')), ], options={ 'abstract': False, }, bases=('passbook_core.rulemodel',), ), + migrations.CreateModel( + name='DebugRule', + fields=[ + ('rule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Rule')), + ('result', models.BooleanField(default=False)), + ('wait_min', models.IntegerField(default=5)), + ('wait_max', models.IntegerField(default=30)), + ], + options={ + 'verbose_name': 'Debug Rule', + 'verbose_name_plural': 'Debug Rules', + }, + bases=('passbook_core.rule',), + ), migrations.CreateModel( name='FieldMatcherRule', fields=[ ('rule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Rule')), ('user_field', models.TextField()), - ('match_action', models.CharField(choices=[('startswith', 'startswith'), ('endswith', 'endswith'), ('endswith', 'contains'), ('regexp', 'regexp'), ('exact', 'exact')], max_length=50)), + ('match_action', models.CharField(choices=[('startswith', 'Starts with'), ('endswith', 'Ends with'), ('endswith', 'Contains'), ('regexp', 'Regexp'), ('exact', 'Exact')], max_length=50)), ('value', models.TextField()), ], options={ - 'abstract': False, + 'verbose_name': 'Field matcher Rule', + 'verbose_name_plural': 'Field matcher Rules', }, bases=('passbook_core.rule',), ), @@ -126,6 +143,23 @@ class Migration(migrations.Migration): }, bases=('passbook_core.rulemodel',), ), + migrations.CreateModel( + name='WebhookRule', + fields=[ + ('rule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Rule')), + ('url', models.URLField()), + ('method', models.CharField(choices=[('GET', 'GET'), ('POST', 'POST'), ('PATCH', 'PATCH'), ('DELETE', 'DELETE'), ('PUT', 'PUT')], max_length=10)), + ('json_body', models.TextField()), + ('json_headers', models.TextField()), + ('result_jsonpath', models.TextField()), + ('result_json_value', models.TextField()), + ], + options={ + 'verbose_name': 'Webhook Rule', + 'verbose_name_plural': 'Webhook Rules', + }, + bases=('passbook_core.rule',), + ), migrations.AddField( model_name='rulemodel', name='rules', diff --git a/passbook/core/migrations/0002_auto_20181125_1638.py b/passbook/core/migrations/0002_auto_20181125_1638.py deleted file mode 100644 index 1fabd2610..000000000 --- a/passbook/core/migrations/0002_auto_20181125_1638.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 2.1.3 on 2018-11-25 16:38 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='application', - name='provider', - field=models.OneToOneField(default=None, null=True, on_delete=django.db.models.deletion.SET_DEFAULT, to='passbook_core.Provider'), - ), - ] diff --git a/passbook/core/migrations/0003_rule_order.py b/passbook/core/migrations/0003_rule_order.py deleted file mode 100644 index 236896606..000000000 --- a/passbook/core/migrations/0003_rule_order.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.1.3 on 2018-11-25 19:35 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0002_auto_20181125_1638'), - ] - - operations = [ - migrations.AddField( - model_name='rule', - name='order', - field=models.IntegerField(default=0), - ), - ] diff --git a/passbook/core/migrations/0004_auto_20181127_1341.py b/passbook/core/migrations/0004_auto_20181127_1341.py deleted file mode 100644 index fce3ddf12..000000000 --- a/passbook/core/migrations/0004_auto_20181127_1341.py +++ /dev/null @@ -1,40 +0,0 @@ -# Generated by Django 2.1.3 on 2018-11-27 13:41 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0003_rule_order'), - ] - - operations = [ - migrations.CreateModel( - name='WebhookRule', - fields=[ - ('rule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Rule')), - ('url', models.URLField()), - ('method', models.CharField(choices=[('get', 'get'), ('post', 'post'), ('patch', 'patch'), ('delete', 'delete'), ('put', 'put')], max_length=10)), - ('json_body', models.TextField()), - ('json_headers', models.TextField()), - ('result_jsonpath', models.TextField()), - ('result_json_value', models.TextField()), - ], - options={ - 'verbose_name': 'Webhook Rule', - 'verbose_name_plural': 'Webhook Rules', - }, - bases=('passbook_core.rule',), - ), - migrations.AlterModelOptions( - name='fieldmatcherrule', - options={'verbose_name': 'Field matcher Rule', 'verbose_name_plural': 'Field matcher Rules'}, - ), - migrations.AlterField( - model_name='fieldmatcherrule', - name='match_action', - field=models.CharField(choices=[('startswith', 'Starts with'), ('endswith', 'Ends with'), ('endswith', 'Contains'), ('regexp', 'Regexp'), ('exact', 'Exact')], max_length=50), - ), - ] diff --git a/passbook/core/migrations/0005_auto_20181127_1522.py b/passbook/core/migrations/0005_auto_20181127_1522.py deleted file mode 100644 index 9bd4cf078..000000000 --- a/passbook/core/migrations/0005_auto_20181127_1522.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.1.3 on 2018-11-27 15:22 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0004_auto_20181127_1341'), - ] - - operations = [ - migrations.AlterField( - model_name='webhookrule', - name='method', - field=models.CharField(choices=[('GET', 'GET'), ('POST', 'POST'), ('PATCH', 'PATCH'), ('DELETE', 'DELETE'), ('PUT', 'PUT')], max_length=10), - ), - ] diff --git a/passbook/core/migrations/0006_user_uuid.py b/passbook/core/migrations/0006_user_uuid.py deleted file mode 100644 index 1c0c0994c..000000000 --- a/passbook/core/migrations/0006_user_uuid.py +++ /dev/null @@ -1,20 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-09 17:58 - -import uuid - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0005_auto_20181127_1522'), - ] - - operations = [ - migrations.AddField( - model_name='user', - name='uuid', - field=models.UUIDField(default=uuid.uuid4, editable=False), - ), - ] diff --git a/passbook/core/migrations/0007_debugrule.py b/passbook/core/migrations/0007_debugrule.py deleted file mode 100644 index c18216d6f..000000000 --- a/passbook/core/migrations/0007_debugrule.py +++ /dev/null @@ -1,28 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-09 18:58 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0006_user_uuid'), - ] - - operations = [ - migrations.CreateModel( - name='DebugRule', - fields=[ - ('rule_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Rule')), - ('result', models.BooleanField(default=False)), - ('wait_min', models.IntegerField(default=5)), - ('wait_max', models.IntegerField(default=30)), - ], - options={ - 'verbose_name': 'Debug Rule', - 'verbose_name_plural': 'Debug Rules', - }, - bases=('passbook_core.rule',), - ), - ] diff --git a/passbook/core/views/overview.py b/passbook/core/views/overview.py index 3ed4451ae..c857ad6ec 100644 --- a/passbook/core/views/overview.py +++ b/passbook/core/views/overview.py @@ -2,7 +2,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import TemplateView - +from passbook.core.models import Application class OverviewView(LoginRequiredMixin, TemplateView): """Overview for logged in user, incase user opens passbook directly @@ -12,4 +12,6 @@ class OverviewView(LoginRequiredMixin, TemplateView): def get_context_data(self, **kwargs): kwargs['applications'] = self.request.user.applications.all() + if self.request.user.is_superuser: + kwargs['applications'] = Application.objects.all() return super().get_context_data(**kwargs) diff --git a/passbook/ldap/migrations/0001_initial.py b/passbook/ldap/migrations/0001_initial.py index 05cc550df..22b8e928d 100644 --- a/passbook/ldap/migrations/0001_initial.py +++ b/passbook/ldap/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.1.3 on 2018-11-26 15:17 +# Generated by Django 2.1.4 on 2018-12-10 09:16 import django.db.models.deletion from django.db import migrations, models @@ -9,7 +9,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('passbook_core', '0003_rule_order'), + ('passbook_core', '0001_initial'), ] operations = [ @@ -20,7 +20,7 @@ class Migration(migrations.Migration): ('server_uri', models.TextField()), ('bind_cn', models.TextField()), ('bind_password', models.TextField()), - ('type', models.CharField(choices=[('ad', 'ad'), ('generic', 'generic')], max_length=20)), + ('type', models.CharField(choices=[('ad', 'Active Directory'), ('generic', 'Generic')], max_length=20)), ('domain', models.TextField()), ('base_dn', models.TextField()), ('create_user', models.BooleanField(default=False)), diff --git a/passbook/ldap/migrations/0002_auto_20181127_1341.py b/passbook/ldap/migrations/0002_auto_20181127_1341.py deleted file mode 100644 index 770d8950d..000000000 --- a/passbook/ldap/migrations/0002_auto_20181127_1341.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 2.1.3 on 2018-11-27 13:41 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_ldap', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='ldapsource', - name='type', - field=models.CharField(choices=[('ad', 'Active Directory'), ('generic', 'Generic')], max_length=20), - ), - ] diff --git a/passbook/oauth_client/migrations/0001_initial.py b/passbook/oauth_client/migrations/0001_initial.py index 90b2029f8..7894cad5f 100644 --- a/passbook/oauth_client/migrations/0001_initial.py +++ b/passbook/oauth_client/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.1.3 on 2018-11-25 10:39 +# Generated by Django 2.1.4 on 2018-12-10 09:16 import django.db.models.deletion from django.db import migrations, models diff --git a/passbook/saml_idp/migrations/0001_initial.py b/passbook/saml_idp/migrations/0001_initial.py index 933a80d7a..91878da0e 100644 --- a/passbook/saml_idp/migrations/0001_initial.py +++ b/passbook/saml_idp/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 2.1.3 on 2018-11-25 10:39 +# Generated by Django 2.1.4 on 2018-12-10 09:16 import django.db.models.deletion from django.db import migrations, models @@ -14,15 +14,22 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='SAMLApplication', + name='SAMLProvider', fields=[ - ('application_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Application')), + ('provider_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Provider')), + ('name', models.TextField()), ('acs_url', models.URLField()), ('processor_path', models.CharField(max_length=255)), + ('issuer', models.TextField()), + ('assertion_valid_for', models.IntegerField(default=86400)), + ('signing', models.BooleanField(default=True)), + ('signing_cert', models.TextField()), + ('signing_key', models.TextField()), ], options={ - 'abstract': False, + 'verbose_name': 'SAML Provider', + 'verbose_name_plural': 'SAML Providers', }, - bases=('passbook_core.application',), + bases=('passbook_core.provider',), ), ] diff --git a/passbook/saml_idp/migrations/0002_auto_20181126_1509.py b/passbook/saml_idp/migrations/0002_auto_20181126_1509.py deleted file mode 100644 index 0e73f33de..000000000 --- a/passbook/saml_idp/migrations/0002_auto_20181126_1509.py +++ /dev/null @@ -1,32 +0,0 @@ -# Generated by Django 2.1.3 on 2018-11-26 15:09 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_core', '0003_rule_order'), - ('passbook_saml_idp', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='SAMLProvider', - fields=[ - ('provider_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Provider')), - ('name', models.TextField()), - ('acs_url', models.URLField()), - ('processor_path', models.CharField(max_length=255)), - ], - bases=('passbook_core.provider',), - ), - migrations.RemoveField( - model_name='samlapplication', - name='application_ptr', - ), - migrations.DeleteModel( - name='SAMLApplication', - ), - ] diff --git a/passbook/saml_idp/migrations/0003_auto_20181126_1514.py b/passbook/saml_idp/migrations/0003_auto_20181126_1514.py deleted file mode 100644 index d37378067..000000000 --- a/passbook/saml_idp/migrations/0003_auto_20181126_1514.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 2.1.3 on 2018-11-26 15:14 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_saml_idp', '0002_auto_20181126_1509'), - ] - - operations = [ - migrations.AlterModelOptions( - name='samlprovider', - options={'verbose_name': 'SAML Provider', 'verbose_name_plural': 'SAML Providers'}, - ), - ] diff --git a/passbook/saml_idp/migrations/0004_auto_20181209_2202.py b/passbook/saml_idp/migrations/0004_auto_20181209_2202.py deleted file mode 100644 index 698ac6d73..000000000 --- a/passbook/saml_idp/migrations/0004_auto_20181209_2202.py +++ /dev/null @@ -1,41 +0,0 @@ -# Generated by Django 2.1.4 on 2018-12-09 22:02 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('passbook_saml_idp', '0003_auto_20181126_1514'), - ] - - operations = [ - migrations.AddField( - model_name='samlprovider', - name='assertion_valid_for', - field=models.IntegerField(default=86400), - ), - migrations.AddField( - model_name='samlprovider', - name='issuer', - field=models.TextField(default=''), - preserve_default=False, - ), - migrations.AddField( - model_name='samlprovider', - name='signing', - field=models.BooleanField(default=True), - ), - migrations.AddField( - model_name='samlprovider', - name='signing_cert', - field=models.TextField(default=''), - preserve_default=False, - ), - migrations.AddField( - model_name='samlprovider', - name='signing_key', - field=models.TextField(default=''), - preserve_default=False, - ), - ]