Skip to content

Commit 66d3efe

Browse files
committed
Ask for a token, not a password
According to [this comment][ref], the usage of a password is currently broken but it is possible to pass an access token instead. This access token is then stored in the configuration file, so adjust the message to ask for an access token, tell the user where then can generate a new one, provide the required scope, qnd do not tell that the value is not stored. [ref]: #2655 (comment)
1 parent c8e68d5 commit 66d3efe

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

features/authentication.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Feature: OAuth authentication
3131
When I type "mislav"
3232
And I type "kitty"
3333
Then the output should contain "github.com username:"
34-
And the output should contain "github.com password for mislav (never stored):"
34+
And the output should contain "github.com access token with scope 'repo' for mislav (generate one at https://github.com/settings/tokens):"
3535
And the exit status should be 0
3636
And the file "~/.config/hub" should contain "user: MiSlAv"
3737
And the file "~/.config/hub" should contain "oauth_token: OTOKEN"
@@ -168,7 +168,7 @@ Feature: OAuth authentication
168168
Given $GITHUB_USER is "mislav"
169169
And $GITHUB_PASSWORD is "kitty"
170170
When I successfully run `hub create`
171-
Then the output should not contain "github.com password for mislav"
171+
Then the output should not contain "github.com access token with scope 'repo' for mislav"
172172
And the file "../home/.config/hub" should contain "oauth_token: OTOKEN"
173173

174174
Scenario: XDG: legacy config found, credentials from GITHUB_USER & GITHUB_PASSWORD
@@ -380,7 +380,7 @@ Feature: OAuth authentication
380380
When I type "mislav"
381381
And I type "kitty"
382382
And I type "112233"
383-
Then the output should contain "github.com password for mislav (never stored):"
383+
Then the output should contain "github.com access token with scope 'repo' for mislav (generate one at https://github.com/settings/tokens):"
384384
Then the output should contain "two-factor authentication code:"
385385
And the output should not contain "warning: invalid two-factor code"
386386
And the exit status should be 0
@@ -438,7 +438,7 @@ Feature: OAuth authentication
438438
When I run `hub create` interactively
439439
When I type "mislav@example.com"
440440
And I type "my pass@phrase ok?"
441-
Then the output should contain "github.com password for mislav@example.com (never stored):"
441+
Then the output should contain "github.com access token with scope 'repo' for mislav@example.com (generate one at https://github.com/settings/tokens):"
442442
And the exit status should be 0
443443
And the file "../home/.config/hub" should contain "user: mislav"
444444
And the file "../home/.config/hub" should contain "oauth_token: OTOKEN"
@@ -466,7 +466,7 @@ Feature: OAuth authentication
466466
When I run `hub fork` interactively
467467
And I type "mislav"
468468
And I type "kitty"
469-
Then the output should contain "git.my.org password for mislav (never stored):"
469+
Then the output should contain "git.my.org access token with scope 'repo' for mislav (generate one at https://git.my.org/settings/tokens):"
470470
And the exit status should be 0
471471
And the file "../home/.config/hub" should contain "git.my.org"
472472
And the file "../home/.config/hub" should contain "user: mislav"

github/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (c *Config) PromptForPassword(host, user string) (pass string) {
163163
return
164164
}
165165

166-
ui.Printf("%s password for %s (never stored): ", host, user)
166+
ui.Printf("%s access token with scope 'repo' for %s (generate one at https://%s/settings/tokens): ", host, user, host)
167167
if ui.IsTerminal(os.Stdin) {
168168
if password, err := getPassword(); err == nil {
169169
pass = password

0 commit comments

Comments
 (0)