pantheon-systems / customer-secrets-php-sdk
Supporting libraries for customer secrets project
Installs: 85 240
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 5
Forks: 2
Open Issues: 4
Requires
- php: ^8.0
- ext-json: *
Requires (Dev)
- g1a/composer-test-scenarios: ^3.2
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.6
- symfony/polyfill: ^1.28
- yoast/phpunit-polyfills: ^2.0
- dev-main
- 1.0.1
- 1.0.0
- v1.0.0-alpha1
- dev-add-catalog-workflow-20241010
- dev-DEVX-2943
- dev-php83
- dev-rename-catalog-info-20240923
- dev-add-catalog-info-20240828
- dev-lops-1269-test
- dev-LOPS-1269
- dev-fetchsecrets-visibility
- dev-strict-coding-standard
- dev-bugs-6767
- dev-deprecate-74
- dev-PSR-12
- dev-add-license
- dev-linting
- dev-test-structure-fixes
This package is auto-updated.
Last update: 2024-10-11 00:36:02 UTC
README
This library should be used to access Pantheon Sites Secrets (currently in EA).
Early Access
The Secrets feature is available for Early Access participants. Features for Secrets are in active development. Pantheon's development team is rolling out new functionality often while this product is in Early Access. Visit the Pantheon Slack channel (or sign up for the channel if you don't already have an account) to learn how you can enroll in our Early Access program. Please review Pantheon's Software Evaluation Licensing Terms for more information about access to our software.
Installation
Use composer to install it:
composer require pantheon-systems/customer-secrets-php-sdk
Usage
In your PHP code, do the following:
use PantheonSystems\CustomerSecrets\CustomerSecrets;
$client = CustomerSecrets::create()->getClient();
$secret = $client->getSecret('foo');
$secret_value = $secret->getValue();
// You could also get all of your secrets like this:
$secrets = $client->getSecrets();
See the included classes and internal documentation for more examples and use cases.
Note: Only get has been implemented so far. You should handle your secrets through terminus using Terminus Secrets Manager.
See our detailed Drupal or WordPress examples for more detailed end to end examples.
Local Environment Usage
The SDK includes a CustomerSecretsFakeClient
implementation that is used when the SDK runs outside of Pantheon infrastructure. This client uses a secrets json file to build the secrets information emulating what happens on the platform using the Secrets service.
To get this file, you should use the plugin secret:site:local-generate
command and then set an environment variable into your local environment (or docker container if you are running a dockerized environment) with name CUSTOMER_SECRETS_FAKE_FILE
and use the absolute path to the file as the value.
Lando example
To setup this using lando, you should modify your .lando.yml
like this:
services:
appserver:
overrides:
environment:
CUSTOMER_SECRETS_FAKE_FILE: /app/secrets.json
Then, generate the secrets file like this:
terminus secret:site:local-generate --filepath=./secrets.json
And rebuild lando application:
lando rebuild -y
Then, you will be able to use your secrets through the SDK.
Restrictions
This SDK will only read secrets with scope web
. Secrets get cached in the server for 15 minutes so you should wait (at most) that time if you modified your site secrets.