Skip to content

fix(ctxutil): restore password callback hook for embedded age prompts - #3590

Merged
dominikschulz merged 3 commits into
masterfrom
copilot/bring-back-ctxutil-withpasswordcallback
Sep 9, 2026
Merged

dominikschulz merged 3 commits into
masterfrom
copilot/bring-back-ctxutil-withpasswordcallback

Conversation

Copilot AI commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Library consumers lost the ctxutil.WithPasswordCallback hook in 1.17.0, which removed the supported way to intercept age identity passphrase prompts and route them through host-provided UI. This change restores that embedding path without changing the default interactive CLI flow.

  • Restore public callback API

    • Reintroduce ctxutil.PasswordCallback and ctxutil.PasswordPurgeCallback
    • Reintroduce With/Has/GetPasswordCallback and With/Has/GetPasswordPurgeCallback
    • Preserve the previous default behavior of GetPasswordCallback by returning ErrNoCallback when unset
  • Wire callbacks back into the age backend

    • Teach internal/backend/crypto/age.New to pick up password and purge callbacks from the context
    • Keep WithAgePassphrase support for fixed non-interactive passphrases
    • Prefer the explicit callback when both a callback and static age passphrase are present
  • Document the embedding contract

    • Update pkg/gopass godoc to point embedders to ctxutil.WithPasswordCallback for interactive passphrase handling
    • Clarify that WithAgePassphrase remains the fixed-passphrase alternative

Example:

ctx := context.Background()

ctx = ctxutil.WithPasswordCallback(ctx, func(prompt string, confirm bool) ([]byte, error) {
	return []byte(myUIReadPassphrase(prompt, confirm)), nil
})

ctx = ctxutil.WithPasswordPurgeCallback(ctx, func(_ string) {
	myUIClearCachedPassphrase()
})

Copilot Agent and others added 2 commits September 7, 2026 09:39
Co-authored-by: dominikschulz <1449175+dominikschulz@users.noreply.github.com>
Co-authored-by: dominikschulz <1449175+dominikschulz@users.noreply.github.com>
Copilot AI changed the title [WIP] Bring back ctxutil.WithPasswordCallback function fix(ctxutil): restore password callback hook for embedded age prompts Sep 7, 2026
Copilot AI requested a review from dominikschulz September 7, 2026 09:46
@dominikschulz
dominikschulz marked this pull request as ready for review September 7, 2026 09:57
@dominikschulz
dominikschulz merged commit 044afdb into master Sep 9, 2026
8 of 9 checks passed
@dominikschulz
dominikschulz deleted the copilot/bring-back-ctxutil-withpasswordcallback branch September 9, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replacement for ctxutil.WithPasswordCallback?

2 participants

⌂ 换网址