particleflux / password-manager-connection
Connect to an external password/secret manager
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0
Requires (Dev)
- infection/infection: ^0.27.4
- phpcompatibility/php-compatibility: dev-develop
- phpmd/phpmd: ^2.9
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.4
- squizlabs/php_codesniffer: ^3.7
README
Connect your PHP app to an external password manager.
Installation
composer require particleflux/password-manager-connection
Requirements
- minimum PHP 8.1
Usage
use particleflux\PMConnection\PassConnection; // initialize the connection client $connection = new PassConnection(); // get the password for the account 'facebook' $password = $connection->getPassword('facebook'); // get the username for the account 'facebook' $username = $connection->getUser('facebook'); // get a custom attribute for an account $email = $connection->getAttribute('facebook', 'email');
PassConnection
PassConnection is a specific implementation to connect with pass.
$connection = new PassConnection([ 'prefix' => 'social-media/', 'userAttribute' => 'username', ]);
Configuration options
prefix
A prefix applied to the pass entry name.
By default, this is empty, meaning that the account given to the connection methods is the complete account name. When having more complex or bigger password databases though, it is common to group them by subfolders. These subfolders can be auto-appended by using the prefix parameter.
For example, when setting prefix to social-media/
, the call to
getPassword('facebook')
will actually get the password entry for
social-media/facebook
.
userAttribute
The attribute to get the username.
To have additional data besides the password for an entry, it is common to have specific attribute name prefixes. This options configures the attribute name used for getting the username.
Taking this pass entry for example:
my-secret-password
username: my-username
This example, with the userAttribute of username
, will return my-username
in a call to getUser()
.