Skip to content

2fa#120

Merged
silvin-lubecki merged 1 commit intomainfrom
2fa
Nov 18, 2020
Merged

2fa#120
silvin-lubecki merged 1 commit intomainfrom
2fa

Conversation

@rumpl
Copy link
Member

@rumpl rumpl commented Nov 16, 2020

- What I did

Implemented hub-tool login that handles 2FA.

- How I did it

@silvin-lubecki did the 2FA part, I added the saving of the authentication and the token in the keystore.

- How to verify it

Login:

$ hub-tool login <USERNAME> 

Use hub-tool:

$ hub-tool account info (cut) $ hub-tool repo ls (cut) 

- Description for the changelog

- A picture of a cute animal (not mandatory)
image

@rumpl rumpl force-pushed the 2fa branch 3 times, most recently from 7857173 to 70024d8 Compare November 16, 2020 11:26
Copy link
Member

@chris-crone chris-crone left a comment

Choose a reason for hiding this comment

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

Some minor changes but exciting to see this!

@rumpl rumpl force-pushed the 2fa branch 9 times, most recently from caeae29 to 563cc64 Compare November 16, 2020 16:47
@rumpl rumpl force-pushed the 2fa branch 5 times, most recently from ae61aef to 77884c5 Compare November 18, 2020 15:29
Copy link
Member

@chris-crone chris-crone left a comment

Choose a reason for hiding this comment

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

Only fix needed before LGTM is the annon typo.

cmd := &cobra.Command{
Use: loginName + " USERNAME",
Short: "Login to the Hub",
Args: cli.ExactArgs(1),
Copy link
Member

Choose a reason for hiding this comment

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

In a followup if the user doesn't specify their user name we can prompt them for it

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would they do that? The doc is explicit enough :trollface:

@rumpl rumpl force-pushed the 2fa branch 6 times, most recently from 0cb970c to 31c6a68 Compare November 18, 2020 16:12
@rumpl rumpl force-pushed the 2fa branch 3 times, most recently from c113a0c to 8fa904f Compare November 18, 2020 16:28
return err
}
if ac.TokenExpired() {
return login.RunLogin(streams, hubClient, store, ac.Username)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: I think we shouldn't run a full login here, but just use stored credentials (username and password) to silently renew the token. Maybe in a follow-up?

Copy link
Member Author

Choose a reason for hiding this comment

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

ac, err := store.GetAuth()
if err != nil || ac.Username == "" {
fmt.Println(ansi.Error(`You need to be logged in to Docker Hub to use this tool.
Please login to Docker Hub using the "hub-tool login" command.`))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: Regarding what we do for "sudo" commands, maybe we could run the login command here, then execute the command, instead of erroring out ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'll open a ticket, we'll do it in a followup because it's not a simple change and it's the end of the day

Copy link
Member Author

Choose a reason for hiding this comment

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

Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com> Use credentials helper to store auth configuration Signed-off-by: Djordje Lukic <djordje.lukic@docker.com> Remove useless auth resolver Signed-off-by: Djordje Lukic <djordje.lukic@docker.com> Use docker.Streams instead of the cli Signed-off-by: Djordje Lukic <djordje.lukic@docker.com> Make account info and all PAT commands sudo (require login) Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
Copy link
Collaborator

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM

@silvin-lubecki
Copy link
Collaborator

Thanks for the hard work @rumpl 🤗

@silvin-lubecki silvin-lubecki merged commit 85dc8eb into main Nov 18, 2020
@silvin-lubecki silvin-lubecki deleted the 2fa branch November 18, 2020 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants