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

Organizations: Test access from anonymous users and users outside the organization #8603

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Oct 19, 2021

Currently, I'm checking the global option
of ALLOW_PRIVATE_REPOS to give access to public views
to users outside the org.
I'm using the same patter we already have with projects about having a public queryset.

We could introduce a privacy level for the organization if we want.

@stsewd stsewd force-pushed the test-orgs-views-outside-org branch 2 times, most recently from f81720d to 2566107 Compare October 20, 2021 00:13
… organization

Currently I'm checking the global option
of `ALLOW_PRIVATE_REPOS` to give access to public views
to users outside the org.

We could introduce a privacy level for the organization if we want.
@stsewd stsewd force-pushed the test-orgs-views-outside-org branch from 2566107 to 3409571 Compare October 20, 2021 00:32
@stsewd stsewd marked this pull request as ready for review October 20, 2021 00:52
@stsewd stsewd requested a review from a team as a code owner October 20, 2021 00:53
@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Mar 2, 2022
@stale stale bot removed the Status: stale Issue will be considered inactive soon label Mar 2, 2022
@stale
Copy link

stale bot commented May 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label May 2, 2022
@ericholscher
Copy link
Member

@stsewd is this still a valid PR? Seems useful, so we should review it if so.

@stale stale bot removed the Status: stale Issue will be considered inactive soon label May 2, 2022
@stsewd
Copy link
Member Author

stsewd commented May 24, 2022

@stsewd is this still a valid PR? Seems useful, so we should review it if so.

It's, it should be ready now

@ericholscher ericholscher requested review from humitos and removed request for a team May 31, 2022 21:16
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This looks like a solid change. Also asking @humitos for a review to ✅ it, since I'm not 100% the implications here.

We could introduce a privacy level for the organization if we want.

Privacy levels are already quite confusing. We definitely don't want to add more of them unless we really need to.

Return all teams the user has access to.

If ``ALLOW_PRIVATE_REPOS`` is `False`, all teams are public by default.
Otherwise, we return only the teams where the user is a member.
Copy link
Member

Choose a reason for hiding this comment

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

Huh.. do we want teams to always be public? I guess the example here is Orgs & Teams on .org once we enable them. I guess I'm fine defaulting them public, since everything is default public now.

Copy link
Member

Choose a reason for hiding this comment

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

I had the same thought as Eric here. Where, or in which situations, are we going to show these teams to anonymous users?

How do other platforms work here? In GitHub for example, I don't think you have access to see all the teams inside an organization. For example, in ours https://github.com/orgs/readthedocs/people, I don't think we have a way to list backend, frontend and advocate teams there. However, on PRs I can see those teams publicly: #929. When logged in, I can access to its members as well https://github.com/orgs/readthedocs/teams/backend

Another thing that GitHub has related to permissions on teams/organizations is "I want to show publicly that I'm member of this organization". Which adds another layer of complexity here.

I'm just describing how another platform works, I'm not saying we need to implement any of this, but just to keep in mind where are we going with this and how do we want it to work.

return self.filter(
Q(owners__in=[user]) | Q(teams__members__in=[user]),
).distinct()

def for_admin_user(self, user):
"""List all organizations where the user is an owner."""
if not user.is_authenticated:
return self.none()
Copy link
Member

Choose a reason for hiding this comment

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

I assume these are just optimizations?

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

I took a look at this and the changes look fine. However, I'm a little worried about changing the auth logic without understanding exactly why 😄 . Basically, why these changes are needed? What are their benefits? I'm not sure to follow the goal of the PR. Is it just a refactor?

We are now using .public instead of .for_user, but there is nothing extra returned on .public methods since we don't have privacy levels in organizations, so 🤷🏼 . I'm confused...

Return all teams the user has access to.

If ``ALLOW_PRIVATE_REPOS`` is `False`, all teams are public by default.
Otherwise, we return only the teams where the user is a member.
Copy link
Member

Choose a reason for hiding this comment

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

I had the same thought as Eric here. Where, or in which situations, are we going to show these teams to anonymous users?

How do other platforms work here? In GitHub for example, I don't think you have access to see all the teams inside an organization. For example, in ours https://github.com/orgs/readthedocs/people, I don't think we have a way to list backend, frontend and advocate teams there. However, on PRs I can see those teams publicly: #929. When logged in, I can access to its members as well https://github.com/orgs/readthedocs/teams/backend

Another thing that GitHub has related to permissions on teams/organizations is "I want to show publicly that I'm member of this organization". Which adds another layer of complexity here.

I'm just describing how another platform works, I'm not saying we need to implement any of this, but just to keep in mind where are we going with this and how do we want it to work.

def test_private_urls(self):
from readthedocs.organizations.urls.private import urlpatterns

self._test_url(urlpatterns)
Copy link
Member

Choose a reason for hiding this comment

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

Pretty hard to follow all these tests with such magic. None of them seems to do anything different one from the other (just a setting and URLs). I assume that all this magic is inside this method :/

I assume this is fine, tho, to avoid repetition, but... :(

"""
Return all organizations the user has access to.

If ``ALLOW_PRIVATE_REPOS`` is `False`, all organizations are public by default.
Copy link
Member

Choose a reason for hiding this comment

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

I think we should probably rename this to RTD_CORPORATE or something. We have been using this setting to differentiate if we are on .org or .com lately, but it's not what the name suggests.

@@ -72,7 +72,7 @@ def get_organization_queryset(self):
"""
if self.admin_only:
return Organization.objects.for_admin_user(user=self.request.user)
return Organization.objects.for_user(user=self.request.user)
return Organization.objects.public(user=self.request.user)
Copy link
Member

Choose a reason for hiding this comment

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

We don't have the concept of privacy level in Organizations, so I'm not sure these changes make a ton of sense.

@@ -109,7 +109,11 @@ def get_team_queryset(self):
This will either be team the user is a member of, or teams where the
user is an owner of the organization.
"""
return Team.objects.member(self.request.user).filter(
if self.admin_only:
Copy link
Member

Choose a reason for hiding this comment

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

Where are we setting this self.admin_only?

@ericholscher
Copy link
Member

@stsewd would be good to address the review comments here and get this merged, if possible.

@agjohnson
Copy link
Contributor

Ping @stsewd ☝️

We can also push this out some sprints or back on the backlog if it makes sense to return to this later instead.

@stsewd
Copy link
Member Author

stsewd commented Sep 1, 2022

We can also push this out some sprints or back on the backlog if it makes sense to return to this later instead.

I'm fine with that, this isn't a priority for me at the moment, I do want to finish this some time :)

@ericholscher
Copy link
Member

Pushed it back a few sprints 👍

@humitos
Copy link
Member

humitos commented Mar 7, 2023

I'm putting this back into Q2, so we come back to this PR soon.

@agjohnson
Copy link
Contributor

Doing some pruning here. How likely are we to get back to this PR? Is it worth prioritizing in the near future, or should we discuss retiring this work?

@stsewd
Copy link
Member Author

stsewd commented Feb 29, 2024

Doing some pruning here. How likely are we to get back to this PR? Is it worth prioritizing in the near future, or should we discuss retiring this work?

I'm fine closing this, it may be helpful when we decide to introduce organizations in community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

4 participants