Move skip_authorization to base Provider
This commit is contained in:
parent
f298c42adc
commit
32945250b6
|
@ -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),
|
||||||
|
),
|
||||||
|
]
|
|
@ -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'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -23,11 +23,15 @@ class Provider(models.Model):
|
||||||
"""Application-independent Provider instance. For example SAML2 Remote, OAuth2 Application"""
|
"""Application-independent Provider instance. For example SAML2 Remote, OAuth2 Application"""
|
||||||
|
|
||||||
# This class defines no field for easier inheritance
|
# 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):
|
class RuleModel(UUIDModel, CreatedUpdatedModel):
|
||||||
"""Base model which can have rules applied to it"""
|
"""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:
|
def passes(self, user: User) -> bool:
|
||||||
"""Return true if user passes, otherwise False or raise Exception"""
|
"""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)
|
launch_url = models.URLField(null=True, blank=True)
|
||||||
icon_url = models.TextField(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)
|
provider = models.ForeignKey('Provider', null=True, default=None, on_delete=models.SET_DEFAULT)
|
||||||
|
skip_authorization = models.BooleanField(default=False)
|
||||||
|
|
||||||
objects = InheritanceManager()
|
objects = InheritanceManager()
|
||||||
|
|
||||||
|
|
|
@ -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
|
import django.db.models.deletion
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -9,7 +9,7 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('passbook_core', '0001_initial'),
|
('passbook_core', '0002_application_skip_authorization'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
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')),
|
('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()),
|
('acs_url', models.URLField()),
|
||||||
('processor_path', models.CharField(max_length=255)),
|
('processor_path', models.CharField(max_length=255)),
|
||||||
('skip_authorization', models.BooleanField(default=False)),
|
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
|
|
|
@ -12,7 +12,6 @@ class SAMLApplication(Application):
|
||||||
|
|
||||||
acs_url = models.URLField()
|
acs_url = models.URLField()
|
||||||
processor_path = models.CharField(max_length=255, choices=[])
|
processor_path = models.CharField(max_length=255, choices=[])
|
||||||
skip_authorization = models.BooleanField(default=False)
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
Reference in New Issue