GoKwallet is a Golang library to interface with Kwalletd via DBus. https://pkg.go.dev/r00t2.io/gokwallet
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
brent s. 820d255773
quick todo
11 months ago
.ref walletmanager funcs done, now for wallet funcs 12 months ago
.gitignore initial commit 12 months ago
LICENSE skeleton work 12 months ago
README.adoc tests pass; tagging release 11 months ago
TODO quick todo 11 months ago
blob_funcs.go tests done 11 months ago
blob_funcs_test.go tests done 11 months ago
consts.go all Dbus methods covered. 12 months ago
consts_test.go tests pass; tagging release 11 months ago
doc.go tests pass; tagging release 11 months ago
errs.go checking in for tests 12 months ago
folder_funcs.go tests pass; tagging release 11 months ago
folder_funcs_test.go tests pass; tagging release 11 months ago
funcs.go walletmanager funcs done, now for wallet funcs 12 months ago
go.mod checking in for tests 12 months ago
go.sum checking in for tests 12 months ago
map_funcs.go tests pass; tagging release 11 months ago
map_funcs_test.go tests done 11 months ago
multierror_funcs.go checking in for tests 12 months ago
password_funcs.go tests done 11 months ago
password_funcs_test.go tests done 11 months ago
types.go checking in for tests 12 months ago
types_test.go tests done 11 months ago
unknownitem_funcs.go tests done 11 months ago
unknownitem_funcs_test.go tests done 11 months ago
utils.go tests pass; tagging release 11 months ago
utils_test.go tests done 11 months ago
wallet_funcs.go tests pass; tagging release 11 months ago
wallet_funcs_test.go tests pass; tagging release 11 months ago
walletmanager_funcs.go tests done 11 months ago

README.adoc

gokwallet

Table of Contents
gokwallet

Package gokwallet serves as a Golang interface to KDE’s KWallet.

Note that to use this library, the running machine must have both Dbus and kwalletd running.

Relatedly, note also that this library interfaces with kwalletd. KWallet is in the process of moving to libsecret/SecretService (see here and here), thus replacing kwalletd. While there is a pull request in place, it has not yet been merged in (and it may be a while before downstream distributions incorporate that version). However, when that time comes I highly recommend using my gosecret library to interface with that (module r00t2.io/gosecret).

1. KWallet Concepts

For reference, KWallet has the following structure (modified slightly to reflect this library):

  • A main Dbus service interface ("org.kde.kwalletd5"), WalletManager, allows one to retrieve and operate on/with Wallet items.

  • One or more Wallet items allow one to retrieve and operate on/with Folder items.

  • One or more Folder items allow one to retrieve and operate on/with Passwords, Maps, BinaryData, and UnknownItem WalletItem items.

Thus, the hierarchy (as exposed by this library) looks like this:

WalletManager
├─ Wallet "A"
│	├─ Folder "A_1"
│	│	├─ Passwords
│	│	│	├─ Password "A_1_a"
│	│	│	└─ Password "A_1_b"
│	│	├─ Maps
│	│	│	├─ Map "A_1_a"
│	│	│	└─ Map "A_1_b"
│	│	├─ BinaryData
│	│	│	├─ Blob "A_1_a"
│	│	│	└─ Blob "A_1_b"
│	│	└─ Unknown
│	│		├─ UnknownItem "A_1_a"
│	│		└─ UnknownItem "A_1_b"
│	└─ Folder "A_2"
│		├─ Passwords
│		│	├─ Password "A_2_a"
│		│	└─ Password "A_2_b"
│		├─ Maps
│		│	├─ Map "A_2_a"
│		│	└─ Map "A_2_b"
│		├─ BinaryData
│		│	├─ Blob "A_2_a"
│		│	└─ Blob "A_2_b"
│		└─ Unknown
│			├─ UnknownItem "A_2_a"
│			└─ UnknownItem "A_2_b"
└─ Wallet "B"
    └─ Folder "B_1"
        ├─ Passwords
        │	├─ Password "B_1_a"
        │	└─ Password "B_1_b"
        ├─ Maps
        │	├─ Map "B_1_a"
        │	└─ Map "B_1_b"
        ├─ BinaryData
        │	├─ Blob "B_1_a"
        │	└─ Blob "B_1_b"
        └─ Unknown
            ├─ UnknownItem "B_1_a"
            └─ UnknownItem "B_1_b"

This is an approximation, but should show a relatively accurate representation of the model. Note that most systems are likely to only have a single wallet, "kdewallet".

2. Usage

Full documentation can be found via inline documentation. Additionally, use either https://pkg.go.dev/r00t2.io/gokwallet or https://pkg.go.dev/golang.org/x/tools/cmd/godoc (or go doc) in the source root.

You most likely do not want to call any New<object> function directly; NewWalletManager with its RecurseOpts parameter (recursion) should get you everything you want/need.

Here’s a quick demonstration:

package main

import (
	`fmt`
	`log`

	`r00t2.io/gokwallet`
)

func main() {

	var err error
	var r *gokwallet.RecurseOpts
	var wm *gokwallet.WalletManager
	var w *gokwallet.Wallet
	var f *gokwallet.Folder
	var p *gokwallet.Password

	r = gokwallet.DefaultRecurseOpts
	r.AllWalletItems = true

	if wm, err = gokwallet.NewWalletManager(r, "ExampleKWalletApplication"); err != nil {
		log.Panicln(err)
	}

	w = wm.Wallets["kdewallet"]

	f = w.Folders["Passwords"]

	if p, err = f.WritePassword("test_password", "this is a test password"); err != nil {
		log.Panicln(err)
	}

	fmt.Println(p.Value)
}