Add bearer support in config command and add to docs/schema, refs #8671
parent
0b993ba4b9
commit
f964b83018
|
@ -129,11 +129,17 @@ A list of domain names and username/passwords to authenticate against them. For
|
||||||
example using `{"example.org": {"username": "alice", "password": "foo"}}` as the
|
example using `{"example.org": {"username": "alice", "password": "foo"}}` as the
|
||||||
value of this option will let Composer authenticate against example.org.
|
value of this option will let Composer authenticate against example.org.
|
||||||
|
|
||||||
> **Note:** Authentication-related config options like `http-basic` and
|
> **Note:** Authentication-related config options like `http-basic`, `bearer` and
|
||||||
> `github-oauth` can also be specified inside a `auth.json` file that goes
|
> `github-oauth` can also be specified inside a `auth.json` file that goes
|
||||||
> besides your `composer.json`. That way you can gitignore it and every
|
> besides your `composer.json`. That way you can gitignore it and every
|
||||||
> developer can place their own credentials in there.
|
> developer can place their own credentials in there.
|
||||||
|
|
||||||
|
## bearer
|
||||||
|
|
||||||
|
A list of domain names and tokens to authenticate against them. For example using
|
||||||
|
`{"example.org": "foo"}` as the value of this option will let Composer authenticate
|
||||||
|
against example.org using an `Authorization: Bearer foo` header.
|
||||||
|
|
||||||
## platform
|
## platform
|
||||||
|
|
||||||
Lets you fake platform packages (PHP and extensions) so that you can emulate a
|
Lets you fake platform packages (PHP and extensions) so that you can emulate a
|
||||||
|
|
|
@ -142,6 +142,11 @@
|
||||||
"description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
|
"description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
},
|
},
|
||||||
|
"bearer": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "A hash of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
|
||||||
|
"additionalProperties": true
|
||||||
|
},
|
||||||
"disable-tls": {
|
"disable-tls": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Defaults to `false`. If set to true all HTTPS URLs will be tried with HTTP instead and no network level encryption is performed. Enabling this is a security risk and is NOT recommended. The better way is to enable the php_openssl extension in php.ini."
|
"description": "Defaults to `false`. If set to true all HTTPS URLs will be tried with HTTP instead and no network level encryption is performed. Enabling this is a security risk and is NOT recommended. The better way is to enable the php_openssl extension in php.ini."
|
||||||
|
|
|
@ -187,7 +187,7 @@ EOT
|
||||||
}
|
}
|
||||||
if ($input->getOption('global') && !$this->authConfigFile->exists()) {
|
if ($input->getOption('global') && !$this->authConfigFile->exists()) {
|
||||||
touch($this->authConfigFile->getPath());
|
touch($this->authConfigFile->getPath());
|
||||||
$this->authConfigFile->write(array('bitbucket-oauth' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject, 'gitlab-token' => new \ArrayObject, 'http-basic' => new \ArrayObject));
|
$this->authConfigFile->write(array('bitbucket-oauth' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject, 'gitlab-token' => new \ArrayObject, 'http-basic' => new \ArrayObject, 'bearer' => new \ArrayObject));
|
||||||
Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
|
Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle auth
|
// handle auth
|
||||||
if (preg_match('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic)\.(.+)/', $settingKey, $matches)) {
|
if (preg_match('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
|
||||||
if ($input->getOption('unset')) {
|
if ($input->getOption('unset')) {
|
||||||
$this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
|
$this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
|
||||||
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
|
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
|
||||||
|
@ -681,7 +681,7 @@ EOT
|
||||||
}
|
}
|
||||||
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
|
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
|
||||||
$this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
|
$this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
|
||||||
} elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token'), true)) {
|
} elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'), true)) {
|
||||||
if (1 !== count($values)) {
|
if (1 !== count($values)) {
|
||||||
throw new \RuntimeException('Too many arguments, expected only one token');
|
throw new \RuntimeException('Too many arguments, expected only one token');
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ class Config
|
||||||
// gitlab-oauth
|
// gitlab-oauth
|
||||||
// gitlab-token
|
// gitlab-token
|
||||||
// http-basic
|
// http-basic
|
||||||
|
// bearer
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $defaultRepositories = array(
|
public static $defaultRepositories = array(
|
||||||
|
@ -133,7 +134,7 @@ class Config
|
||||||
// override defaults with given config
|
// override defaults with given config
|
||||||
if (!empty($config['config']) && is_array($config['config'])) {
|
if (!empty($config['config']) && is_array($config['config'])) {
|
||||||
foreach ($config['config'] as $key => $val) {
|
foreach ($config['config'] as $key => $val) {
|
||||||
if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic')) && isset($this->config[$key])) {
|
if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer')) && isset($this->config[$key])) {
|
||||||
$this->config[$key] = array_merge($this->config[$key], $val);
|
$this->config[$key] = array_merge($this->config[$key], $val);
|
||||||
} elseif ('preferred-install' === $key && isset($this->config[$key])) {
|
} elseif ('preferred-install' === $key && isset($this->config[$key])) {
|
||||||
if (is_array($val) || is_array($this->config[$key])) {
|
if (is_array($val) || is_array($this->config[$key])) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
||||||
{
|
{
|
||||||
$authConfig = $this->authConfig;
|
$authConfig = $this->authConfig;
|
||||||
$this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
|
$this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
|
||||||
if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|platform)\.}', $key)) {
|
if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
|
||||||
list($key, $host) = explode('.', $key, 2);
|
list($key, $host) = explode('.', $key, 2);
|
||||||
if ($authConfig) {
|
if ($authConfig) {
|
||||||
$config[$key][$host] = $val;
|
$config[$key][$host] = $val;
|
||||||
|
@ -116,7 +116,7 @@ class JsonConfigSource implements ConfigSourceInterface
|
||||||
{
|
{
|
||||||
$authConfig = $this->authConfig;
|
$authConfig = $this->authConfig;
|
||||||
$this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
|
$this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
|
||||||
if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|platform)\.}', $key)) {
|
if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
|
||||||
list($key, $host) = explode('.', $key, 2);
|
list($key, $host) = explode('.', $key, 2);
|
||||||
if ($authConfig) {
|
if ($authConfig) {
|
||||||
unset($config[$key][$host]);
|
unset($config[$key][$host]);
|
||||||
|
|
Loading…
Reference in New Issue