Skip to content

API: add project name/slug filters #9843

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

Merged
merged 5 commits into from
Jan 5, 2023
Merged

Conversation

agjohnson
Copy link
Contributor

@agjohnson agjohnson commented Dec 23, 2022

I am trying to use the project API for some search and dropdown filters,
and while I can filter the local results, it's much nicer to use the API
filter for this.

This adds an icontains filter field for project name and slug, and
hopefully some accurate tests.


📚 Documentation previews 📚

I am trying to use the project API for some search and dropdown filters,
and while I can filter the local results, it's much nicer to use the API
filter for this.

This adds an icontains filter field for project name and slug, and
hopefully some accurate tests.
@agjohnson agjohnson requested review from a team as code owners December 23, 2022 21:54
@agjohnson agjohnson requested a review from benjaoming December 23, 2022 21:54
@agjohnson agjohnson requested a review from humitos December 23, 2022 22:02
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 think this is fine as long as we use this filter only over the projects the user is owner/maintainer. Otherwise, it will kill our servers.

@agjohnson
Copy link
Contributor Author

I think this is fine as long as we use this filter only over the projects the user is owner/maintainer. Otherwise, it will kill our servers.

This is a great point, I hadn't thought of that. The intention is to only use this param to filter owner/user projects. However, if we are still allowing public project listing search, someone could abuse this query.

If you have any thoughts on how to secure this more, this might be a good place for you to jump in on this. Seems we could probably truncate the queryset or validate the request somehow, if we're concerned about querying all projects with this.

@agjohnson
Copy link
Contributor Author

Dev docs failure isn't related to this change.

@humitos
Copy link
Member

humitos commented Dec 26, 2022

This is a great point, I hadn't thought of that. The intention is to only use this param to filter owner/user projects. However, if we are still allowing public project listing search, someone could abuse this query.

I think we are fine:

* Always give permission for a ``detail`` request
* Only give permission for ``listing`` request if user is admin of the project

We allow details on all the objects and listing only over the objects the user has access to.

Copy link
Contributor

@benjaoming benjaoming left a comment

Choose a reason for hiding this comment

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

LGTM, perhaps when the print statement is removed, this can go in?

Co-authored-by: Benjamin Balder Bach <[email protected]>
@humitos
Copy link
Member

humitos commented Jan 5, 2023

This is ready to merge 💯

@agjohnson agjohnson merged commit 26765fc into main Jan 5, 2023
@agjohnson agjohnson deleted the agj/api-project-add-filters branch January 5, 2023 17:16
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