Repository navigation
fix(cli): honour the self-signed setting when signing in with a password - #2081
Merged
Merged
Conversation
The endpoint check before sign-in trusted a self-signed certificate when the current session allowed it, but the sign-in client did not, so the request that followed the passing check failed TLS. The new session was also written without the setting, so later commands would have failed the same way. login now builds its client with the setting, stores it on the session it creates, and takes --self-signed (same true/false form as client) so a self-signed instance can be signed in to without a prior client call.
🟢 Tier S · Ready to merge
This pull request adds Latest changes: The latest commit distinguishes an omitted
📂 Walkthrough · 2
✅ Fixed since the last review · 1
Reviewed the commits since |
2 tasks
An empty value was indistinguishable from the flag being omitted, so --self-signed= silently fell back to the stored preference instead of being rejected like any other value that is not true or false.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Self-hosted email/password sign-in failed against an instance with a self-signed certificate.
loginchecked the endpoint with the current session'sselfSignedpreference, soappwrite client --self-signed truefollowed byappwrite login --endpoint https://self-hosted/v1passed the/health/versioncheck, butloginWithPasswordbuilt its client withoutSetSelfSigned, soPOST /account/sessions/emailthen failed withx509: certificate signed by unknown authority. The session it created was also written withoutselfSigned, so every later command would have hit the same TLS error even if sign-in had worked.Changes in
templates/cli/internal/cmd/login.go:/accountlookup reuse that client, so they get it too.selfSigned: truewhen the setting is on, soconsoleClientand token refresh pick it up afterwards.logintakes--self-signed true|false, in the same string form asclient --self-signed. A self-signed instance can now be signed in to in one command. When the flag is set it overrides the stored preference. It is rejected with--switchand against Cloud, the same way--password,--mfaand--codeare.Test Plan
New tests in
templates/cli/internal/cmd/login_test.gorun againsthttptest.NewTLSServer:TestLoginSignsInWithTheStoredSelfSignedPreferencefailed onmainwithPost "https://127.0.0.1:.../account/sessions/email": tls: failed to verify certificate: x509: certificate signed by unknown authorityafter the endpoint check had passed. It passes with this change.TestLoginSignsInWithTheStoredSelfSignedPreferenceandTestLoginSelfSignedFlagWorksWithoutAPriorClientCallboth fail, which shows that the persistence assertion catches a missing write.clientcall,--self-signed falseoverriding a storedtrue, MFA over a self-signed certificate, invalid values, and rejection with Cloud and with--switch.Steps run locally:
php example.php cli, then inexamples/cli:go mod tidy,gofmt -l .(clean),go build ./...,go vet ./...andgo test -race ./...all pass. The only failure was the known watcher flake,TestWatcherIgnoresUnchangedSavesWhileTreeIsBusy, which passed on re-run.composer lint-twig,composer refactor:checkandmax-line-length.shpass.Related PRs and Issues
None. The issue was found by reading the code and is reproduced by the regression test above.
Closes #2082