class ApigeeAuthKeyType in Apigee Edge 8
Key type for Apigee Edge authentication credentials.
Plugin annotation
@KeyType(
id = "apigee_auth",
label = @Translation("Apigee Edge Authentication"),
description = @Translation("Key type to use for Apigee Edge authentication credentials."),
group = "apigee_edge",
key_value = {
"plugin" = "apigee_auth_input"
},
multivalue = {
"enabled" = true,
"fields" = {
"instance_type" = {
"label" = @Translation("Instance type"),
"required" = false
},
"auth_type" = {
"label" = @Translation("Authentication type"),
"required" = false
},
"organization" = {
"label" = @Translation("Organization"),
"required" = true
},
"username" = {
"label" = @Translation("Username"),
"required" = false
},
"password" = {
"label" = @Translation("Password"),
"required" = false
},
"endpoint" = {
"label" = @Translation("Apigee Edge endpoint"),
"required" = false
},
"authorization_server" = {
"label" = @Translation("Authorization server"),
"required" = false
},
"client_id" = {
"label" = @Translation("Client ID"),
"required" = false
},
"client_secret" = {
"label" = @Translation("Client secret"),
"required" = false
},
"account_json_key" = {
"label" = @Translation("Account JSON key"),
"required" = false
},
"gcp_hosted" = {
"label" = @Translation("Use default service account if hosted on GCP"),
"required" = false
}
}
}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\key\Plugin\KeyPluginBase implements KeyPluginInterface
- class \Drupal\key\Plugin\KeyTypeBase implements KeyTypeInterface
- class \Drupal\apigee_edge\Plugin\EdgeKeyTypeBase implements EdgeKeyTypeInterface
- class \Drupal\apigee_edge\Plugin\KeyType\ApigeeAuthKeyType
- class \Drupal\apigee_edge\Plugin\EdgeKeyTypeBase implements EdgeKeyTypeInterface
- class \Drupal\key\Plugin\KeyTypeBase implements KeyTypeInterface
- class \Drupal\key\Plugin\KeyPluginBase implements KeyPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ApigeeAuthKeyType
1 file declares its use of ApigeeAuthKeyType
File
- src/
Plugin/ KeyType/ ApigeeAuthKeyType.php, line 94
Namespace
Drupal\apigee_edge\Plugin\KeyTypeView source
class ApigeeAuthKeyType extends EdgeKeyTypeBase {
/**
* {@inheritdoc}
*/
public static function generateKeyValue(array $configuration) {
return '[]';
}
/**
* {@inheritdoc}
*/
public function validateKeyValue(array $form, FormStateInterface $form_state, $key_value) {
if (empty($key_value)) {
return;
}
$value = $this
->unserialize($key_value);
if ($value === NULL) {
$form_state
->setError($form, $this
->t('The key value does not contain valid JSON: @error', [
'@error' => json_last_error_msg(),
]));
return;
}
foreach ($this
->getPluginDefinition()['multivalue']['fields'] as $id => $field) {
if (isset($field['required']) && !$field['required']) {
continue;
}
$error_element = $form['settings']['input_section']['key_input_settings'][$id] ?? $form;
if (!isset($value[$id])) {
$form_state
->setError($error_element, $this
->t('The key value is missing the field %field.', [
'%field' => $field['label']
->render(),
]));
}
elseif (empty($value[$id])) {
$form_state
->setError($error_element, $this
->t('The key value field %field is empty.', [
'%field' => $field['label']
->render(),
]));
}
}
}
/**
* {@inheritdoc}
*/
public function getAuthenticationMethod(KeyInterface $key) : Authentication {
$values = $key
->getKeyValues();
if ($this
->getInstanceType($key) === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
if ($this
->useGcpDefaultServiceAccount($key)) {
return new GceServiceAccountAuthentication(\Drupal::service('apigee_edge.authentication.oauth_token_storage'));
}
else {
$account_key = $this
->getAccountKey($key);
return new HybridAuthentication($account_key['client_email'], $account_key['private_key'], \Drupal::service('apigee_edge.authentication.oauth_token_storage'));
}
}
elseif ($values['auth_type'] === EdgeKeyTypeInterface::EDGE_AUTH_TYPE_OAUTH) {
// Use Oauth authentication.
return new OauthAuthentication($this
->getUsername($key), $this
->getPassword($key), \Drupal::service('apigee_edge.authentication.oauth_token_storage'), NULL, $this
->getClientId($key), $this
->getClientSecret($key), NULL, $this
->getAuthorizationServer($key));
}
else {
// Use basic authentication.
return new BasicAuth($this
->getUsername($key), $this
->getPassword($key));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ApigeeAuthKeyType:: |
public static | function |
Generate a key value of this type using the submitted configuration. Overrides KeyTypeInterface:: |
|
ApigeeAuthKeyType:: |
public | function |
Gets the authentication method object. Overrides KeyTypeAuthenticationMethodInterface:: |
|
ApigeeAuthKeyType:: |
public | function |
Allows the Key Type plugin to validate the key value. Overrides KeyTypeInterface:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EdgeKeyTypeBase:: |
public | function |
Return the JSON account key decoded as an array. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the authentication type. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the authorization server. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the client ID. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the client secret. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API endpoint. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API endpoint type (default or custom). Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the instance type (public, private or hybrid). Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API organization. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API password. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Gets the API username. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Serialize an array of key values into a string. Overrides KeyTypeMultivalueInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Unserialize a string of key values into an array. Overrides KeyTypeMultivalueInterface:: |
|
EdgeKeyTypeBase:: |
public | function |
Return if you should use the Default Service account. Overrides EdgeKeyTypeInterface:: |
|
EdgeKeyTypeInterface:: |
constant | ID of the basic authentication method. | ||
EdgeKeyTypeInterface:: |
constant | |||
EdgeKeyTypeInterface:: |
constant | ID of the JWT authentication method. | ||
EdgeKeyTypeInterface:: |
constant | ID of the OAuth authentication method. | ||
EdgeKeyTypeInterface:: |
constant | The endpoint type for custom. | ||
EdgeKeyTypeInterface:: |
constant | The endpoint type for default. | ||
EdgeKeyTypeInterface:: |
public | constant | Apigee instance on hybrid cloud. | |
EdgeKeyTypeInterface:: |
public | constant | Apigee instance on private cloud. | |
EdgeKeyTypeInterface:: |
public | constant | Apigee instance on public cloud. | |
KeyPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
KeyPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
KeyPluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
8 |
KeyPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
KeyPluginBase:: |
public | function |
Returns the type of plugin. Overrides KeyPluginInterface:: |
|
KeyPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
KeyPluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |