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

Raise forbidden error if un authenticated users load email api. #1548

Merged
merged 2 commits into from
Feb 27, 2019

Conversation

newswangerd
Copy link
Member

fixes: #1522

class UserEmailList(base_views.SubListAPIView):
model = EmailAddress
serializer_class = serializers.EmailSerializer
parent_model = User
relationship = 'emailaddress_set'

def get_queryset(self):
deny_anonymous_users(self.request.user)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be handled in access.py

Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely get_queryset() is not the best place for checking user permissions.
Please use permission_classes = (IsAuthenticated,)

class UserEmailList(base_views.SubListAPIView):
model = EmailAddress
serializer_class = serializers.EmailSerializer
parent_model = User
relationship = 'emailaddress_set'

def get_queryset(self):
deny_anonymous_users(self.request.user)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely get_queryset() is not the best place for checking user permissions.
Please use permission_classes = (IsAuthenticated,)

@newswangerd newswangerd merged commit e0b7f94 into ansible:devel Feb 27, 2019
newswangerd added a commit to newswangerd/galaxy that referenced this pull request Feb 27, 2019
…ble#1548)

* Raise forbidden error if un authenticated users load email api.

* Switch to using permission classes.

(cherry picked from commit e0b7f94)
newswangerd added a commit that referenced this pull request Feb 27, 2019
… (#1592)

* Raise forbidden error if un authenticated users load email api.

* Switch to using permission classes.

(cherry picked from commit e0b7f94)
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.

500 Server Error from /api/v1/emails/
3 participants