-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add support for package upload from frontend to API #268
Conversation
nihaals
commented
Feb 28, 2021
•
edited
Loading
edited
- CORS
- Add auth endpoint to get token for frontend
- Support token for package upload endpoint
- Add API for fetching current user's teams
- Add API for fetching all communities
- Add API for fetching all categories
- Add current user's username to current user (blocks Add header/nav bar component thunderstore-ui#44)
- Add upload limits (e.g. max upload size)
Codecov Report
@@ Coverage Diff @@
## master #268 +/- ##
==========================================
- Coverage 83.77% 83.17% -0.61%
==========================================
Files 93 94 +1
Lines 2971 2900 -71
Branches 307 312 +5
==========================================
- Hits 2489 2412 -77
- Misses 399 403 +4
- Partials 83 85 +2
Continue to review full report at Codecov.
|
CORS might only be required for when the frontend is hosted on another domain (so not during the frontend migration period) but it eases development and will be needed at some point (this PR should set most of the foundations needed for the full transition). |
Categories might be a bit complicated, at least on the frontend side. If you give a list of categories when uploading a package, can't those categories only be applied to a single community's listing as a category has a single parent community? Is it expected to fetch the list of categories for the current community and just not add any categories for the others? Maybe this could be made more clear on the frontend or change how communities/categories are supplied when uploading a package. |
api_experimental_urls = [ | ||
path( | ||
"", | ||
include((experimental_urls, "api-experimental"), namespace="api-experimental"), | ||
include( | ||
(repository_experimental_urls, "api-experimental"), | ||
namespace="api-experimental", | ||
), | ||
), | ||
path( | ||
"", | ||
include(community_experimental_urls), | ||
), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be improved
696e376
to
d8200f3
Compare
Somehow the new push (7ee8917) hasn't triggered anything (CI or an update of this PR) |
It looks like this PR managed to break due to me updating it at the same time as the GitHub outage |
7ee8917
to
a13df8c
Compare
Looks like this was fixed after rebasing |
I'm not sure what tests are needed for the API and if old tokens need clearing (see OP) but the functionality is complete and I've tested each endpoint manually |
A possible issue is that tokens can't be revoked. Clearing all tokens on log out doesn't really make sense since there isn't any metadata stored linking a session and a token. |
We could change to our own Token model, it's relatively straight forward to extend the one provided by DRF |
And store the session ID with the token then validate the session ID is valid? |
I wouldn't even tie sessions into tokens to be honest, we'll get rid of sessions entirely eventually and just use tokens in their place |
This would just be while React components are used in templates. Right now you're able to generate a token using a session but they're not tied to anything but using a session would mean if you logged out it would be revoked and all the other session features would apply. I'm not really sure what else to use without over complicating things for just a transition patch. Another idea, again tied to sessions, could be sign the session ID with something like |
This uses |
The slight hackiness of the internal value:
Doesn't actually make me feel too uncomfortable as with a few tests this will be very reliable and updating Django shouldn't be something concerning. There might also be a better way to get the user. I'll look at the session middleware and see what it uses. |
I'll add tests for the create token endpoint once we decide if we're keeping it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the session token solution here 👍