diff --git a/authentik/stages/authenticator_sms/migrations/0001_squashed_0004_auto_20211014_0936.py b/authentik/stages/authenticator_sms/migrations/0001_squashed_0004_auto_20211014_0936.py new file mode 100644 index 000000000..fcedae8a8 --- /dev/null +++ b/authentik/stages/authenticator_sms/migrations/0001_squashed_0004_auto_20211014_0936.py @@ -0,0 +1,118 @@ +# Generated by Django 3.2.8 on 2021-10-14 09:41 + +import django.db.models.deletion +import django.utils.timezone +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + replaces = [ + ("authentik_stages_authenticator_sms", "0001_initial"), + ("authentik_stages_authenticator_sms", "0002_authenticatorsmsstage_from_number"), + ("authentik_stages_authenticator_sms", "0003_auto_20211014_0813"), + ("authentik_stages_authenticator_sms", "0004_auto_20211014_0936"), + ] + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("authentik_flows", "0024_alter_flow_compatibility_mode"), + ] + + operations = [ + migrations.CreateModel( + name="AuthenticatorSMSStage", + fields=[ + ( + "stage_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="authentik_flows.stage", + ), + ), + ( + "provider", + models.TextField(choices=[("twilio", "Twilio"), ("generic", "Generic")]), + ), + ("account_sid", models.TextField()), + ("auth", models.TextField()), + ( + "configure_flow", + models.ForeignKey( + blank=True, + help_text="Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.", + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="authentik_flows.flow", + ), + ), + ("from_number", models.TextField(default="")), + ("auth_password", models.TextField(blank=True, default="")), + ( + "auth_type", + models.TextField( + choices=[("basic", "Basic"), ("bearer", "Bearer")], default="basic" + ), + ), + ], + options={ + "verbose_name": "SMS Authenticator Setup Stage", + "verbose_name_plural": "SMS Authenticator Setup Stages", + }, + bases=("authentik_flows.stage", models.Model), + ), + migrations.CreateModel( + name="SMSDevice", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ( + "name", + models.CharField( + help_text="The human-readable name of this device.", max_length=64 + ), + ), + ( + "confirmed", + models.BooleanField(default=True, help_text="Is this device ready for use?"), + ), + ("token", models.CharField(blank=True, max_length=16, null=True)), + ( + "valid_until", + models.DateTimeField( + default=django.utils.timezone.now, + help_text="The timestamp of the moment of expiry of the saved token.", + ), + ), + ("phone_number", models.TextField()), + ( + "stage", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="authentik_stages_authenticator_sms.authenticatorsmsstage", + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL + ), + ), + ], + options={ + "verbose_name": "SMS Device", + "verbose_name_plural": "SMS Devices", + }, + ), + ] diff --git a/authentik/stages/authenticator_sms/migrations/0004_auto_20211014_0936.py b/authentik/stages/authenticator_sms/migrations/0004_auto_20211014_0936.py new file mode 100644 index 000000000..2dde13cd7 --- /dev/null +++ b/authentik/stages/authenticator_sms/migrations/0004_auto_20211014_0936.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.8 on 2021-10-14 09:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_stages_authenticator_sms", "0003_auto_20211014_0813"), + ] + + operations = [ + migrations.AlterField( + model_name="authenticatorsmsstage", + name="auth_type", + field=models.TextField( + choices=[("basic", "Basic"), ("bearer", "Bearer")], default="basic" + ), + ), + migrations.AlterField( + model_name="authenticatorsmsstage", + name="auth_password", + field=models.TextField(blank=True, default=""), + ), + ] diff --git a/authentik/stages/authenticator_sms/models.py b/authentik/stages/authenticator_sms/models.py index d9aeed30a..1fb9dbbdf 100644 --- a/authentik/stages/authenticator_sms/models.py +++ b/authentik/stages/authenticator_sms/models.py @@ -30,8 +30,8 @@ class SMSProviders(models.TextChoices): class SMSAuthTypes(models.TextChoices): """Supported SMS Auth Types""" - BEARER = "bearer" BASIC = "basic" + BEARER = "bearer" class AuthenticatorSMSStage(ConfigurableStage, Stage): @@ -43,8 +43,8 @@ class AuthenticatorSMSStage(ConfigurableStage, Stage): account_sid = models.TextField() auth = models.TextField() - auth_password = models.TextField(null=True) - auth_type = models.TextField(choices=SMSAuthTypes.choices, null=True) + auth_password = models.TextField(default="", blank=True) + auth_type = models.TextField(choices=SMSAuthTypes.choices, default=SMSAuthTypes.BASIC) def send(self, token: str, device: "SMSDevice"): """Send message via selected provider""" diff --git a/schema.yml b/schema.yml index ab5420c01..7f1bf2222 100644 --- a/schema.yml +++ b/schema.yml @@ -14157,7 +14157,6 @@ paths: name: auth_type schema: type: string - nullable: true enum: - basic - bearer @@ -18874,8 +18873,8 @@ components: - slug AuthTypeEnum: enum: - - bearer - basic + - bearer type: string AuthenticateWebAuthnStage: type: object @@ -19207,11 +19206,8 @@ components: type: string auth_password: type: string - nullable: true auth_type: - allOf: - - $ref: '#/components/schemas/AuthTypeEnum' - nullable: true + $ref: '#/components/schemas/AuthTypeEnum' required: - account_sid - auth @@ -19248,11 +19244,8 @@ components: type: string auth_password: type: string - nullable: true auth_type: - allOf: - - $ref: '#/components/schemas/AuthTypeEnum' - nullable: true + $ref: '#/components/schemas/AuthTypeEnum' required: - account_sid - auth @@ -26001,11 +25994,8 @@ components: type: string auth_password: type: string - nullable: true auth_type: - allOf: - - $ref: '#/components/schemas/AuthTypeEnum' - nullable: true + $ref: '#/components/schemas/AuthTypeEnum' PatchedAuthenticatorStaticStageRequest: type: object description: AuthenticatorStaticStage Serializer