Move skip_authorization to base Provider

This commit is contained in:
Jens Langhammer 2018-11-24 22:26:28 +01:00
parent f298c42adc
commit 32945250b6
No known key found for this signature in database
GPG key ID: BEBC05297D92821B
5 changed files with 44 additions and 5 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.3 on 2018-11-24 09:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('passbook_core', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='application',
name='skip_authorization',
field=models.BooleanField(default=False),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.3 on 2018-11-24 10:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('passbook_core', '0002_application_skip_authorization'),
]
operations = [
migrations.AlterField(
model_name='rulemodel',
name='rules',
field=models.ManyToManyField(blank=True, to='passbook_core.Rule'),
),
]

View file

@ -23,11 +23,15 @@ class Provider(models.Model):
"""Application-independent Provider instance. For example SAML2 Remote, OAuth2 Application"""
# This class defines no field for easier inheritance
def __str__(self):
if hasattr(self, 'name'):
return getattr(self, 'name')
return super().__str__()
class RuleModel(UUIDModel, CreatedUpdatedModel):
"""Base model which can have rules applied to it"""
rules = models.ManyToManyField('Rule')
rules = models.ManyToManyField('Rule', blank=True)
def passes(self, user: User) -> bool:
"""Return true if user passes, otherwise False or raise Exception"""
@ -46,6 +50,7 @@ class Application(RuleModel):
launch_url = models.URLField(null=True, blank=True)
icon_url = models.TextField(null=True, blank=True)
provider = models.ForeignKey('Provider', null=True, default=None, on_delete=models.SET_DEFAULT)
skip_authorization = models.BooleanField(default=False)
objects = InheritanceManager()

View file

@ -1,4 +1,4 @@
# Generated by Django 2.1.3 on 2018-11-22 10:03
# Generated by Django 2.1.3 on 2018-11-24 09:48
import django.db.models.deletion
from django.db import migrations, models
@ -9,7 +9,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
('passbook_core', '0001_initial'),
('passbook_core', '0002_application_skip_authorization'),
]
operations = [
@ -19,7 +19,6 @@ class Migration(migrations.Migration):
('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')),
('acs_url', models.URLField()),
('processor_path', models.CharField(max_length=255)),
('skip_authorization', models.BooleanField(default=False)),
],
options={
'abstract': False,

View file

@ -12,7 +12,6 @@ class SAMLApplication(Application):
acs_url = models.URLField()
processor_path = models.CharField(max_length=255, choices=[])
skip_authorization = models.BooleanField(default=False)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)