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: Output username and password forcode server --dev#1193

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
mafredri merged 4 commits intomainfrommafredri/dev-mode-credentials
Apr 27, 2022

Conversation

mafredri
Copy link
Member

This PR allows the dev mode credentials (email and password) to be output to the terminal.

Fixes#825

@mafredrimafredri requested review fromjohnstcn anda teamApril 27, 2022 13:08
@codecov
Copy link

codecovbot commentedApr 27, 2022
edited
Loading

Codecov Report

Merging#1193 (e94fdaf) intomain (a769e86) willincrease coverage by0.02%.
The diff coverage is100.00%.

@@            Coverage Diff             @@##             main    #1193      +/-   ##==========================================+ Coverage   66.26%   66.28%   +0.02%==========================================  Files         265      265                Lines       16682    16681       -1       Branches      157      157              ==========================================+ Hits        11054    11057       +3+ Misses       4483     4481       -2+ Partials     1145     1143       -2
FlagCoverage Δ
unittest-go-macos-latest53.61% <100.00%> (-0.07%)⬇️
unittest-go-postgres-65.62% <100.00%> (+<0.01%)⬆️
unittest-go-ubuntu-latest56.22% <100.00%> (+0.05%)⬆️
unittest-go-windows-202253.20% <100.00%> (+0.02%)⬆️
unittest-js66.50% <ø> (ø)
Impacted FilesCoverage Δ
cli/server.go58.91% <100.00%> (-0.08%)⬇️
provisionerd/provisionerd.go76.17% <0.00%> (-0.54%)⬇️
peer/conn.go81.21% <0.00%> (ø)
peer/channel.go84.97% <0.00%> (+1.15%)⬆️
provisioner/echo/serve.go59.20% <0.00%> (+4.80%)⬆️

Continue to review full report at Codecov.

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

@mafredrimafredriforce-pushed themafredri/dev-mode-credentials branch from563b060 tod6410d9CompareApril 27, 2022 13:11
Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

🎉 Two in one day! Just a couple of minor things.

@@ -88,6 +92,9 @@ func TestServer(t *testing.T) {
require.NoError(t, err)
parsed, err := url.Parse(accessURL)
require.NoError(t, err)
// Verify that credentials were output to the terminal.
assert.Contains(t, stdoutBuf.String(), "email: admin@coder.com", "unexpected output")
assert.Contains(t, stdoutBuf.String(), "password: password", "unexpected output")
Copy link
Member

Choose a reason for hiding this comment

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

nit: changemsgAndArgs to be different for both asserts

@@ -88,6 +92,9 @@ func TestServer(t *testing.T) {
require.NoError(t, err)
parsed, err := url.Parse(accessURL)
require.NoError(t, err)
// Verify that credentials were output to the terminal.
assert.Contains(t, stdoutBuf.String(), "email: admin@coder.com", "unexpected output")
Copy link
Member

Choose a reason for hiding this comment

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

minor: should we use the values fromdefaultDevUser instead of hard-coding? This would mean exporting it, but I don't see a huge issue there.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Sure, we can do that. I think hard-coding would be acceptable here too, as changes to the defaults may require rethinking some things, but either works for me.

kylecarbs reacted with thumbs up emoji
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 a fan of hard coding here too. Customers that use the product will likely depend on the credentials, so having tests fail if they change seems reasonable.

@johnstcn
Copy link
Member

I don't think thetest/go failure onubuntu-latest is related to anything we're doing. You can just retry that for now.

mafredri reacted with thumbs up emoji

@mafredrimafredriforce-pushed themafredri/dev-mode-credentials branch frome343748 to3cd7460CompareApril 27, 2022 14:10
@mafredrimafredri merged commit8661f92 intomainApr 27, 2022
@mafredrimafredri deleted the mafredri/dev-mode-credentials branchApril 27, 2022 14:59

// Verify that credentials were output to the terminal.
wantEmail := "email: admin@coder.com"
wantPassword := "password: password"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could exportdefaultDevUser so we could assert the output in tests

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

That's definitely an option, wediscussed it a bit and I added a commit that this this but ultimately dropped it before the merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, I should've read back before I commented!

Comment on lines +78 to +79
var stdoutBuf bytes.Buffer
root.SetOutput(&stdoutBuf)
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit: if you're only ever callingbuffer.String() you can usestrings.Builder to avoid a copy on each call toString()

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good point, I didn't considerstrings.Builder in this scenario although I did note the multiple calls toString() but thought it would be acceptable for a test. Would you like me to do a follow-up PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope! Not important at all, just thought I'd mention.

mafredri reacted with thumbs up emoji
@ammario
Copy link
Member

@mafredri I think the constant password + the external access URL option poses a security risk. I suggest we randomly generate the password to be safe.

Screen Shot 2022-04-27 at 12 31 43 PM

@mafredri
Copy link
MemberAuthor

@ammario I'd be happy to look at fixing that. Should we move this to a new issue to narrow down the specs a bit? For instance, a user might want to override the random password with a self-defined one (thinking about the convenience of logging in). A way to achieve that could be an env variable, or perhaps storing the generated password in a dotfile or similar.

@ammario
Copy link
Member

It's a highly relevant one line fix so I don't think a new issue is necessary.

I'm not sure what the best solution is... Writing to a dotfile makes sense as it achieves both stability and security.

mafredri reacted with thumbs up emoji

@coadler
Copy link
Contributor

I'd probably be against a dotfile approach. Getting the initial login would be harder in ephemeral environments, plus we can't always assume we have a writable fs.

@ammario
Copy link
Member

That's fine... then we could default to a randomly generated one and let an environment variable override. Secure by default, stable if configured.

@coadler
Copy link
Contributor

Seems reasonable to me

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@coadlercoadlercoadler left review comments

@johnstcnjohnstcnjohnstcn approved these changes

@kylecarbskylecarbskylecarbs approved these changes

Assignees

@mafredrimafredri

Labels
None yet
Projects
None yet
Milestone
V2 Beta
Development

Successfully merging this pull request may close these issues.

dev mode launches with no credentials printed to console
6 participants
@mafredri@johnstcn@ammario@coadler@kylecarbs@misskniss

[8]ページ先頭

©2009-2025 Movatter.jp