From f6c322be2743832f5a5539fe3fdb62a68c407d23 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 2 Mar 2020 17:40:38 +0100 Subject: [PATCH] providers/oidc: fix skip_authorization not being synced to oidc_client --- passbook/providers/oidc/apps.py | 4 ++++ passbook/providers/oidc/signals.py | 16 ++++++++++++++++ static.Dockerfile | 5 ----- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 passbook/providers/oidc/signals.py diff --git a/passbook/providers/oidc/apps.py b/passbook/providers/oidc/apps.py index de1ecb0e6..ee4f50191 100644 --- a/passbook/providers/oidc/apps.py +++ b/passbook/providers/oidc/apps.py @@ -1,4 +1,6 @@ """passbook auth oidc provider app config""" +from importlib import import_module + from django.apps import AppConfig from django.db.utils import InternalError, OperationalError, ProgrammingError from django.urls import include, path @@ -34,3 +36,5 @@ class PassbookProviderOIDCConfig(AppConfig): include("oidc_provider.urls", namespace="oidc_provider"), ), ) + + import_module("passbook.providers.oidc.signals") diff --git a/passbook/providers/oidc/signals.py b/passbook/providers/oidc/signals.py new file mode 100644 index 000000000..0281464ff --- /dev/null +++ b/passbook/providers/oidc/signals.py @@ -0,0 +1,16 @@ +"""OIDC Provider signals""" +from django.db.models.signals import post_save +from django.dispatch import receiver + +from passbook.core.models import Application +from passbook.providers.oidc.models import OpenIDProvider + + +@receiver(post_save, sender=Application) +# pylint: disable=unused-argument +def on_application_save(sender, instance: Application, **_): + """Synchronize application's skip_authorization with oidc_client's require_consent""" + if isinstance(instance.provider, OpenIDProvider): + instance.provider.oidc_client.require_consent = not instance.skip_authorization + instance.provider.oidc_client.save() + print("updating skip_authz") diff --git a/static.Dockerfile b/static.Dockerfile index c5dafb4be..e6793f3d4 100644 --- a/static.Dockerfile +++ b/static.Dockerfile @@ -46,8 +46,3 @@ FROM nginx COPY --from=static-build /app/static /usr/share/nginx/html/static COPY --from=static-build /app/static/robots.txt /usr/share/nginx/html/robots.txt COPY --from=npm-packager /static/node_modules /usr/share/nginx/html/static/node_modules - -# FROM beryju/pixie:latest - -# COPY --from=static-build /app/static /web-root/static/ -# COPY --from=static-build /app/static/robots.txt /web-root/robots.txt