Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buggy allauthusers permissions #194

Merged

Conversation

BrendaH
Copy link
Contributor

@BrendaH BrendaH commented Mar 17, 2020

Fix bug in #193 and update/add some tests that could've found this bug.

When a logged in user does not have a group with rights on forum X, the
all_authenticated_users permissions for forum X were not taken into account.

Add a test to prove this bug and fix it by taking a block of code outside of
the if that checks if there were group permissions on the given forum, but keep
it within the if for not self.user.is_anonymous.

Closes ellmetha#193
To be able to take into account the per_forum_nongranted_all_users_permcodes
when making the final granted_user_permcodes list, we need to move the block
that computers this list to the bottom of the whole get_perms_for_forumlist
function.

We also add a test to ensure that all_authenticated_users permissions take
precedence over the default_authenticated_permissions (which possibly come from
settings), which is now the case by doing to code move mentioned above.
The test class sets the can_see_forum permission in
DEFAULT_AUTHENTICATED_USER_FORUM_PERMISSIONS at setup. To make the test
test_knows_that_alluser_permissions_take_precedence_over_alluser_global_permissions
more transparent we do not use can_see_forum to check here but
can_edit_own_posts. Effectively ignoring (not using) the default permissions
setting for this test.

Using can_see_forum obscured the bug in ellmetha#193 because the default permissions
set it to True, passing the check in this test which would not have passed with
a different permission to check that was not elsewhere set to True.
Copy link

@SundialServices SundialServices left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your latest commit of moving stuff to the end broke permissions on my site causing all forums to not-appear. Also: I am still having a problem where forum-categories as a whole are not appearing and/or are appearing as empty. I have no settings concerning these categories but they don't appear at all unless I do. Strangely, not every forum group is like this. After applying the patch, anonymous users saw "no forums." Right now I'm struggling with the problem that some forum-groups show all entries, some are listed but have no content, and some do not appear at all.

KEY DISCOVERY: If a user is "authenticated" but not in any group, he does not see any forum or forum-group which occurs AFTER a forum or forum-bar for which (login) group rules have been defined. They do not appear at all if the user is authenticated but not part of a group. This is the (buggy ...) rule that prevents them from appearing.

@BrendaH
Copy link
Contributor Author

BrendaH commented Mar 18, 2020

KEY DISCOVERY: If a user is "authenticated" but not in any group, he does not see any forum or forum-group which occurs AFTER a forum or forum-bar for which (login) group rules have been defined. They do not appear at all if the user is authenticated but not part of a group. This is the (buggy ...) rule that prevents them from appearing.

Thank you for your testing and feedback. However, I do not seem to be able to reproduce this problem. I'm not totally clear on the issues you're describing.
Could you please describe your forum structure, the structure of your forum permissions and if you have the setting DEFAULT_AUTHENTICATED_USER_FORUM_PERMISSIONS set? And then in which cases the problem occurs.

Because I have just tested with this setup:

categoryforum 1
subcategory 1 (normal type forum)
subcategory 2 (normal type forum)

categoryforum 2
subcategory 2.1 (normal type forum)

Permissions:
categoryforum 1: all_auth_users may see and write, group A may NOT see and write
subforum 1: all_auth_users may see and write
subforum 2: all_auth_users may see and write

categoryforum 2: all_auth_users may see and write
subforum 2.1: no permissions at all

Then a logged in user that is not in any group can see categoryforum 1 and it's content (2 subfora) and see the bar of categoryforum 2 (but not subforum 2.1). So there is a group-permission in place on categoryforum 1, as you describe in your bug report. But still my logged in user (not in any groups) gets to see the bar for categoryforum 2, as expected but if I understand your bug report right then you do not get to see categoryforum 2?
The reason the user may NOT see subforum 2.1 is that django-machina does not inherit permissions. So you have to set permissions on subfora separately. (when I do that for all_auth_users, my user gets to see the subforum as well)

@ellmetha ellmetha merged commit 8d989f6 into ellmetha:master Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants