2017 © Pedro PelĂĄez
 

library phpsst

A PHP library for distributing (one time) passwords/secrets in a more secure way

image

felixsand/phpsst

A PHP library for distributing (one time) passwords/secrets in a more secure way

  • Sunday, December 31, 2017
  • by felixsand
  • Repository
  • 1 Watchers
  • 0 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

PhPsst

Latest Stable Version Build Status License Scrutinizer Code Quality Code Coverage, (*1)

A PHP library for distributing (one time) passwords/secrets in a more secure way, (*2)

Installation

Add the package as a requirement to your composer.json:, (*3)

$ composer require felixsand/phpsst

Usage

<?php
use PhPsst\PhPsst;
use PhPsst\Storage\FileStorage;

$phPsst = new PhPsst(new FileStorage('data/passwords', 10));
$secret = $phPsst->store('my secret password');
echo "Retrieve the password from: https://example.net/get-password?secret={$secret}";

```php <?php use PhPsst\PhPsst; use PhPsst\Storage\FileStorage;, (*4)

$phPsst = new PhPsst(new FileStorage('data/passwords', 10)); $decryptedPassword = $phPsst->retrieve($_GET['secret']); echo "The password stored: {$decryptedPassword}";, (*5)


## Storage Classes ### FileStorage The most basic of the storage classes is the FileStorage. It's also (generally) the most insecure and if you store a lot of passwords there's a performance issue due to the garbage collector being very crude. It is however the easiest way to try out the library and useful during development. The constructor parameter $gcProbability is a value from 0 and up, where 0 disables the GC; 1 means it's run for every file write; 10 means it got a 10% probability of running; etc. It's not recommended to turn it off. ```php $phPsst = new PhPsst(new FileStorage('data/passwords', 10));

RedisStorage

The recommended production storage class is the RedisStorage. It has great performance even during heavy use and since it removes the passwords with expired TTL automatically, it's more secure than the other options. It's important to note that if you're not reviewing the Redis configuration, it might purge entries even before the item's TTL has expired (if it's memory limit is reached) and the items will only live for as long as the server is running. This might be desired properties in certain cases, but you need to be aware of it when setting up the solution., (*6)

$redis = new \Predis\Client(array(
    'host' => '10.0.0.1',
    'port' => 6380,
));
$phPsst = new PhPsst(new RedisStorage($redis));

SqLiteStorage

If you don't have access to Redis, another storage engine that is suitable for production use is the SqLiteStorage. It's not as secure as the RedisStorage, mainly because of it's dependency on a garbage collector; as well as the possibility that the SqLite DB file might be included in backups, etc. It's also not suitable for setups with several webservers without access to a shared filesystem. The constructor parameter $gcProbability is the same as for the FileStorage., (*7)

$db = new \SQLite3('path/to/sqlite.db');
$phPsst = new PhPsst(new SqLiteStorage($db, 10));

Requirements

  • PHP 8.1 or above.
  • Redis (for the Redis Storage)

Demo

Author

Felix Sandström http://github.com/felixsand, (*8)

Special thanks

License

Licensed under the MIT License - see the LICENSE file for details., (*9)

The Versions

31/12 2017

dev-master

9999999-dev https://github.com/felixsand/PhPsst

A PHP library for distributing (one time) passwords/secrets in a more secure way

  Sources   Download

MIT

The Requires

 

The Development Requires

password distribution secret safely

31/12 2017

v1.2.2

1.2.2.0 https://github.com/felixsand/PhPsst

A PHP library for distributing (one time) passwords/secrets in a more secure way

  Sources   Download

MIT

The Requires

 

The Development Requires

password distribution secret safely

09/08 2017

v1.2.1

1.2.1.0 https://github.com/felixsand/PhPsst

A PHP library for distributing (one time) passwords/secrets in a more secure way

  Sources   Download

MIT

The Requires

 

The Development Requires

password distribution secret safely

05/08 2017

v1.2.0

1.2.0.0 https://github.com/felixsand/PhPsst

A PHP library for distributing (one time) passwords/secrets in a more secure way

  Sources   Download

MIT

The Requires

 

The Development Requires

password distribution secret safely

16/07 2016

v1.1.0

1.1.0.0 https://github.com/felixsand/PhPsst

A PHP library for distributing (one time) passwords/secrets in a more secure way

  Sources   Download

MIT

The Requires

 

The Development Requires

password distribution secret safely

16/07 2016

v1.0

1.0.0.0 https://github.com/felixsand/PhPsst

A PHP library for distributing (one time) passwords/secrets in a more secure way

  Sources   Download

MIT

The Requires

 

The Development Requires

password distribution secret safely

06/06 2016

0.1

0.1.0.0 https://github.com/felixsand/php-pass-dist

A PHP library for distributing (one time) passwords/secrets in a more secure way

  Sources   Download

MIT

The Requires

 

The Development Requires

password distribution secret safely