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

Disable interactive credential prompt for git resolver #411

Conversation

straight-shoota
Copy link
Member

Resolves #316

Git repository requests over HTTP can result in 401 Authentication Required status code. This is typically the case when a repository is private. Some git providers also return this status code when a repository exists to avoid disclosing the existence of private repositories.
By default, git clone prompts for credentials when it receives a 401 status code. When shards install uses git clone, this leads to unexpected and misleading behaviour. shards install is not meant to be used interactively, so this prompt should be completely disabled.

This PR implements this by using the environment variable GIT_ASKPASS set to a value resulting in false. It can still be overriden by setting the environment variable.

src/resolvers/git.cr Outdated Show resolved Hide resolved
@straight-shoota
Copy link
Member Author

The option doesn't need to be an absolute path. I also changed it to true because that's the minimal reduced value and should work in any shell (test probably too, but we don't really need a test here).
I also changed from using the environment variable GIT_ASKPASS to the git config setting core.askPass because that seems cleaner. Overriding is still possible by setting the environment variable because it has precedence over the config setting.

@jhass
Copy link
Member

jhass commented Jun 18, 2020

Maybe add a comment explaining this both :)

I read the diff first and was very confused, as you need to know that the setting takes a command rather than a boolean value and that it's still overridable :)

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

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

So counterintuitive to read core.askPass=true as do not ask me for credentials. 😅

@bcardiff bcardiff merged commit 1ea91ea into crystal-lang:master Jun 25, 2020
@straight-shoota straight-shoota deleted the fix/disable-git-credentials-prompt branch June 25, 2020 15:08
@waj waj added this to the v0.12.0 milestone Jul 28, 2020
taylor pushed a commit to vulk/shards that referenced this pull request Aug 11, 2020
)

* Disable interactive credential prompt for git resolver

* Simplify ASKPASS

* Add comment
f-fr pushed a commit to f-fr/shards that referenced this pull request Jan 2, 2021
)

* Disable interactive credential prompt for git resolver

* Simplify ASKPASS

* Add comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"shards install" halts asking for github username
4 participants