public function Lockr::getSecretValue in Lockr 7.3
Gets the latest value of a secret by name.
Parameters
string $name:
Return value
string
File
- vendor/
lockr/ lockr/ src/ Lockr.php, line 210
Class
Namespace
LockrCode
public function getSecretValue($name) {
$query = <<<'EOQ'
query LatestSecretValue($name: String!) {
self {
secret(name: $name) {
latest {
value
}
}
}
}
EOQ;
$t0 = microtime(true);
$data = $this->client
->query([
'query' => $query,
'variables' => [
'name' => $name,
],
]);
$t1 = microtime(true);
$this->client
->getStats()
->lockrCallCompleted('get_secret_value', $t1 - $t0);
if (!isset($data['self']['secret']['latest']['value'])) {
return null;
}
$value = $data['self']['secret']['latest']['value'];
$value = base64_decode($value);
$info = $this->info
->getSecretInfo($name);
if (isset($info['wrapping_key'])) {
$wk = $info['wrapping_key'];
$value = MultiKeyWrapper::decrypt($value, $wk);
}
return $value;
}