2017 © Pedro PelĂĄez
 

library keepasshttpclient

PHP library for KeePassHTTP

image

valicek1/keepasshttpclient

PHP library for KeePassHTTP

  • Saturday, January 21, 2017
  • by Valicek1
  • Repository
  • 1 Watchers
  • 1 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

KeePassHTTPClient

Requirements

Install

Best way is to install with composer, (*1)

$ composer require valicek1/keepasshttpclient

Sample code

# load key and it's id
$secret = loadKey(); // you need to implement this by yourself

# create class
# $secret[0] is 256-bit (32 characters) long key
# $secret[1] contains key id
$kpx = new KeePassHTTPClient($secret[1], $secret[0]);

# is the key associated with DB?
if (!$kpx->testAssociated()) {
    # if not, try to authorize
    $label = $kpx->authorizeKey();
    # and save key + label for next use
    saveKey($label, $secret[1]); // you need to implement this yourself
}

if ($kpx->testAssociated()) {
  // you are welcome to do something in database
  $url = "https://skype.com";

  // get logins
  $logins = $kpx->getLogins($url, $url); // first URL is page URL, second one is Submit url for "form"

  // or just their count
  $count = $kpx->getLoginsCount($url, $url)

  // or create new pairs in database
  $kpx->setLogin($url, $url, "username", "realPassword") 

}

Technological process

Pairing with KeePass

  1. testAssociated - optional
  2. authorizeLey, save key id returned - for future request
  3. testAssociated - if succeeds, you can continue by sending requests

Requests

Server requires testAssociated at the beginning of every new session, or after failure. There is written you have to do it, but personally, I haven't seen any difference in KeepassHTTP's behaviour without testAssociated, (*2)

  1. testAssociated - before first request
  2. getLoginsCount, getLogins or setLogin - work with data

Documentation

Constructor

/**
 * KeePassHTTPClient constructor.
 * @param string $key Encryption key, 256 bits
 * @param string $label Label (product of association)
 * @param string $address KeepassHTTP listening address
 * @param int    $port KeepassHTTP listening port
 */
public function __construct($key, $label = "", $address = "localhost", $port = 19455){}

Getters

public function getAddress(){} // address of server
public function getPort(){} // port of server
public function isAssociated(){} // state of last testAssociated
public function getClient(){} // return guzzle client

Functions to work with KeePass

public function isServerListening(){} // check, if port is opened
public function sendRequest($json){} // json encode $json and send it as request. Return json object of response
public function testAssociated($empty = FALSE){} // test if key is associated or server responding (empty = TRUE)
public function authorizeKey(){} // authorize key (from constructor)
public function getLogins($url, $redirectUrl){} // find logins/passwords for entered criteria.
public function getLoginsCount($url, $redirectUrl){} // count number of items for entered criteria
public function setLogin($url, $redirectURL, $login, $password){} // save login to KeePass DB

It's not much pretty, but enough for using. You can still look into source.., (*3)

The Versions

21/01 2017

dev-master

9999999-dev

PHP library for KeePassHTTP

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

21/01 2017

v1.0.1

1.0.1.0

PHP library for KeePassHTTP

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires

 

03/11 2016

v1.0.0

1.0.0.0

PHP library for KeePassHTTP

  Sources   Download

GPL-3.0 BSD-3-Clause GPL-2.0

The Requires