class ServicesClientConnectionBasicAuth in Services Client 7
Same name and namespace in other branches
- 7.2 services_client_connection/plugins/ServicesClientConnectionBasicAuth.inc \ServicesClientConnectionBasicAuth
@file Session authentication for 3.x version
Hierarchy
Expanded class hierarchy of ServicesClientConnectionBasicAuth
1 string reference to 'ServicesClientConnectionBasicAuth'
- _services_client_connection_auth in services_client_connection/
include/ plugin_definition.inc - List of auth plugins provided by module
File
- services_client_connection/
plugins/ ServicesClientConnectionBasicAuth.inc, line 8 - Session authentication for 3.x version
View source
class ServicesClientConnectionBasicAuth extends ServicesClientConnectionAuth {
/**
* Implements configForm().
*/
public function configForm(&$form, &$form_state) {
$form['username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#default_value' => isset($this->config['username']) ? $this->config['username'] : '',
);
$form['password'] = array(
'#type' => 'textfield',
'#title' => t('Password'),
'#default_value' => isset($this->config['password']) ? $this->config['password'] : '',
);
}
/**
* Implements configFormSubmit().
*/
public function configFormSubmit(&$form, &$form_state) {
parent::configFormSubmit($form, $form_state);
$form_state['config']['username'] = $form_state['values']['username'];
$form_state['config']['password'] = $form_state['values']['password'];
}
/**
* Implements prepareRequest().
*
* @param ServicesClientConnectionHttpRequest $request
*/
public function prepareRequest(ServicesClientConnectionHttpRequest &$request) {
parent::prepareRequest($request);
$credentials = $this->config['username'] . ':' . $this->config['password'];
$credentials = base64_encode($credentials);
$request->http_headers['Authorization'] = 'Basic ' . $credentials;
}
}