diff --git a/authentik/events/models.py b/authentik/events/models.py index 796c75cce224..0479c896f5e4 100644 --- a/authentik/events/models.py +++ b/authentik/events/models.py @@ -258,6 +258,7 @@ def log_deprecation( action=EventAction.CONFIGURATION_WARNING, context__deprecation=identifier, ) + cause = str(cause) if cause: query &= Q(context__cause=cause) if Event.objects.filter(query).exists(): diff --git a/authentik/events/tests/test_event.py b/authentik/events/tests/test_event.py index 345d78052d66..47ea1e664d7d 100644 --- a/authentik/events/tests/test_event.py +++ b/authentik/events/tests/test_event.py @@ -225,3 +225,14 @@ def test_password_set_signal_on_set_password_from_hash(self): new_count = Event.objects.filter(action=EventAction.PASSWORD_SET, user__pk=user.pk).count() self.assertEqual(new_count, old_count + 1) + + def test_log_deprecation(self): + """Test Event.log_deprecation""" + Event.log_deprecation(self.__module__, "Test deprecation") + Event.log_deprecation(self.__module__, "Test deprecation") + Event.log_deprecation(self.__module__, "Test deprecation") + Event.log_deprecation(self.__module__, "Test deprecation", cause=create_test_user()) + logs = Event.objects.filter( + action=EventAction.CONFIGURATION_WARNING, context__deprecation=self.__module__ + ) + self.assertEqual(logs.count(), 2) diff --git a/authentik/providers/saml/views/flows.py b/authentik/providers/saml/views/flows.py index aaaf873c2174..33c96b77ff39 100644 --- a/authentik/providers/saml/views/flows.py +++ b/authentik/providers/saml/views/flows.py @@ -127,7 +127,7 @@ def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse: "Redirect binding for Service Provider binding is deprecated " "and will be removed in a future version. Use Post binding instead." ), - cause=provider, + cause=provider.name, ) url_args = { REQUEST_KEY_SAML_RESPONSE: deflate_and_base64_encode(response),