-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(publish): read token from stdin #16001
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
feat(publish): read token from stdin #16001
Conversation
cb6b55b to
0010ead
Compare
src/bin/cargo/commands/publish.rs
Outdated
| .get_one::<String>("token") | ||
| .cloned() | ||
| .or_else(|| { | ||
| if std::io::stdin().is_terminal().not() |
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 would really like to know why most windows-based and one mac-based "Test" checks were terminated in Github before I added this not a terminal condition here like in similar implementation in login command. Process hanged waiting input with no input provided? 🤔
weihanglo
left a comment
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 hope I understand the "tests and commits" guidance better this time 🤔)
Yes that seems correct :)
And thank you for the contribution.
0010ead to
a6972e5
Compare
a6972e5 to
1a213cb
Compare
weihanglo
left a comment
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.
Thanks. I'll do an FCP now.
|
@rfcbot fcp merge I'd like to propose we
Note that |
|
Team member @weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
@rfcbot concern behavior-change https://github.com/rust-lang/cargo/pull/16001/files#r2375989885 |
|
https://github.com/rust-lang/cargo/actions/runs/17979102378/job/51140134992?pr=16001 A fix is on the way: #16010 |
…icitly when `login` is run before `publish` (login uses token creds for simplicity)
|
@rfcbot resolve behavior-change |
0xPoe
left a comment
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.
Thanks! ![]()
src/doc/man/cargo-publish.md
Outdated
|
|
||
| This command requires you to be authenticated with either the `--token` option | ||
| or using {{man "cargo-login" 1}}. | ||
| Instead of `--token` option, _token_ value might also be provided via stdin. |
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 was a little confused reading this. I'm wondering if it would help to be more explicit about only reading stdin if it is not a terminal. Maybe something like this?
| Instead of `--token` option, _token_ value might also be provided via stdin. | |
| Instead of using the `--token` option, the _token_ value may be piped in via stdin. |
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 rephrased it a bit more to mention new flag too.
|
@rfcbot concern heuristics I worry that this is making a heavy assumption that in non-interactive environments stdin is connected to I also worry that I understand there is some concern that there would be a lack of symmetry with Can we consider some explicit means of saying "read from stdin"? |
Hi, and thanks for your concern. As I mentioned in a conversation earlier, my main reason for this was to keep token related behavior consistent across cargo commands. However, regarding the main concern I agree that explicitness might be less risky option here. To summarize: yeah, let's make this feature safer with a new command line flag? I'm in 🙂 |
I now wonder if I introduce a new cmd flag to |
If I understand correctly, this is a showcase of the concern mentioned here: #16001 (comment) |
|
In three latest commits I introduced a flag |
|
@rfcbot fcp cancel The team discussed the proposal. The concern raised was that implicitly reading from stdin introduces risks: subprocesses might inadvertently consume the token, and passing stdin through could lead to confusing or unsafe behavior. Unlike We came to the conclusion that we should stick with the original plan of just deprecating the flag, and to not try to read from stdin. Instead, we guide users toward cargo login and environment variables as safer and more explicit mechanisms. Deprecating without a direct replacement also leaves room for users to provide feedback on missing use cases. |
|
@weihanglo proposal cancelled. |
|
@omskscream I really appreicate you trying to add an unstable flag. That is useful. However, as I concluded earlier, instead of speculation, we might want to deprecate it (a warning) without a direct replacement, so we'll know what is missing better. Sorry I should have posted this conclusion earlier before you added more commits 😞. |
|
@weihanglo no problem at all, thanks for letting me know 🙂 I'm contributing to learn Rust and its ecosystem, and I've learned a lot already. Good thing that my PR lead to a team conclusion on how to make things even better. |
FCP comment
What does this PR try to resolve?
Part of #15274
This PR adds support for reading auth token from stdin as an alternative to the existing
--tokencommand line option. This is needed to deprecate the mentioned--tokenoption.Which is, in turn, needed to avoid tokens being saved in shell history.
How to test and review this PR?
Please check added test case in first and second commits to see how behavior changes.
(I hope I understand the "tests and commits" guidance better this time 🤔)
r? @epage