Skip to content
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

Use git credential helper #1871

Merged

Conversation

ChrisBr
Copy link
Contributor

@ChrisBr ChrisBr commented Aug 8, 2024

Instead of using gh we should use the built in git credential helper to get a valid token. I think we could even get rid of reading the credentials files manually as git should be able to just do this for us.

What we're essentially doing is

> printf "host=github.com\nprotocol=https" | git credential fill
protocol=https
host=github.com
username=3799140
password=TOKEN

Ideally we would even hand down a path so the token could be scoped to a single repository.

https://git-scm.com/docs/gitcredentials

@ChrisBr
Copy link
Contributor Author

ChrisBr commented Aug 8, 2024

Ideally I would like to do something like to scope it to a repository, can we somehow hand the repository down?

printf "host=github.com\nprotocol=https\npath=cargo-bins/cargo-binstall" | git credential fill

Copy link
Member

@NobodyXu NobodyXu left a comment

Choose a reason for hiding this comment

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

Thanks!

According to gh-auth-login doc, the token could be stored in a system credential store, it only fallbacks if it's not available.

I suggest to fallback to git, if gh-auth-token fails

@ChrisBr
Copy link
Contributor Author

ChrisBr commented Aug 8, 2024

@NobodyXu thanks, makes sense.

Do you see a way to scope the token per repository, that's what we're doing in CI for security reason. Or does cargo-binstall need a token valid for all repositories it attempts to download?

@NobodyXu
Copy link
Member

NobodyXu commented Aug 8, 2024

Or does cargo-binstall need a token valid for all repositories it attempts to download?

Yes, it currently just reuses the same github-token for every repository of the crates to install.

@passcod
Copy link
Member

passcod commented Aug 8, 2024

I also want to say that on my system, using printf "host=github.com\nprotocol=https" | git credential fill does not return anything useful, while gh is currently logged in and binstall uses its token.

@ChrisBr
Copy link
Contributor Author

ChrisBr commented Aug 8, 2024

I also want to say that on my system, using printf "host=github.com\nprotocol=https" | git credential fill does not return anything useful

Hum that's interesting. But your git client is authenticated and can push to Github? Or do you use gh for this?

I don't use gh myself and only use plain old git.

@passcod
Copy link
Member

passcod commented Aug 9, 2024

Yes, I can push to git, because that uses ssh keys.

@ChrisBr
Copy link
Contributor Author

ChrisBr commented Aug 9, 2024

Yes, I can push to git, because that uses ssh keys.

Ah got it

@NobodyXu
Copy link
Member

NobodyXu commented Nov 9, 2024

Pinging @ChrisBr

do you want to continue this PR or do you want me to take over?

@ChrisBr
Copy link
Contributor Author

ChrisBr commented Nov 12, 2024

do you want to continue this PR or do you want me to take over?

Please take over but let me know if you run into any issues.

@NobodyXu NobodyXu force-pushed the cbruckmayer/use-git-credential-helper branch from 4372849 to 4a01320 Compare November 13, 2024 14:15
Signed-off-by: Jiahao XU <[email protected]>
@NobodyXu NobodyXu force-pushed the cbruckmayer/use-git-credential-helper branch from 4a01320 to 6e46f66 Compare November 13, 2024 14:19
@NobodyXu NobodyXu requested a review from passcod November 13, 2024 14:20
@NobodyXu NobodyXu added this pull request to the merge queue Nov 18, 2024
Merged via the queue into cargo-bins:main with commit b1aaafc Nov 18, 2024
22 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 19, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cargo-bins/cargo-binstall](https://github.com/cargo-bins/cargo-binstall) | patch | `v1.10.8` -> `v1.10.13` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cargo-bins/cargo-binstall (cargo-bins/cargo-binstall)</summary>

### [`v1.10.13`](https://github.com/cargo-bins/cargo-binstall/releases/tag/v1.10.13)

[Compare Source](cargo-bins/cargo-binstall@v1.10.12...v1.10.13)

*Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for `cargo install` in most cases. Install it today with `cargo install cargo-binstall`, from the binaries below, or if you already have it, upgrade with `cargo binstall cargo-binstall`.*

##### In this release:

-   Use git credential helper for github token auto discovery (can be disabled via `--no-discover-github-token`) ([#&#8203;1871](cargo-bins/cargo-binstall#1871))

##### Other changes:

-   Upgrade transitive dependencies

### [`v1.10.12`](https://github.com/cargo-bins/cargo-binstall/releases/tag/v1.10.12)

[Compare Source](cargo-bins/cargo-binstall@v1.10.11...v1.10.12)

*Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for `cargo install` in most cases. Install it today with `cargo install cargo-binstall`, from the binaries below, or if you already have it, upgrade with `cargo binstall cargo-binstall`.*

##### In this release:

-   Speedup installation script by avoiding additional network trip

##### Other changes:

-   Upgrade dependencies (hickory-dns, thiserror, file-format, etc).

### [`v1.10.11`](https://github.com/cargo-bins/cargo-binstall/releases/tag/v1.10.11)

[Compare Source](cargo-bins/cargo-binstall@v1.10.10...v1.10.11)

*Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for `cargo install` in most cases. Install it today with `cargo install cargo-binstall`, from the binaries below, or if you already have it, upgrade with `cargo binstall cargo-binstall`.*

##### In this release:

-   Upgrade dependencies to fix compilation failures due to yanked dependency fs4 0.10

### [`v1.10.10`](https://github.com/cargo-bins/cargo-binstall/releases/tag/v1.10.10)

[Compare Source](cargo-bins/cargo-binstall@v1.10.9...v1.10.10)

*Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for `cargo install` in most cases. Install it today with `cargo install cargo-binstall`, from the binaries below, or if you already have it, upgrade with `cargo binstall cargo-binstall`.*

##### In this release:

-   Use rc-zip-sync for zip extraction ([#&#8203;1080](cargo-bins/cargo-binstall#1080) [#&#8203;1942](cargo-bins/cargo-binstall#1942))
-   Better UI: default to "yes" for installation prompt, and display more readable message for the prompt ([#&#8203;1943](cargo-bins/cargo-binstall#1943) [#&#8203;1948](cargo-bins/cargo-binstall#1948) [#&#8203;1950](cargo-bins/cargo-binstall#1950) )

##### Other changes:

-   Upgrade dependencies ([#&#8203;1949](cargo-bins/cargo-binstall#1949))

### [`v1.10.9`](https://github.com/cargo-bins/cargo-binstall/releases/tag/v1.10.9)

[Compare Source](cargo-bins/cargo-binstall@v1.10.8...v1.10.9)

*Binstall is a tool to fetch and install Rust-based executables as binaries. It aims to be a drop-in replacement for `cargo install` in most cases. Install it today with `cargo install cargo-binstall`, from the binaries below, or if you already have it, upgrade with `cargo binstall cargo-binstall`.*

##### In this release:

-   Upgrade dependencies

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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