Go client for KeePassHTTP to interact with KeePass's credentials.
$ go get -u github.com/cyrbil/go_keepasshttp/keepasshttp package main import ( "fmt" "github.com/cyrbil/go_keepasshttp/keepasshttp" ) func main() { kph := keepasshttp.New() ... credential, err := kph.Get(&keepasshttp.Filter{Url: "my_credential_name_or_url"}) if err != nil { panic(err) } fmt.Printf("Login: %#v - Password: %#v", credential.Login, credential.Password) credentials, err := kph.List() if err != nil { panic(err) } for _, credential = range credentials { fmt.Printf("Login: %#v", credential.Login) } credentials, err = kph.Search(&keepasshttp.Filter{ SubmitUrl: "github.com", // Filter has other useful fields }) if err != nil { panic(err) } for _, credential := range credentials { fmt.Printf("Login: %#v - Password: %#v", credential.Login, credential.Password) } err = kph.Create(&keepasshttp.Credential{ Login: "hello", Password: "world", Url: "github.com", }) if err != nil { panic(err) } credential.Password = "new password" err = credential.Commit() if err != nil { panic(err) } // or err = kph.Update(&keepasshttp.Credential{ Uuid: credential.Uuid, Login: "hello", Password: "world", Url: "github.com", }) if err != nil { panic(err) } By default, this module will write AES association key to ~/.go_keepass_http and use http://localhost:19455/ to connect to the KeePassHTTP server.
To change theses parameters, instantiate keepasshttp.KeePassHTTP with different values.
kph := keepasshttp.New() kph.Storage = "file.bin" kph.Url = "http://remote/keepasshttp/server" You can simply run the tests using:
$ cd keepasshttp $ go test KeePassHTTP calls are mocked, to run the tests against a real server, you need to:
- open
tests/test_database.kdbxinKeePasspassword istest - set
TEST_WITH_KEEPASSenvironment variable - run test normally
KeePassHTTPwill ask to store new key (enterunittestas name and pressyesto overwrite) and yield various messages, this is all normal
To run tests with coverage:
$ go get golang.org/x/tools/cmd/cover $ go test -cover