Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@samcoe
Copy link
Contributor

@samcoe samcoe commented Feb 24, 2023

This PR breaks up the Config interface and moves authentication methods into the new AuthConfig. This is done to make it easy to implement encrypted token storage. Essentially in any of the auth code we can now use AuthConfig instead of Config. There are no functional changes here and all test changes are done to now stub/mock out AuthConfig instead of Config.

supersedes: #7023
follow up: #7043
cc: #449

@samcoe samcoe self-assigned this Feb 24, 2023
@samcoe samcoe force-pushed the keyring-v2 branch 2 times, most recently from cd185b1 to 5488d0b Compare February 24, 2023 07:14
Comment on lines -38 to -41
// TODO this probably shouldn't live in this package. It should probably be in a new package that
// depends on both iostreams and config.

// FIXME: this duplicates `factory.browserLauncher()`
Copy link
Contributor Author

@samcoe samcoe Feb 24, 2023

Choose a reason for hiding this comment

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

Addressed both of these as part of the refactor by having the AuthFlow take a browser.Browser as an input and moving the writing of the config out of this flow and having the caller be responsible for writing it.

Comment on lines +30 to +34
// This is deprecated and will be removed, do not use!
// Please use cfg.Authentication().Token()
AuthToken(string) (string, string)
// This is deprecated and will be removed, do not use!
// Please use cfg.Authentication().DefaultHost()
DefaultHost() (string, string)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would have removed these but it would have ballooned the size of this PR. Will do it in a follow up cleanup PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +136 to +137
hostsOverride func() []string
tokenOverride func(string) (string, string)
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 tried a new approach here to have the overrides live inside the struct rather than create an interface that can be mocked out. Any function that calls a ghAuth can have an override.

@samcoe samcoe marked this pull request as ready for review February 27, 2023 00:25
@samcoe samcoe requested a review from a team as a code owner February 27, 2023 00:25
@samcoe samcoe requested review from vilmibm and removed request for a team February 27, 2023 00:25
@samcoe samcoe mentioned this pull request Feb 27, 2023
// Login will set user, git protocol, and auth token for the given hostname.
// If the encrypt option is specified it will first try to store the auth token
// in encrypted storage and will fall back to the plain text config file.
func (c *AuthConfig) Login(hostname, username, token, gitProtocol string, encrypt bool) error {
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 assuming the encrypt flag will be implemented in a follow up?

@samcoe samcoe merged commit a33e12a into trunk Feb 27, 2023
@samcoe samcoe deleted the keyring-v2 branch February 27, 2023 23:51
@Samkj94

This comment was marked as spam.

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.

4 participants