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

auth logout #1491

Merged
merged 3 commits into from
Aug 6, 2020
Merged

auth logout #1491

merged 3 commits into from
Aug 6, 2020

Conversation

vilmibm
Copy link
Contributor

@vilmibm vilmibm commented Aug 5, 2020

This PR implements gh auth logout. It's very close to the mockup with one minor difference; when
multiple accounts are in hosts.yml the user is prompted to select among hostnames as opposed to
"github.com" vs "github enterprise".

I chose to error when there's nothing in the hosts config or when a host is specified via --hostname
that isn't in the hosts config.

Interactive demo:

logoutInteractive

Noninteractive demo:

logoutNoninteractive

Part of #1413
Depends on #1445

@vilmibm vilmibm added this to Backlog 🗒 in The GitHub CLI via automation Aug 5, 2020
@vilmibm vilmibm requested review from ampinsk and mislav August 5, 2020 22:23
@vilmibm vilmibm moved this from Backlog 🗒 to Needs review 🤔 in The GitHub CLI Aug 5, 2020
@mislav mislav mentioned this pull request Aug 5, 2020
4 tasks
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

Looks great! Awesome job 👏

if showConfirm {
var keepGoing bool
err := prompt.SurveyAskOne(&survey.Confirm{
Message: fmt.Sprintf("Are you sure you want to log out of %s%s?", hostname, usernameStr),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we need this final confirmation if there was a prompt before this. Two prompts make it look as if the user is potentially doing something really dangerous. The worst thing that can happen to a user that has accidentally logged out is that they will have to go through the OAuth flow again when they want to use gh next, which usually takes under a minute.

So if the user typed out gh auth logout and selected a hostname from a list, I think we can assume that they want to logout from that host without any additional safety nets. Thoughts @ampinsk?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Chatted with @ampinsk in our sync and for now we'll leave the confirmation in ✨


mainBuf := bytes.Buffer{}
hostsBuf := bytes.Buffer{}
defer config.StubWriteConfig(&mainBuf, &hostsBuf)()
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessarily something that you have to address here, but I was thinking: now that we have the ability to pass a mock Config when testing a command, and Config is an interface, we could pass our own test stub that conforms to that interface and that verifies that Write was called, but does not actually attempt to write to disk. That way we don't have to rely on package-level function stubbing anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm in favor of reducing package-level function stubbing for sure; here, I like that we're exercising the the part of Write that is taking the yaml tree and actually writing it out. There's just enough logic in there that I'd feel better having coverage for it. I assume we can refactor to have the best of both worlds but I'm not in any rush to do it.

Copy link
Contributor

@mislav mislav Aug 6, 2020

Choose a reason for hiding this comment

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

here, I like that we're exercising the the part of Write that is taking the yaml tree and actually writing it out.

For sure! If Write isn't exercised anywhere else in tests, then it's great to keep it active here. 👍

The GitHub CLI automation moved this from Needs review 🤔 to Needs to be merged 🎉 Aug 6, 2020
@vilmibm vilmibm changed the base branch from auth-cmd to trunk August 6, 2020 17:54
@vilmibm vilmibm merged commit 7f5aad5 into trunk Aug 6, 2020
The GitHub CLI automation moved this from Needs to be merged 🎉 to Pending Release 🥚 Aug 6, 2020
@mislav mislav deleted the auth-logout branch August 11, 2020 17:36
@github-actions github-actions bot moved this from Pending Release 🥚 to Done 💤 in The GitHub CLI Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
The GitHub CLI
  
Done 💤
Development

Successfully merging this pull request may close these issues.

None yet

2 participants