Beispiel #1
0
    def test_False_when_not_present(self):
        def function():
            pass

        is_public = utils.is_view_func_public(function)

        self.assertFalse(is_public)
Beispiel #2
0
    def test_False_when_not_present(self):
        def function():
            pass

        is_public = utils.is_view_func_public(function)

        self.assertFalse(is_public)
Beispiel #3
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        if conf.STRONGHOLD_USER_TEST_FUNC(request.user) \
                or utils.is_view_func_public(view_func) \
                or self.is_public_url(request.path_info):
            return None

        decorator = user_passes_test(conf.STRONGHOLD_USER_TEST_FUNC)
        return decorator(view_func)(request, *view_args, **view_kwargs)
    def process_view(self, request, view_func, view_args, view_kwargs):
        if conf.STRONGHOLD_USER_TEST_FUNC(request.user) \
                or utils.is_view_func_public(view_func) \
                or self.is_public_url(request.path_info):
            return None

        decorator = user_passes_test(conf.STRONGHOLD_USER_TEST_FUNC)
        return decorator(view_func)(request, *view_args, **view_kwargs)
Beispiel #5
0
    def test_True(self):
        def function():
            pass
        function.STRONGHOLD_IS_PUBLIC = True

        is_public = utils.is_view_func_public(function)

        self.assertTrue(is_public)
Beispiel #6
0
    def process_view(request, view_func, view_args, view_kwargs):
        """Reject non-admin access to views that are private and not marked."""
        if is_view_func_public(view_func) or \
           hasattr(view_func, 'IS_NON_ADMIN'):
            return

        if not is_user_admin(request.user):
            raise PermissionDenied
Beispiel #7
0
    def process_view(request, view_func, view_args, view_kwargs):
        """Reject non-admin access to views that are private and not marked."""
        if is_view_func_public(view_func) or \
           hasattr(view_func, 'IS_NON_ADMIN'):
            return

        if not is_user_admin(request.user):
            raise PermissionDenied
Beispiel #8
0
    def test_True(self):
        def function():
            pass

        function.STRONGHOLD_IS_PUBLIC = True

        is_public = utils.is_view_func_public(function)

        self.assertTrue(is_public)
Beispiel #9
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        if (
            request.user.is_authenticated()
            or utils.is_view_func_public(view_func)
            or self.is_public_url(request.path_info)
        ):
            return None

        return login_required(view_func)(request, *view_args, **view_kwargs)
Beispiel #10
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        if request.user.is_authenticated():
            if (self.only_superuser and not request.user.is_superuser) or (self.only_staff and not (request.user.is_staff or request.user.is_superuser)):
                auth_logout(request)
                return user_passes_test(lambda u: False)(lambda r: None)(request)
            return None

        if utils.is_view_func_public(view_func) or self.is_public_url(request.path_info):
            return None

        return login_required(view_func)(request, *view_args, **view_kwargs)
    def process_view(self, request, view_func, view_args, view_kwargs):
        if request.user.is_authenticated() or utils.is_view_func_public(view_func) \
                or self.is_public_url(request.path_info):
            return None

        return login_required(view_func)(request, *view_args, **view_kwargs)
    def process_view(self, request, view_func, view_args, view_kwargs):
        if request.user.is_authenticated() or utils.is_view_func_public(view_func) \
                or self.is_public_url(request.path_info):
            return None

        return conf.STRONGHOLD_PERMISSIONS_DECORATOR(view_func)(request, *view_args, **view_kwargs)