diff --git a/src/Composer/Manager.php b/src/Composer/Manager.php index 79fc054a8..27ceb14aa 100644 --- a/src/Composer/Manager.php +++ b/src/Composer/Manager.php @@ -260,6 +260,22 @@ public function addAuthCredentials($hostname, $username, $password, $type = null ]); } + /** + * getAuthCredentials returns auth credentials added to the config file + */ + public function getAuthCredentials($hostname, $type = null): ?array + { + if ($type === null) { + $type = 'http-basic'; + } + + $authFile = $this->getAuthPath(); + + $config = json_decode(file_get_contents($authFile), true); + + return $config[$type][$hostname] ?? null; + } + /** * makeComposer returns a new instance of composer */