-
Notifications
You must be signed in to change notification settings - Fork 55
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
Polish the login flow #11
Conversation
Need to figure out how to add all scopes eventually :)
@@ -42,6 +42,7 @@ type Authenticator struct { | |||
|
|||
type Result struct { | |||
Tenant string | |||
Domain string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We forgot to include this -- ultimately this is the parameter we thread through to the management.New
call (e.g. https://github.com/go-auth0/auth0)
// config defines the exact set of tenants, access tokens, which only exists | ||
// for a particular user's machine. | ||
type config struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In retrospect data
didn't seem clear enough as a type name :)
Name string `json:"name"` | ||
Domain string `json:"domain"` | ||
AccessToken string `json:"access_token,omitempty"` | ||
ExpiresAt time.Time `json:"expires_at"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not using ExpiresAt yet -- but eventually we can use it to determine when to re-trigger a new login.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a backlog item so we don't lose track https://auth0team.atlassian.net/browse/A0CLI-9
if t.BearerToken != "" { | ||
c.api, err = management.New(t.Domain, | ||
management.WithStaticToken(t.BearerToken), | ||
management.WithDebug(c.verbose)) | ||
} else { | ||
if t.AccessToken != "" { | ||
c.api, err = management.New(t.Domain, | ||
management.WithClientCredentials(t.ClientID, t.ClientSecret), | ||
management.WithStaticToken(t.AccessToken), | ||
management.WithDebug(c.verbose)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally we had an if else for M2M or a static token. Given that we've made device flow work already, we can remove this until we decide we need it.
internal/cli/cli.go
Outdated
if c.path == "" { | ||
c.path = path.Join(os.Getenv("HOME"), ".config", "auth0", "config.json") | ||
} | ||
// setTenant assigns an existing, or new tenant. This is expected to be called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setTenant
is the meat of the PR. The rest of the stuff around it is cleanup and code polish.
c.renderer = &display.Renderer{ | ||
Tenant: c.tenant, | ||
MessageWriter: os.Stderr, | ||
ResultWriter: os.Stdout, | ||
Format: display.OutputFormat(format), | ||
} | ||
c.renderer.Format = display.OutputFormat(format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we've already initialized a Renderer
before, we don't really need to do that -- we just need to assign Format, Tenant, etc.
// Once initialized, we'll keep returning the same err that was | ||
// originally encountered. | ||
return c.errOnce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug fix in the UX such that you'll occasionally get Unable to find tenant
errors.
func getLogin(cli *cli) string { | ||
if !cli.isLoggedIn() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UX improvements: this checks if we're logged in and changes / amends the help text in the main auth0
command.
👍TIL
…On Sat, Jan 23, 2021 at 2:29 PM Cyril David ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In internal/cli/cli.go
<#11 (comment)>:
> })
- return err
+ // Once initialized, we'll keep returning the same err that was
+ // originally encountered.
+ return c.errOnce
+}
+
+func (c *cli) initContext() (err error) {
+ if c.path == "" {
+ c.path = path.Join(os.Getenv("HOME"), ".config", "auth0", "config.json")
For context, here's my ~/.config folder after using gh, stripe, shopify:
$ ls ~/.config
@cto.ai auth0 configstore gatsby gh htop jgit shopify stripe
Diving into the dirs:
$ ls ~/.config/gh
config.yml config.yml.bak hosts.yml state.yml
$ ls ~/.config/gh
config.yml config.yml.bak hosts.yml state.yml
$ ls ~/.config/stripe
config.toml
$ ls ~/.config/shopify
config logs
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABK6CDMXREWPWRS4NSULNLS3MBPDANCNFSM4WPLT5HQ>
.
|
Description
Adds the necessary plumbing to persist the login state.