providers/oidc: fix skip_authorization not being synced to oidc_client

This commit is contained in:
Jens Langhammer 2020-03-02 17:40:38 +01:00
parent a144552059
commit f6c322be27
3 changed files with 20 additions and 5 deletions

View File

@ -1,4 +1,6 @@
"""passbook auth oidc provider app config""" """passbook auth oidc provider app config"""
from importlib import import_module
from django.apps import AppConfig from django.apps import AppConfig
from django.db.utils import InternalError, OperationalError, ProgrammingError from django.db.utils import InternalError, OperationalError, ProgrammingError
from django.urls import include, path from django.urls import include, path
@ -34,3 +36,5 @@ class PassbookProviderOIDCConfig(AppConfig):
include("oidc_provider.urls", namespace="oidc_provider"), include("oidc_provider.urls", namespace="oidc_provider"),
), ),
) )
import_module("passbook.providers.oidc.signals")

View File

@ -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")

View File

@ -46,8 +46,3 @@ FROM nginx
COPY --from=static-build /app/static /usr/share/nginx/html/static 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=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 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