Documentation
¶
Overview ¶
Package crosskey provides a unified credential management API that works transparently across Windows, standard Linux, and WSL (Windows Subsystem for Linux).
Backends ¶
The package automatically selects the correct backend at runtime:
Windows (runtime.GOOS == "windows"): delegates to the native Windows Credential Manager via github.com/zalando/go-keyring.
Linux (non-WSL): delegates to the D-Bus Secret Service (GNOME Keyring, KDE Wallet, etc.) via github.com/zalando/go-keyring.
WSL: first attempts the native Linux keyring; if that fails (common when no D-Bus session is available), falls back to bridging into the Windows host by invoking powershell.exe and cmdkey.exe.
Usage ¶
import "github.com/Gankarloo/crosskey"
// Store a credential err := crosskey.Set("my-app", "johndoe", "s3cret")
// Retrieve a credential password, err := crosskey.Get("my-app", "johndoe")
// Delete a credential err = crosskey.Delete("my-app", "johndoe")
Security Considerations ¶
On WSL the package must invoke Windows executables (cmdkey.exe, powershell.exe) with credential material passed as command-line arguments. This means:
- The password is briefly visible in the process list (/proc/*/cmdline).
- Other users on the same WSL instance could potentially observe it.
For environments where this is unacceptable, consider storing secrets exclusively in the native Linux keyring or using an alternative vault.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = fmt.Errorf("crosskey: secret not found")
ErrNotFound is returned when a requested credential does not exist.
Functions ¶
func Delete ¶
Delete removes the credential for the given service and user.
On WSL it first attempts the native Linux keyring; if that fails it transparently falls back to the Windows Credential Manager.
func Get ¶
Get retrieves the password for the given service and user.
On WSL it first attempts the native Linux keyring; if that fails it transparently falls back to the Windows Credential Manager.
func IsWSL ¶
func IsWSL() bool
IsWSL reports whether the current process is running inside Windows Subsystem for Linux. The result is cached after the first call.
func Set ¶
Set stores a credential for the given service and user.
On WSL it first attempts the native Linux keyring; if that fails it transparently falls back to the Windows Credential Manager.
SECURITY NOTE (WSL): the password is passed as a command-line argument to cmdkey.exe and is therefore briefly visible in the process list.
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
crosskey-cli
command
crosskey-cli is a small utility for live-testing the crosskey package.
|
crosskey-cli is a small utility for live-testing the crosskey package. |