Skip to content

feat: support native credstore in macOS#1680

Open
ayush-panta wants to merge 1 commit intomainfrom
macos-cred-improvements
Open

feat: support native credstore in macOS#1680
ayush-panta wants to merge 1 commit intomainfrom
macos-cred-improvements

Conversation

@ayush-panta
Copy link
Contributor

@ayush-panta ayush-panta commented Jan 20, 2026

Description of changes: This PR contains an architectural rework for credential operations on macOS. This rework came out of necessity in the objective to remove plaintext credential storage for Finch by using the macOS keychain. The solution uses a custom credential helper in the VM in tandem with a credential process on the host to standardize how credentials are securely stored, erased, and retrieved.

Testing done: Unit tests have been included for the majority of added functions. Integration tests have been added under test-e2e-vm-serial that test workflows for credential operations with both osxkeychain and the existing plaintext config. A bug bash has been conducted to confirm the implementation works across comprehensive user-scenarios.

  • I've reviewed the guidance in CONTRIBUTING.md

License Acceptance

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ayush-panta ayush-panta force-pushed the macos-cred-improvements branch 2 times, most recently from c151049 to 7bee38b Compare January 21, 2026 22:31
@ayush-panta ayush-panta marked this pull request as ready for review January 21, 2026 22:52
}

// Start credential server after VM is running (no-op on Windows)
execPath, err := os.Executable()
Copy link
Member

Choose a reason for hiding this comment

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

how this is no op in windows?
How login and logout is handled in windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Windows does not use the finchhost credential helper. Though it runs login/logout on host, they still interface with ~/.finch/config.json. As the nerdctl configuration in VM is effectively untouched for Windows, meaning ~/.finch/config.json is still available in Windows, this still works as expected.

Copy link
Member

Choose a reason for hiding this comment

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

Can we add this to the comment, its unintuitive.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 can you clarify this in the comment, not clear to me

@ayush-panta ayush-panta changed the title feat: improve credential operations on macOS feat: support native credstore in macOS Jan 23, 2026
@ayush-panta ayush-panta force-pushed the macos-cred-improvements branch from e502bb6 to b23336c Compare January 26, 2026 19:22
@ayush-panta ayush-panta force-pushed the macos-cred-improvements branch 3 times, most recently from 2100694 to 368008b Compare January 27, 2026 00:53
Shubhranshu153
Shubhranshu153 previously approved these changes Jan 30, 2026
Signed-off-by: ayush-panta <ayushkp@amazon.com>
Copy link
Contributor

@sondavidb sondavidb left a comment

Choose a reason for hiding this comment

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

Mostly small changes LGTM overall

logrus.WithField("socket", socketPath).Info("Starting credential server")

// Remove stale socket if it exists
_ = os.Remove(socketPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we not throw an error if there is one when removing?

// Create listener and socket
listener, err := net.Listen("unix", socketPath)
if err != nil {
logrus.Fatalf("Failed to create socket: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does logrus failing auto-exit the log process and thus the whole program? If not, we should make sure to explicitly exit as well. (Applicable to a lot of the rest of this file too.)

hostSocket: "{{.Dir}}/sock/finch.sock"
- guestSocket: "/run/user/{{.UID}}/finch-creds.sock"
hostSocket: "{{.Dir}}/sock/creds.sock"
reverse: true No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

newline

}
}

func credHelperDefault(cfg *Finch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add the defaults for Windows?

// The default location of DOCKER_CONFIG is ~/.docker/config.json. This config change sets the location to
// ~/.finch/config.json, but from the perspective of macOS (/Users/<user>/.finch/config.json).
// The default location of DOCKER_CONFIG is ~/.docker/config.json. This config change sets the location in a
// platform-specific manner. On macOS (Lima), this is set to ~/.finch/vm-config/config.json to allow nerdctl to
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Lima technically handles both Windows and Mac. Just that it defers to WSL on Windows.

pid := strings.TrimSpace(string(data))
if !isDaemonRunning(pidFile) {
logrus.Warnf("Stale PID file found (PID: %s), cleaning up", pid)
_ = os.Remove(pidFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we warn if this errors?

cmd.Stdin = strings.NewReader(registryHostname)
output, err := cmd.CombinedOutput()
if err != nil {
// Do not include helper output in error as it may contain credentials
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we avoid leaking credentials in errors anyway?

Might be good to have a sanitation function that comes w/ the credhelper funcs. (Fine as a followup)

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.

3 participants