Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Manual token input during login.#124

Merged
creack merged 1 commit intomasterfrom107-auth-input-fallback
Sep 15, 2020
Merged

Conversation

creack
Copy link
Contributor

Loosely based on how concourse ci handles it.

Fixes#107. This makes for a better experience when using the cli over ssh.

Notable change: use the full URL given by the user instead of trimming down the path. This allows for path based reverse proxies.

Copy link
Contributor

@cmoogcmoog left a comment

Choose a reason for hiding this comment

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

First pass. Good thinking with keeping the full URL in the config.

Comment on lines +41 to +42
// From this point, the commandline is correct.
// Don't return errors as it would print the usage.
Copy link
Contributor

Choose a reason for hiding this comment

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

I see what you're getting at here... not sure this is the best approach though. Because usage errors seem like the outlier, we could setSilenceUsage: true and only print the usage when needed.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This seem a bit outside the scope of this PR as it is the way all commands are set. We can create a new PR to improve error management everywhere at once.

cmoog reacted with thumbs up emoji
case <-ctx.Done():
t.Fatal("Timeout waiting for the input.")
case err := <-errChan:
t.Fatalf("ReadLine returned before we got the token (%v).", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

slogtest.Fatal(t, "ReadLine returned before we got the token", slog.Error(err))... same for all other logs.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I think we should stick with stdlib and standard widely used and supported instead of using custom ones. Unless there is some value I am missing? Integration with our co/monitoring/alerting maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

I enjoy using slog since it's able to print the stack frames from the provided error, though I can't say there's much consistency in either direction atm.

case <-ctx.Done():
t.Fatal("Timeout waiting for readline to finish.")
case err := <-errChan:
require.NoError(t, err, "Error reading the line.")
Copy link
Contributor

Choose a reason for hiding this comment

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

assert.Success

return xerrors.Errorf("store config: %w", err)
}

flog.Success("Logged in.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be precede this with a newline? Right now, the output is:

$ coder login https://master.cdr.devor enter token manually: 2020-09-08 16:04:30 SUCCESS    Logged in.

creack reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Added a newline in the prompt before this line. Otherwise, flog's prefix still is on he previous line.

buf := bufio.NewReader(r)

retry:
_, _ = fmt.Fprintf(w, "or enter token manually: ") // Best effort. Can only fail on custom writers.
Copy link
Contributor

Choose a reason for hiding this comment

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

This message doesn't seem descriptive enough... maybe we should include specific direction so the user knows to paste the contents of the URL bar.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This is the same message that concourse ci uses, with the same formatting. We expect most people to not require this part, so I think it might be good enough? I am not really good with words ^^, If you have a suggestion for better wording, I'd be happy to update.

case <-ctx.Done():
t.Fatal("Timeout waiting for the input.")
case err := <-errChan:
t.Fatalf("ReadLine returned before we got the token (%v).", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I enjoy using slog since it's able to print the stack frames from the provided error, though I can't say there's much consistency in either direction atm.

if err != nil {
return xerrors.Errorf("parse url: %v", err)
if l, err = net.Listen("tcp6", "[::1]:0"); err != nil {
return nil, xerrors.Errorf("failed to listen on a port: %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
returnnil,xerrors.Errorf("failed tolisten on a port: %s",err)
returnnil,xerrors.Errorf("listen on a port: %w",err)

creack reacted with thumbs up emoji
@creackcreackforce-pushed the107-auth-input-fallback branch 2 times, most recently from09a3d77 toaafc42aCompareSeptember 15, 2020 17:36
@creackcreack requested a review fromcmoogSeptember 15, 2020 17:37
- Support path based reverse proxy.Signed-off-by: Guillaume J. Charmes <guillaume@coder.com>
@creackcreackforce-pushed the107-auth-input-fallback branch fromaafc42a to8b35b02CompareSeptember 15, 2020 17:40
Copy link
Contributor

@cmoogcmoog left a comment

Choose a reason for hiding this comment

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

The language ofor enter token manually is a bit off, but I don't have any better ideas at the moment. I'd be curious to hear what others think when they try it out after this lands.

@creackcreack merged commit2edd14e intomasterSep 15, 2020
@creackcreack deleted the 107-auth-input-fallback branchSeptember 15, 2020 20:08
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@coadlercoadlercoadler approved these changes

@cmoogcmoogcmoog approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add input while waiting for oauth callback to allow ssh
3 participants
@creack@coadler@cmoog

[8]ページ先頭

©2009-2025 Movatter.jp