class OAuth2ServerRestfulAuthentication in OAuth2 Server 7
A simple OAuth2 authentication type.
Hierarchy
- class \RestfulPluginBase implements RestfulPluginInterface
- class \RestfulAuthenticationBase implements RestfulAuthenticationInterface
Expanded class hierarchy of OAuth2ServerRestfulAuthentication
1 string reference to 'OAuth2ServerRestfulAuthentication'
- oauth2.inc in plugins/
authentication/ oauth2.inc
File
- plugins/
authentication/ OAuth2ServerRestfulAuthentication.class.php, line 11 - Contains RestfulOAuth2Authentication and OAuth2ServerRestfulException.
View source
class OAuth2ServerRestfulAuthentication extends \RestfulAuthenticationBase {
/**
* {@inheritdoc}
*/
public function authenticate(array $request = array(), $method = \RestfulInterface::GET) {
if (!($server = variable_get('oauth2_server_restful_server'))) {
return NULL;
}
$result = oauth2_server_check_access($server, variable_get('oauth2_server_restful_scope'));
if ($result instanceof OAuth2\Response) {
throw new \OAuth2ServerRestfulException($result);
}
elseif (is_array($result) && !empty($result['user_id'])) {
return user_load($result['user_id']);
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function applies(array $request = array(), $method = \RestfulInterface::GET) {
// Don't attempt to authenticate during a Drush call, for example registry
// rebuild.
// @todo perhaps this should be a patch upstream (for the restful module)
if (drupal_is_cli()) {
return FALSE;
}
return parent::applies($request, $method);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OAuth2ServerRestfulAuthentication:: |
public | function |
Determines if the request can be checked for authentication. For example,
when authenticating with HTTP header, return FALSE if the header values do
not exist. Overrides RestfulAuthenticationBase:: |
|
OAuth2ServerRestfulAuthentication:: |
public | function |
Authenticate the request by trying to match a user. Overrides RestfulAuthenticationInterface:: |
|
RestfulAuthenticationBase:: |
protected | property | Settings from the plugin definition. | |
RestfulAuthenticationBase:: |
public | function |
Get the name of the authentication plugin. Overrides RestfulAuthenticationInterface:: |
|
RestfulAuthenticationBase:: |
public | function |
Constructor. Overrides RestfulPluginBase:: |
|
RestfulPluginBase:: |
protected | property | The plugin definition array. | |
RestfulPluginBase:: |
public | function |
Gets information about the restful plugin. Overrides RestfulPluginInterface:: |
|
RestfulPluginBase:: |
public | function |
Gets information about the restful plugin key. Overrides RestfulPluginInterface:: |
|
RestfulPluginBase:: |
public | function |
Sets information about the restful plugin. Overrides RestfulPluginInterface:: |
|
RestfulPluginBase:: |
public | function |
Gets information about the restful plugin key. Overrides RestfulPluginInterface:: |