go_keepasshttp

module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2019 License: MIT

README

Go KeePassHTTP

version.svg godoc.svg report.svg stability.svg

license.svg travis_build.svg codecov.svg code_size.svg

Go client for KeePassHTTP to interact with KeePass's credentials.

Installation

$ go get -u github.com/cyrbil/go_keepasshttp/keepasshttp

Usage

Initialisation
package main

import (
	"fmt"
	"github.com/cyrbil/go_keepasshttp/keepasshttp"
)

func main() {
	kph := keepasshttp.New()
	...
Get single credential
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)
Find all credentials's name
credentials, err := kph.List()
if err != nil { panic(err) }
for _, credential = range credentials {
    fmt.Printf("Login: %#v", credential.Login)
}
Fetch all partially matching credentials
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)
}
Create a new KeePassHTTP entry
err = kph.Create(&keepasshttp.Credential{
    Login: "hello",
    Password: "world",
    Url: "github.com",
})
if err != nil { panic(err) }
Update a KeePassHTTP entry
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) }

Configuration

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"

Testing

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.kdbx in KeePass password is test
  • set TEST_WITH_KEEPASS environment variable
  • run test normally
  • KeePassHTTP will ask to store new key (enter unittest as name and press yes to overwrite) and yield various messages, this is all normal

Coverage

To run tests with coverage:

$ go get golang.org/x/tools/cmd/cover
$ go test -cover

Directories

Path Synopsis
Package keepasshttp provide tools to see and manipulate KeePass credentials through keePassHTTP plugin.
Package keepasshttp provide tools to see and manipulate KeePass credentials through keePassHTTP plugin.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL