-
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
base: master
Are you sure you want to change the base?
feat(publish): read token from stdin #16001
Conversation
cb6b55b
to
0010ead
Compare
.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? 🤔
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
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 |
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!
|
||
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. |
@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 🙂 |
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
--token
command line option. This is needed to deprecate the mentioned--token
option.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