diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b3911..a1f8ab2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Изменения +## 1.7.3 — 2026-11-12 + +Галочка «Запомнить» у пароля SSH-ключа и у пароля репозитория теперь работает и +тогда, когда хранилища секретов ещё нет. + +### Исправления + +- Пароль SSH-ключа с галочкой «Remember in the Go.Git store» не сохранялся, если + хранилище секретов (`vault.bin`) ещё не создано: приложение молча писало + предупреждение в журнал и спрашивало пароль при каждом подключении. Теперь + хранилище создаётся при первом запоминании: на Windows — с ключом DPAPI без + вопросов, на Linux — с ключом из системной связки или с мастер-паролем. + Отмена создания ничего не сохраняет. +- То же исправлено для пароля репозитория по HTTPS с галочкой «Запомнить для + этого ресурса». + ## 1.7.2 — 2026-11-11 Новый движок, текст как в Windows, окна сравнения и разрешения конфликтов diff --git a/README.en.md b/README.en.md index fb060c5..b4a5e51 100644 --- a/README.en.md +++ b/README.en.md @@ -17,7 +17,7 @@ interface. An alternative to the paid SmartGit. window; the layout is remembered. - Localization: Russian and English out of the box, any other language is a single JSON file. -## What 1.7.2 can already do +## What 1.7.3 can already do **Interface.** The menu and toolbar mirror SmartGit; the toolbar is configured in a separate window and stored in `config.toml`. Dock panels: diff --git a/README.md b/README.md index 5c858df..e697c2a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ раскладка запоминается. - Локализация: русский и английский из коробки, любой другой язык — один JSON-файл. -## Что уже умеет 1.7.2 +## Что уже умеет 1.7.3 **Интерфейс.** Меню и панель инструментов повторяют SmartGit; панель настраивается в отдельном окне и хранится в `config.toml`. Док-панели: diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4bd3470..e950ecb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,47 +1,15 @@ -# Go.Git 1.7.2 — Text as in Windows, collapsible compare and conflict windows +# Go.Git 1.7.3 — Remembering passphrases without a secret store -A new engine, text drawn the way Windows is set up, compare and conflict-resolution -windows that collapse their sides and remember how they were left, and main -branches first in the Branches pane. - -## Text - -- The headless-gui engine is updated to v4.5.0 (from v3.43.0). Text follows the - system setting: with ClearType on it uses subpixel smoothing (measured the same as - Windows itself on the same font) with the monitor's subpixel order; in a remote - session (RDP) and with greyscale smoothing it is grey. Turning ClearType on or off - or connecting over RDP changes it at once, without a restart. -- The interface font on Windows is Verdana: at small sizes it reads more clearly - than the former Go Regular. Linux keeps the old font. -- Dialogs and floating panes in their own windows draw text with the same font and - smoothing as the main window. -- On Windows 11 the window and the dialogs no longer show a second frame arc at the - rounded corners: the system draws the frame, accent color included. - -## Compare and conflicts - -- The compare window collapses its left or right side, the border between them can - be dragged, and the window has maximize and minimize buttons. -- The conflict-resolution window collapses Ours, Base and Theirs, shows the result - or the sources at full height, and the border between the top and the result can - be dragged. New: Redo, the All conflicts menu (take ours or theirs in every - unresolved conflict, mark every conflict unresolved again) and separate scrolling. -- Both windows reopen the way they were closed: size, collapsed sides, border, base - pane and joint scrolling are kept in `config.toml`. - -## Branches - -- git-flow develop and master, every server's default branch and the usual main, - master and develop come first in a Main group with their own icon, and first on - every server. The pane menu turns the group off, and selecting obsolete branches - leaves main branches alone. A server default branch such as `release/current` no - longer appears again under Releases. +The "Remember" checkbox in the SSH key passphrase and repository password dialogs +now works when the secret store does not exist yet. ## Fixes -- The installer shows the license text again: since 1.6.1 the license dialog was - empty. -- A failure in a widget or a handler no longer brings the app down: the engine - catches it, and Go.Git logs it once per place, with secrets redacted. -- The layout of a window closed twice (by the window and by the engine) is saved - once. +- An SSH key passphrase entered with "Remember in the Go.Git store" was not saved + when the secret store (`vault.bin`) had not been created: Go.Git only wrote a + warning to its log and asked for the passphrase on every connection. The store + is now created the first time something is remembered: on Windows with a DPAPI + key and no questions, on Linux with a key from the system keyring or with a + master password. Cancelling the setup saves nothing. +- The same fix applies to an HTTPS repository password saved with "Remember for + this resource". diff --git a/USER_GUIDE.md b/USER_GUIDE.md index 9da2b9e..9229d5b 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -355,6 +355,10 @@ git**. - **Файл ключа** — только по явному выбору, для Linux без keyring или для серверов; защита — права доступа к файлу. +Если хранилища ещё нет, оно создаётся при первом включении галочки +«Запомнить» в диалоге пароля SSH-ключа или пароля репозитория; отмена +создания ничего не сохраняет. + Мастер-пароль меняется в том же разделе настроек: нужно ввести текущий пароль и задать новый — старый после этого перестаёт действовать. diff --git a/cmd/gogit/winres/winres.json b/cmd/gogit/winres/winres.json index 35ef057..58749be 100644 --- a/cmd/gogit/winres/winres.json +++ b/cmd/gogit/winres/winres.json @@ -11,7 +11,7 @@ "0409": { "identity": { "name": "Go.Git", - "version": "1.7.2.0" + "version": "1.7.3.0" }, "description": "Go.Git git client", "minimum-os": "win7", @@ -35,8 +35,8 @@ "#1": { "0000": { "fixed": { - "file_version": "1.7.2.0", - "product_version": "1.7.2.0" + "file_version": "1.7.3.0", + "product_version": "1.7.3.0" }, "info": { "0409": { diff --git a/internal/app/credentials.go b/internal/app/credentials.go index 6a9391e..7f49096 100644 --- a/internal/app/credentials.go +++ b/internal/app/credentials.go @@ -363,24 +363,34 @@ func (a *App) askCredentials(ctx context.Context, resource, username string, ret } } -func (a *App) rememberCredential(ctx context.Context, resource, username string, secret []byte) { - v := a.vaultIfOpen() - if v == nil { - a.log.Warn("cannot remember credential: secret store is not set up", "resource", resource) - return +func (a *App) unlockedVaultForRemembering(ctx context.Context) (*vault.Vault, error) { + v, _, err := a.secretsVault(ctx, true) + if err != nil { + return nil, err } if v.Locked() { unlocked, err := a.unlockVault(ctx, v) if err != nil { - a.log.Warn("unlock secret store for credential failed", "resource", resource, "error", err) - return + return nil, err } if !unlocked { - return + return nil, ErrSecretsUnlockCancelled } } + return v, nil +} + +func (a *App) rememberCredential(ctx context.Context, resource, username string, secret []byte) { + v, err := a.unlockedVaultForRemembering(ctx) + if errors.Is(err, ErrSecretsUnlockCancelled) || errors.Is(err, ErrSecretsSetupCancelled) { + return + } + if err != nil { + a.log.Warn("open secret store for credential failed", "resource", resource, "error", err) + return + } cred := vault.Credential{Resource: resource, Username: username, Secret: append([]byte(nil), secret...)} - err := v.SetCredential(cred) + err = v.SetCredential(cred) cred.Wipe() if err != nil { a.log.Warn("save credential failed", "resource", resource, "error", err) diff --git a/internal/app/credentials_test.go b/internal/app/credentials_test.go index 2bbaf88..8012899 100644 --- a/internal/app/credentials_test.go +++ b/internal/app/credentials_test.go @@ -20,6 +20,7 @@ import ( "github.com/oops1/gogit/internal/gitcore/transport" "github.com/oops1/gogit/internal/i18n" "github.com/oops1/gogit/internal/ui/credentials" + "github.com/oops1/gogit/internal/ui/masterpassword" "github.com/oops1/gogit/internal/ui/unlock" "github.com/oops1/gogit/internal/vault" ) @@ -730,13 +731,33 @@ func TestCredentialsSourceRememberGivesUpWhenUnlockIsCancelled(t *testing.T) { } } -func TestCredentialsSourceWithoutASetUpVaultRememberIsANoop(t *testing.T) { +func TestCredentialsSourceWithoutASetUpVaultRememberCreatesTheStore(t *testing.T) { a := newTestApp(t) stubRememberedDialogAnswer(t, a) + stubSecretsDefaultSlotKind(t, vault.SlotPassword) + stubCreateVaultFileWithPassword(t, nil) + stubMasterPasswordDialog(t, a, []masterpassword.Result{{Password: []byte(testVaultPassword)}}) + + rememberAndApprove(t, a) + saved, ok := a.vaultIfOpen().Credential(testResource) + if !ok || saved.Username != "bob" { + t.Fatalf("credential was not saved into the created store: %+v, ok=%v", saved, ok) + } +} + +func TestCredentialsSourceWithoutASetUpVaultRememberStaysSilentWhenSetupIsCancelled(t *testing.T) { + a := newTestApp(t) + buf := captureLog(a) + stubRememberedDialogAnswer(t, a) + stubSecretsDefaultSlotKind(t, vault.SlotPassword) + stubMasterPasswordDialog(t, a, nil) rememberAndApprove(t, a) if _, err := os.Stat(a.paths.VaultFile()); !errors.Is(err, fs.ErrNotExist) { - t.Fatal("remembering must not create a secret store") + t.Fatal("a cancelled setup must not leave a secret store") + } + if buf.Len() != 0 { + t.Fatalf("log = %q, want nothing", buf.String()) } } diff --git a/internal/app/sshkeys.go b/internal/app/sshkeys.go index 1cdc93b..a13d6ab 100644 --- a/internal/app/sshkeys.go +++ b/internal/app/sshkeys.go @@ -137,20 +137,13 @@ func (a *App) askKeyPassphrase(ctx context.Context, req transport.PassphraseRequ var errHostHasAnotherKey = errors.New("app: the host already has another ssh key in the store") func (a *App) rememberKeyPassphrase(ctx context.Context, req transport.PassphraseRequest, passphrase []byte) { - v := a.vaultIfOpen() - if v == nil { - a.log.Warn("cannot remember key passphrase: secret store is not set up", "host", req.Host) + v, err := a.unlockedVaultForRemembering(ctx) + if errors.Is(err, ErrSecretsUnlockCancelled) || errors.Is(err, ErrSecretsSetupCancelled) { return } - if v.Locked() { - unlocked, err := a.unlockVault(ctx, v) - if err != nil { - a.log.Warn("unlock secret store for key passphrase failed", "host", req.Host, "error", err) - return - } - if !unlocked { - return - } + if err != nil { + a.log.Warn("open secret store for key passphrase failed", "host", req.Host, "error", err) + return } if err := storeKeyPassphrase(v, req, passphrase); err != nil { a.log.Warn("save key passphrase failed", "host", req.Host, "key", req.Path, "error", err) diff --git a/internal/app/sshkeys_test.go b/internal/app/sshkeys_test.go index df3db79..a82d9b1 100644 --- a/internal/app/sshkeys_test.go +++ b/internal/app/sshkeys_test.go @@ -8,6 +8,7 @@ import ( "encoding/pem" "errors" "fmt" + "io/fs" "net" "os" "path/filepath" @@ -23,6 +24,7 @@ import ( "github.com/oops1/gogit/internal/i18n" "github.com/oops1/gogit/internal/ui/hostkey" "github.com/oops1/gogit/internal/ui/keypassphrase" + "github.com/oops1/gogit/internal/ui/masterpassword" "github.com/oops1/gogit/internal/ui/unlock" "github.com/oops1/gogit/internal/vault" ) @@ -261,11 +263,43 @@ func rememberWork(a *App) { a.rememberKeyPassphrase(context.Background(), transport.PassphraseRequest{Host: "github.com", Path: "/keys/work"}, []byte("pp-secret")) } -func TestRememberKeyPassphraseNeedsASecretStore(t *testing.T) { +func TestRememberKeyPassphraseCreatesTheSecretStoreWhenItIsMissing(t *testing.T) { a := newTestApp(t) + stubSecretsDefaultSlotKind(t, vault.SlotPassword) + stubCreateVaultFileWithPassword(t, nil) + stubMasterPasswordDialog(t, a, []masterpassword.Result{{Password: []byte(testVaultPassword)}}) + rememberWork(a) + v := a.vaultIfOpen() + if v == nil { + t.Fatal("the secret store was not created") + } + if stored, ok := v.SSHKey("github.com"); !ok || string(stored.Passphrase) != "pp-secret" || stored.Path != "/keys/work" { + t.Fatalf("stored = %+v, %v", stored, ok) + } +} + +func TestRememberKeyPassphraseSavesNothingWhenTheStoreSetupIsCancelled(t *testing.T) { + a := newTestApp(t) + stubSecretsDefaultSlotKind(t, vault.SlotPassword) + stubMasterPasswordDialog(t, a, nil) + log := captureLog(a) + rememberWork(a) + if _, err := os.Stat(a.paths.VaultFile()); !errors.Is(err, fs.ErrNotExist) { + t.Fatalf("stat err = %v, want the store to stay missing", err) + } + if log.Len() != 0 { + t.Fatalf("log = %q, want nothing logged for a cancelled setup", log.String()) + } +} + +func TestRememberKeyPassphraseLogsAStoreItCannotCreate(t *testing.T) { + a := newTestApp(t) + stubSecretsDefaultSlotKind(t, vault.SlotPassword) + stubMasterPasswordDialog(t, a, []masterpassword.Result{{Password: []byte(testVaultPassword)}}) + blockFileWrites(t, a.paths.VaultFile()) log := captureLog(a) rememberWork(a) - if !strings.Contains(log.String(), "secret store is not set up") || strings.Contains(log.String(), "pp-secret") { + if !strings.Contains(log.String(), "open secret store for key passphrase failed") || strings.Contains(log.String(), "pp-secret") { t.Fatalf("log = %q", log.String()) } } @@ -298,7 +332,7 @@ func TestRememberKeyPassphraseLogsAFailedUnlock(t *testing.T) { log := captureLog(a) stubUnlockDialog(t, a, []unlock.Result{{Password: []byte(testVaultPassword)}}) rememberWork(a) - if !strings.Contains(log.String(), "unlock secret store for key passphrase failed") { + if !strings.Contains(log.String(), "open secret store for key passphrase failed") { t.Fatalf("log = %q", log.String()) } }