-
Notifications
You must be signed in to change notification settings - Fork 983
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
One time use project upload token #6935
Conversation
…these in as caveat permissions instead.
This reverts commit 77183f7.
warehouse/legacy/api/pypi.py
Outdated
except InvalidMacaroon: | ||
raise HTTPUnauthorized() | ||
user = macaroon_service.find_userid( | ||
request.master_key |
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 see that this master_key
attribute gets mocked in the tests, but I can't find where it actually appears in the (real) request object. Does it get set anywhere, or is this WIP?
Uses the auth framework and leans on the session/active request user where possible, reuses the macaroon creation form used in the UI, adds appropriate event recording, and propagates errors as a JSON response. Removes "one-time" tokens pending a refactor.
This PR now contains a few different features:
|
Some notes:
|
@rcipkins @woodruffw I suspect this is the kind of feature that could use a sentence of explanation in https://pypi.org/help/#apitoken . |
Could be coming from the generic forbidden view: A more specific view_config (using a specific exception as |
macaroon_service = request.find_service(IMacaroonService, context=None) | ||
|
||
form = CreateMacaroonForm( | ||
**payload, |
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.
Passing **
from attacker provided JSON is a risky move. It lets the attacker control which args are provided. If CreateMacaroonForm
adds a new optional argument this can turn into a vulnerability. It ought to be passed as data=payload
or explicitly unpacked.
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.
Yep, excellent point. This PR needs a decent amount of reworking (and discussion, w/r/t to the semantics of "one time use" for uploads of multiple files per release).
I'm going to pick the core functionality out of this PR and include it in #10888. Closing. |
Created a one time user scoped token for project uploads. Implemented as a caveat. #6378