By joachim on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
7.x-3.x
Introduced in version:
7.x-3.0-beta7
Issue links:
Description:
The way in which a connection stores its credentials (such as username and password) is now handled by a plugin. This allows connections to store their credentials in different ways.
Two credentials storage plugins currently exist:
- Configuration storage: This works the same as before the introduction of the plugins. The credentials are stored in the connection's configuration array. This means they are exported to features. Use this storage for the convenience of the credentials being in the codebase, and therefore easily available to all developers on a project.
- Variable storage: The credentials are stored in a system variable. This means they are not exported to features as part of the connection. Use this storage when the credentials should be kept secure and not distributed in the codebase.
Changes to connection handler classes
Admin form elements
Form elements for credentials should now be in the $form['credentials'] element rather than $form['configuration'].
Before:
$form['configuration']['username'] = array(
'#type' => 'textfield',
'#title' => t('Service username'),
'#size' => 30,
'#maxlength' => 60,
'#attributes' => array('autocomplete' => 'off'),
'#description' => t('This should be same as the username on the server you are connecting to.'),
'#required' => TRUE,
);
After:
$form['credentials']['username'] = array(
'#type' => 'textfield',
'#title' => t('Service username'),
'#size' => 30,
'#maxlength' => 60,
'#attributes' => array('autocomplete' => 'off'),
'#description' => t('This should be same as the username on the server you are connecting to.'),
'#required' => TRUE,
);
credentialsProperties()
Connection handlers should define the credentialsProperties() method, to declare which properties are to be considered to be credentials:
/**
* Declare an array of properties which should be treated as credentials.
*
* This lets the credentials storage plugin know which configuration
* properties to take care of.
*
* @return
* A flat array of property names.
*/
function credentialsProperties() {
return array('username', 'password');
}
Using credentials
Credentials must now be explicitly loaded when they are needed.
Before:
$data = array(
'username' => $this->configuration['username'],
'password' => $this->configuration['password'],
);
After:
$this->credentialsLoad();
$data = array(
'username' => $this->credentials['username'],
'password' => $this->credentials['password'],
);
Impacts:
Site builders, administrators, editors
Module developers