diff --git a/hobo/rest_authentication.py b/hobo/rest_authentication.py index 88c544a..485c1c0 100644 --- a/hobo/rest_authentication.py +++ b/hobo/rest_authentication.py @@ -8,6 +8,7 @@ from django.contrib.auth import get_user_model from django.conf import settings from django.contrib.auth.models import AnonymousUser from django.db.models.fields import FieldDoesNotExist +from django.utils.deprecation import CallableTrue from django.utils.module_loading import import_string try: @@ -18,8 +19,14 @@ except ImportError: class AnonymousAuthenticServiceUser(AnonymousUser): '''This virtual user hold permissions for other publik services''' - is_authenticated = True - is_anonymous = True + + @property + def is_anonymous(self): + return CallableTrue + + @property + def is_authenticated(self): + return CallableTrue def has_perm(self, perm_or_perms, obj=None): return True @@ -41,8 +48,14 @@ class AnonymousAuthenticServiceUser(AnonymousUser): class AnonymousAdminServiceUser(AnonymousUser): '''This virtual user hold permissions for other publik services''' is_staff = True - is_authenticated = True - is_anonymous = True + + @property + def is_anonymous(self): + return CallableTrue + + @property + def is_authenticated(self): + return CallableTrue def __unicode__(self): return 'Publik Service Admin' diff --git a/tests_authentic/test_rest_authentication.py b/tests_authentic/test_rest_authentication.py index 2b15bf4..e2874dc 100644 --- a/tests_authentic/test_rest_authentication.py +++ b/tests_authentic/test_rest_authentication.py @@ -47,6 +47,9 @@ def test_publik_authentication(tenant, settings): assert len(result) == 2 assert result[0].__class__ is rest_authentication.AnonymousAdminServiceUser assert result[0].is_authenticated + assert result[0].is_authenticated() + assert result[0].is_anonymous + assert result[0].is_anonymous() assert result[0].is_staff assert result[1] is None