From d98499a3fa8b39be957da142a03501049f363b72 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 9 Sep 2021 13:26:36 +0200 Subject: [PATCH] providers/proxy: fix defaults for old proxy providers Signed-off-by: Jens Langhammer --- .../proxy/migrations/0014_proxy_v2.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 authentik/providers/proxy/migrations/0014_proxy_v2.py diff --git a/authentik/providers/proxy/migrations/0014_proxy_v2.py b/authentik/providers/proxy/migrations/0014_proxy_v2.py new file mode 100644 index 000000000..18204d24e --- /dev/null +++ b/authentik/providers/proxy/migrations/0014_proxy_v2.py @@ -0,0 +1,24 @@ +# Generated by Django 3.2.6 on 2021-09-09 11:24 + +from django.apps.registry import Apps +from django.db import migrations +from django.db.backends.base.schema import BaseDatabaseSchemaEditor + + +def migrate_defaults(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): + from authentik.providers.proxy.models import JWTAlgorithms + + db_alias = schema_editor.connection.alias + ProxyProvider = apps.get_model("authentik_providers_proxy", "proxyprovider") + for provider in ProxyProvider.objects.using(db_alias).filter(jwt_alg=JWTAlgorithms.RS256): + provider.set_oauth_defaults() + provider.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("authentik_providers_proxy", "0013_mode"), + ] + + operations = [migrations.RunPython(migrate_defaults)]