core: move name field to base Provider
This commit is contained in:
parent
b0602a3215
commit
195d8fe71f
|
@ -33,7 +33,7 @@ class ProviderListView(
|
||||||
permission_required = "passbook_core.add_provider"
|
permission_required = "passbook_core.add_provider"
|
||||||
template_name = "administration/provider/list.html"
|
template_name = "administration/provider/list.html"
|
||||||
ordering = "id"
|
ordering = "id"
|
||||||
search_fields = ["id"]
|
search_fields = ["id", "name"]
|
||||||
|
|
||||||
|
|
||||||
class ProviderCreateView(
|
class ProviderCreateView(
|
||||||
|
|
|
@ -17,7 +17,7 @@ class ProviderSerializer(ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
model = Provider
|
model = Provider
|
||||||
fields = ["pk", "authorization_flow", "property_mappings", "__type__"]
|
fields = ["pk", "name", "authorization_flow", "property_mappings", "__type__"]
|
||||||
|
|
||||||
|
|
||||||
class ProviderViewSet(ReadOnlyModelViewSet):
|
class ProviderViewSet(ReadOnlyModelViewSet):
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 3.1.2 on 2020-10-03 17:34
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("passbook_core", "0010_auto_20200917_1021"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="provider",
|
||||||
|
name="name_temp",
|
||||||
|
field=models.TextField(default=""),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.1.2 on 2020-10-03 17:37
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("passbook_core", "0011_provider_name_temp"),
|
||||||
|
("passbook_providers_oauth2", "0006_remove_oauth2provider_name"),
|
||||||
|
("passbook_providers_saml", "0006_remove_samlprovider_name"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="provider",
|
||||||
|
old_name="name_temp",
|
||||||
|
new_name="name",
|
||||||
|
),
|
||||||
|
]
|
|
@ -124,6 +124,8 @@ class User(GuardianUserMixin, AbstractUser):
|
||||||
class Provider(models.Model):
|
class Provider(models.Model):
|
||||||
"""Application-independent Provider instance. For example SAML2 Remote, OAuth2 Application"""
|
"""Application-independent Provider instance. For example SAML2 Remote, OAuth2 Application"""
|
||||||
|
|
||||||
|
name = models.TextField()
|
||||||
|
|
||||||
authorization_flow = models.ForeignKey(
|
authorization_flow = models.ForeignKey(
|
||||||
Flow,
|
Flow,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
|
@ -148,11 +150,8 @@ class Provider(models.Model):
|
||||||
"""Return Form class used to edit this object"""
|
"""Return Form class used to edit this object"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
# This class defines no field for easier inheritance
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if hasattr(self, "name"):
|
return self.name
|
||||||
return getattr(self, "name")
|
|
||||||
return super().__str__()
|
|
||||||
|
|
||||||
|
|
||||||
class Application(PolicyBindingModel):
|
class Application(PolicyBindingModel):
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Generated by Django 3.1.2 on 2020-10-03 17:37
|
||||||
|
|
||||||
|
from django.apps.registry import Apps
|
||||||
|
from django.db import migrations
|
||||||
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||||
|
|
||||||
|
|
||||||
|
def update_name_temp(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
|
||||||
|
OAuth2Provider = apps.get_model("passbook_providers_oauth2", "OAuth2Provider")
|
||||||
|
db_alias = schema_editor.connection.alias
|
||||||
|
|
||||||
|
for provider in OAuth2Provider.objects.using(db_alias).all():
|
||||||
|
provider.name_temp = provider.name
|
||||||
|
provider.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("passbook_core", "0011_provider_name_temp"),
|
||||||
|
("passbook_providers_oauth2", "0005_auto_20200920_1240"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(update_name_temp),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="oauth2provider",
|
||||||
|
name="name",
|
||||||
|
),
|
||||||
|
]
|
|
@ -120,8 +120,6 @@ class ScopeMapping(PropertyMapping):
|
||||||
class OAuth2Provider(Provider):
|
class OAuth2Provider(Provider):
|
||||||
"""OAuth2 Provider for generic OAuth and OpenID Connect Applications."""
|
"""OAuth2 Provider for generic OAuth and OpenID Connect Applications."""
|
||||||
|
|
||||||
name = models.TextField()
|
|
||||||
|
|
||||||
client_type = models.CharField(
|
client_type = models.CharField(
|
||||||
max_length=30,
|
max_length=30,
|
||||||
choices=ClientTypes.choices,
|
choices=ClientTypes.choices,
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# Generated by Django 3.1.2 on 2020-10-03 17:37
|
||||||
|
|
||||||
|
from django.apps.registry import Apps
|
||||||
|
from django.db import migrations
|
||||||
|
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
|
||||||
|
|
||||||
|
|
||||||
|
def update_name_temp(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
|
||||||
|
SAMLProvider = apps.get_model("passbook_providers_saml", "SAMLProvider")
|
||||||
|
db_alias = schema_editor.connection.alias
|
||||||
|
|
||||||
|
for provider in SAMLProvider.objects.using(db_alias).all():
|
||||||
|
provider.name_temp = provider.name
|
||||||
|
provider.save()
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("passbook_core", "0011_provider_name_temp"),
|
||||||
|
("passbook_providers_saml", "0005_remove_samlprovider_processor_path"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(update_name_temp),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name="samlprovider",
|
||||||
|
name="name",
|
||||||
|
),
|
||||||
|
]
|
|
@ -27,8 +27,6 @@ class SAMLBindings(models.TextChoices):
|
||||||
class SAMLProvider(Provider):
|
class SAMLProvider(Provider):
|
||||||
"""SAML 2.0 Endpoint for applications which support SAML."""
|
"""SAML 2.0 Endpoint for applications which support SAML."""
|
||||||
|
|
||||||
name = models.TextField()
|
|
||||||
|
|
||||||
acs_url = models.URLField(verbose_name=_("ACS URL"))
|
acs_url = models.URLField(verbose_name=_("ACS URL"))
|
||||||
audience = models.TextField(default="")
|
audience = models.TextField(default="")
|
||||||
issuer = models.TextField(help_text=_("Also known as EntityID"))
|
issuer = models.TextField(help_text=_("Also known as EntityID"))
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Generated by Django 3.1.2 on 2020-10-03 17:34
|
||||||
|
|
||||||
|
import django.contrib.postgres.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
(
|
||||||
|
"passbook_stages_identification",
|
||||||
|
"0004_identificationstage_case_insensitive_matching",
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="identificationstage",
|
||||||
|
name="user_fields",
|
||||||
|
field=django.contrib.postgres.fields.ArrayField(
|
||||||
|
base_field=models.CharField(
|
||||||
|
choices=[("email", "E Mail"), ("username", "Username")],
|
||||||
|
max_length=100,
|
||||||
|
),
|
||||||
|
help_text="Fields of the user object to match against. (Hold shift to select multiple options)",
|
||||||
|
size=None,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -6589,6 +6589,7 @@ definitions:
|
||||||
minLength: 1
|
minLength: 1
|
||||||
Provider:
|
Provider:
|
||||||
required:
|
required:
|
||||||
|
- name
|
||||||
- authorization_flow
|
- authorization_flow
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -6596,6 +6597,10 @@ definitions:
|
||||||
title: ID
|
title: ID
|
||||||
type: integer
|
type: integer
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
name:
|
||||||
|
title: Name
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
authorization_flow:
|
authorization_flow:
|
||||||
title: Authorization flow
|
title: Authorization flow
|
||||||
description: Flow used when authorizing this provider.
|
description: Flow used when authorizing this provider.
|
||||||
|
|
Reference in New Issue