samuong / alpaca

A local HTTP proxy for command-line tools. Supports PAC scripts and NTLM authentication.
Apache License 2.0
196 stars 35 forks source link

Alpaca fails to get credentails from NoMAD/Keychain #32

Closed samuong closed 4 years ago

samuong commented 4 years ago

Even when NoMAD is installed and configured to use the system keychain, Alpaca fails to read the NoMAD configuration and get the credentials out of the keychain. It disables proxy authentication as a result:

main.go:58: NoMAD configuration key not found. Disabling proxy authentication.

When NoMAD app preferences are managed by a configuration profile which means they get written to /Library/Managed Preferences/$USER/com.trusourcelabs.NoMAD.plist. When a user then logs into NoMAD, their particular details get written to /Users/$USER/Library/Preferences/com.trusourcelabs.NoMAD.plist. In this case, UseKeychain gets defined in Managed Preferences and UserPrincipal gets defined in the user's Preferences directory.

Alpaca uses the defaults command to read the configuration, and it looks like this is only reading the plist file in the user's Preferences directory.

A workaround is to manually use defaults write to set UseKeychain to 1 in the user's plist:

defaults write com.trusourcelabs.NoMAD UseKeychain 1