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

feat: Login via CLI#298

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bryphe-coder merged 19 commits intomainfrombryphe/feat/210/cli-login
Feb 18, 2022
Merged

feat: Login via CLI#298

bryphe-coder merged 19 commits intomainfrombryphe/feat/210/cli-login
Feb 18, 2022

Conversation

bryphe-coder
Copy link
Contributor

@bryphe-coderbryphe-coder commentedFeb 16, 2022
edited
Loading

Fixes#210 - this isPR implementscoder login in the case where the default user is already created.

This change adds:

  • A prompt in the case where there is not an initial user that opens the server URL + requests a session token
    • This ports over some code from v1 for theopenURL andisWSL functions to support opening the browser
  • A/api/v2/api-keys endpoint that can bePOST'd to in order to request a new api key for a user
    • This route was inspired by the v1 functionality
  • Acli-auth route + page that shows the generated api key
  • Tests for the new code + storybook for the new UI

The/cli-auth route, like in v1, is very minimal:

Screen Shot 2022-02-16 at 5 05 07 PM

And the terminal UX looks like this:

2022-02-16 17 13 29

TODO:

@codecov
Copy link

codecovbot commentedFeb 16, 2022
edited
Loading

Codecov Report

Merging#298 (0d829b3) intomain (e5db936) willincrease coverage by2.66%.
The diff coverage is52.90%.

Impacted file tree graph

@@            Coverage Diff             @@##             main     #298      +/-   ##==========================================+ Coverage   64.81%   67.47%   +2.66%==========================================  Files          67      140      +73       Lines         756     7407    +6651       Branches       74       77       +3     ==========================================+ Hits          490     4998    +4508- Misses        251     1899    +1648- Partials       15      510     +495
FlagCoverage Δ
unittest-go-macos-latest66.15% <55.20%> (?)
unittest-go-ubuntu-latest67.09% <54.40%> (?)
unittest-go-windows-latest65.89% <52.80%> (?)
unittest-js63.61% <30.00%> (-1.21%)⬇️
Impacted FilesCoverage Δ
codersdk/users.go61.22% <0.00%> (ø)
site/components/SignIn/index.tsx0.00% <0.00%> (ø)
site/pages/cli-auth.tsx0.00% <0.00%> (ø)
coderd/users.go58.76% <52.63%> (ø)
cli/login.go60.46% <67.14%> (ø)
coderd/coderd.go95.28% <100.00%> (ø)
site/components/SignIn/CliAuthToken.tsx100.00% <100.00%> (ø)
httpmw/userparam.go76.66% <0.00%> (ø)
coderd/projectversion.go55.22% <0.00%> (ø)
... and69 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatee5db936...0d829b3. Read thecomment docs.

@bryphe-coderbryphe-coder marked this pull request as ready for reviewFebruary 17, 2022 01:14
@bryphe-coderbryphe-coder self-assigned thisFeb 17, 2022
Copy link
Member

@kylecarbskylecarbs left a comment

Choose a reason for hiding this comment

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

Minor nits. Overall, wonderful change!

bryphe-coder reacted with hooray emoji
cli/login.go Outdated
}
}

funcsaveSessionToken(cmd*cobra.Command,client*codersdk.Client,sessionTokenstring,serverURL*url.URL)error {
Copy link
Member

Choose a reason for hiding this comment

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

I'm hesitant to rip this into a distinct function. We already validate the "me" user request above, so feels like that should be reused.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

The alternative is to duplicate the persistence code both in the 'create initial user' and 'login' flows - inlined this function in13696a7

Another thing we could consider is bringing the"me" check above (since it's only required for initial login), and factor out the common save-session-token-and-url logic into this function. Happy with whichever you prefer.

bryphe-coder added a commit that referenced this pull requestFeb 17, 2022
…307)Fixes#304 Unblocks#298 After logging in, the login flow should redirect to a whatever path is specified by the `?redirect` query parameter. This is important for cases like#298 - where we need to set `?redirect=%2Fcli_auth`, but also really any case where the user is linked and might have to go back to the login screen.The fix is simple - just check if the `redirect` query parameter is set, and if it is, use that as the path to redirect to on success. Also adds a test case - we had one checking that we redirect to the default (root `/`) url, but not one of the `?redirect` param
@bryphe-coderbryphe-coder merged commit3f77814 intomainFeb 18, 2022
@bryphe-coderbryphe-coder deleted the bryphe/feat/210/cli-login branchFebruary 18, 2022 04:09
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kylecarbskylecarbskylecarbs 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.

CLI support for login

2 participants

@bryphe-coder@kylecarbs

[8]ページ先頭

©2009-2025 Movatter.jp