e36d7928e4
add New fields for - assertion_valid_not_before - assertion_valid_not_on_or_after - session_valid_not_on_or_after allow flexible time durations for these fields fall back to Provider's ACS if none is specified in AuthNRequest
62 lines
2.2 KiB
Python
62 lines
2.2 KiB
Python
# Generated by Django 2.2.9 on 2020-02-14 13:54
|
|
|
|
from django.db import migrations, models
|
|
|
|
import passbook.providers.saml.utils.time
|
|
|
|
|
|
def migrate_valid_for(apps, schema_editor):
|
|
"""Migrate from single number standing for minutes to 'minutes=3'"""
|
|
SAMLProvider = apps.get_model("passbook_providers_saml", "SAMLProvider")
|
|
db_alias = schema_editor.connection.alias
|
|
for provider in SAMLProvider.objects.using(db_alias).all():
|
|
provider.assertion_valid_not_on_or_after = (
|
|
f"minutes={provider.assertion_valid_for}"
|
|
)
|
|
provider.save()
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("passbook_providers_saml", "0001_initial"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name="samlprovider",
|
|
name="assertion_valid_not_before",
|
|
field=models.TextField(
|
|
default="minutes=5",
|
|
help_text="Assertion valid not before current time - this value (Format: hours=1;minutes=2;seconds=3).",
|
|
validators=[
|
|
passbook.providers.saml.utils.time.timedelta_string_validator
|
|
],
|
|
),
|
|
),
|
|
migrations.AddField(
|
|
model_name="samlprovider",
|
|
name="assertion_valid_not_on_or_after",
|
|
field=models.TextField(
|
|
default="minutes=5",
|
|
help_text="Assertion not valid on or after current time + this value (Format: hours=1;minutes=2;seconds=3).",
|
|
validators=[
|
|
passbook.providers.saml.utils.time.timedelta_string_validator
|
|
],
|
|
),
|
|
),
|
|
migrations.RunPython(migrate_valid_for),
|
|
migrations.RemoveField(model_name="samlprovider", name="assertion_valid_for",),
|
|
migrations.AddField(
|
|
model_name="samlprovider",
|
|
name="session_valid_not_on_or_after",
|
|
field=models.TextField(
|
|
default="minutes=86400",
|
|
help_text="Session not valid on or after current time + this value (Format: hours=1;minutes=2;seconds=3).",
|
|
validators=[
|
|
passbook.providers.saml.utils.time.timedelta_string_validator
|
|
],
|
|
),
|
|
),
|
|
]
|