http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Api/Models/Role.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Api/Models/Role.php b/sdks/other/php5/apache-usergrid/src/Api/Models/Role.php new file mode 100644 index 0000000..3e93465 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Api/Models/Role.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Api\Models; + + +use Guzzle\Service\Command\ResponseClassInterface; + +/** + * Class Role + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * @link http://baas-platform.com + */ +class Role extends BaseCollection implements ResponseClassInterface +{ + + use GuzzleCommandTrait; + + public function usersAttribute() + { + return $this->getApiClient()->application()->GetRelationship([ + 'collection' => 'roles', + 'entity_id' => $this->entities->fetch('uuid')->first(), + 'relationship' => 'users' + ])->toArray(); + } + + public function groupsAttribute() + { + return $this->getApiClient()->application()->GetRelationship([ + 'collection' => 'roles', + 'entity_id' => $this->entities->fetch('uuid')->first(), + 'relationship' => 'groups' + ])->toArray(); + } +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Api/Models/User.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Api/Models/User.php b/sdks/other/php5/apache-usergrid/src/Api/Models/User.php new file mode 100644 index 0000000..8bec6d3 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Api/Models/User.php @@ -0,0 +1,77 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Api\Models; + + +use Guzzle\Service\Command\ResponseClassInterface; + +/** + * Class User + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * @link http://baas-platform.com + */ +class User extends BaseCollection implements ResponseClassInterface +{ + + use GuzzleCommandTrait; + + public function deviceAttribute() + { + return $this->getApiClient()->application()->GetRelationship([ + 'collection' => 'users', + 'entity_id' => $this->entities->fetch('uuid')->first(), + 'relationship' => 'devices' + ])->toArray(); + } + + public function notificationAttribute() + { + + } + + public function groupsAttribute() + { + return $this->getApiClient()->application()->GetRelationship([ + 'collection' => 'users', + 'entity_id' => $this->entities->fetch('uuid')->first(), + 'relationship' => 'groups' + ])->toArray(); + } + + public function rolesAttribute() + { + return $this->getApiClient()->application()->GetRelationship([ + 'collection' => 'users', + 'entity_id' => $this->entities->fetch('uuid')->first(), + 'relationship' => 'roles' + ])->toArray(); + } + + public function connectionsAttribute() + { + return $this->getApiClient()->application()->GetRelationship([ + 'collection' => 'users', + 'entity_id' => $this->entities->fetch('uuid')->first(), + 'relationship' => 'connections' + ])->toArray(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Api/QueryAggregator.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Api/QueryAggregator.php b/sdks/other/php5/apache-usergrid/src/Api/QueryAggregator.php new file mode 100644 index 0000000..eacfcd5 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Api/QueryAggregator.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Api; + + +use Guzzle\Http\QueryAggregator\QueryAggregatorInterface; +use Guzzle\Http\QueryString; + +/** + * Class QueryAggregator + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * @link http://baas-platform.com + */ +class QueryAggregator implements QueryAggregatorInterface +{ + + /** + * {@inheritDoc} + */ + public function aggregate($key, $value, QueryString $query) + { + $response = []; + + foreach ($value as $k => $v) { + if (is_int($k)) { + return [ + $query->encodeValue("{$key}[]") => $value + ]; + } + + $k = "{$key}[{$k}]"; + + if (is_array($v)) { + $response = array_merge($response, self::aggregate($k, $v, $query)); + } else { + $response[$query->encodeValue($k)] = $query->encodeValue($v); + } + } + + return $response; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Api/ResourceIterator.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Api/ResourceIterator.php b/sdks/other/php5/apache-usergrid/src/Api/ResourceIterator.php new file mode 100644 index 0000000..7df0dd7 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Api/ResourceIterator.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + + +namespace Apache\Usergrid\Api; + +use Guzzle\Service\Command\CommandInterface; +use Guzzle\Service\Resource\ResourceIterator as BaseIterator; + +/** + * Class ResourceIterator + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * @link http://baas-platform.com + */ +class ResourceIterator extends BaseIterator +{ + /** + * {@inheritDoc} + */ + public function __construct(CommandInterface $command, array $data = []) + { + parent::__construct($command, $data); + + $this->pageSize = 20; + } + + /** + * Send a request to retrieve the next page of results. Hook for subclasses to implement. + * + * @return array Returns the newly loaded resources + */ + protected function sendRequest() + { + $this->command->set('limit', $this->pageSize); + + if ($this->nextToken) { + $this->command->set('cursor', $this->nextToken); + } + + $result = $this->command->execute(); + + $data = $result['entities']; + + if ($result->has('cursor')) { + $this->nextToken = $result['cursor'] ? $result['cursor'] : false; + } + + return $data; + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Api/Usergrid.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Api/Usergrid.php b/sdks/other/php5/apache-usergrid/src/Api/Usergrid.php new file mode 100644 index 0000000..279f2b2 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Api/Usergrid.php @@ -0,0 +1,452 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Api; + + +use Apache\Usergrid\Guzzle\Plugin\Oauth2\Oauth2Plugin; +use Guzzle\Common\Event; +use Guzzle\Plugin\ErrorResponse\ErrorResponsePlugin; +use Guzzle\Service\Description\ServiceDescription; +use InvalidArgumentException; + +/** + * Class Usergrid + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * @link http://baas-platform.com + */ +class Usergrid +{ + + /** + * Header Bearer Token + * @var + */ + protected $token; + + + /** + * @var \Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType\GrantTypeInterface + */ + protected $grantType; + /** + * The Usergrid API version. + * + * @var string + */ + protected $version = '1.0.1'; + /** + * The manifests path. + * + * @var string + */ + protected $manifestPath; + /** + * The Base URL. + * + * @var string + */ + protected $baseUrl; + /** + * Oauth2 Guzzle Plugin. + * + * @var \Apache\Usergrid\Guzzle\Plugin\Oauth2\Oauth2Plugin + */ + protected $oauth2_plugin; + /** + * The cached manifests data. + * + * @var array + */ + protected $manifests = []; + /** + * The user agent. + * + * @var string + */ + protected $userAgent = 'BaaS-Usergrid/1.0.0'; + /** + * The headers to be sent to the Guzzle client. + * + * @var array + */ + protected $headers = []; + private $org_name; + private $app_name; + + /** + * @param null $orgName + * @param null $appName + * @param $manifestPath + * @param $version + * @param $baseUrl + * @param Oauth2Plugin $oauth2_plugin + */ + function __construct( + $orgName = null, + $appName = null, + $manifestPath, + $version, + $baseUrl, + Oauth2Plugin $oauth2_plugin = null + ) { + //Set Version so its added to header + $this->setVersion($version ?: $this->version); + + $this->baseUrl = $baseUrl; + + $this->org_name = $orgName; + $this->app_name = $appName; + + //check if OAuth2 plugin is enabled + if ($oauth2_plugin != null) { + $this->oauth2_plugin = $oauth2_plugin; + $this->grantType = $this->oauth2_plugin->getGrantType(); + } + + // Set the manifest path + $this->setManifestPath($manifestPath ?: dirname(dirname(__FILE__)) . '/Manifests'); + } + + /** + * @return mixed + */ + public function getToken() + { + return $this->token; + } + + /** + * @param mixed $token + * @return $this + */ + public function setToken($token) + { + $this->token = $token; + + $this->setHeaders([ + 'Authorization' => (string)'Bearer ' . $token, + ]); + + return $this; + } + + /** + * Dynamically handle missing methods. + * + * @param string $method + * @param array $arguments + * @return mixed + */ + public function __call($method, array $arguments = []) + { + if (substr($method, -8) === 'Iterator') { + return $this->handleIteratorRequest($method, $arguments); + } elseif ($this->isSingleRequest($method)) { + return $this->handleSingleRequest($method, $arguments); + } + + return $this->handleRequest($method); + } + + /** + * Handles an iterator request. + * + * @param string $method + * @param array $arguments + * @return \Apache\Usergrid\Api\ResourceIterator + * @throws \InvalidArgumentException + */ + protected function handleIteratorRequest($method, array $arguments = []) + { + $client = $this->handleRequest(substr($method, 0, -8)); + + $command = $client->getCommand('all', array_get($arguments, 0, [])); + + return new ResourceIterator($command, array_get($arguments, 1, [])); + } + + /** + * Handles the current request. + * + * @param string $method + * @throws InvalidArgumentException + * @return \Guzzle\Service\Client + */ + protected function handleRequest($method) + { + if (!$this->manifestExists($method)) { + throw new InvalidArgumentException("Undefined method [{$method}] called."); + } + + // Initialize the Guzzle client + $client = new GuzzleClient('', + ['command.params' => ['app_name_or_uuid' => $this->app_name, 'org_name_or_uuid' => $this->org_name]]); + + // Set our own usergrid api client for internal + // usage within our api models. + $client->setApiClient($this); + + // Set the client user agent + $client->setUserAgent($this->getUserAgent(), true); + + + // Set the headers + $client->setDefaultOption('headers', $this->getHeaders()); + + // Get the Guzzle event dispatcher + $dispatcher = $client->getEventDispatcher(); + + // Register the error response plugin for our custom exceptions + $dispatcher->addSubscriber(new ErrorResponsePlugin); + + // Listen to the "command.after_prepare" event fired by Guzzle + $dispatcher->addListener('command.after_prepare', function (Event $event) { + $request = $event['command']->getRequest(); + + $request->getQuery()->setAggregator(new QueryAggregator()); + }); + + //check if Oauth 2 plugin is a instance of Oauth2Plugin + if ($this->oauth2_plugin instanceof Oauth2Plugin) { + $dispatcher->addSubscriber($this->oauth2_plugin); + } + + + // Set the manifest payload into the Guzzle client + $client->setDescription(ServiceDescription::factory( + $this->buildPayload($method) + )); + + // Return the Guzzle client + return $client; + } + + /** + * Checks if the manifest file for the current request exists. + * + * @param string $file + * @return bool + */ + protected function manifestExists($file) + { + return file_exists($this->getManifestFilePath($file)); + } + + /** + * Returns the given request manifest file path. + * + * @param string $file + * @return string + */ + protected function getManifestFilePath($file) + { + return $this->getFullManifestPath() . '/' . ucwords($file) . '.php'; + } + + /** + * Returns the full versioned manifests path. + * + * @return string + */ + protected function getFullManifestPath() + { + return $this->getManifestPath() . '/' . $this->getVersion(); + } + + /** + * @return string + */ + public function getManifestPath() + { + return $this->manifestPath; + } + + /** + * @param string $manifestPath + * @return $this + */ + public function setManifestPath($manifestPath) + { + $this->manifestPath = $manifestPath; + return $this; + } + + /** + * @return string + */ + public function getVersion() + { + return $this->version; + } + + /** + * @param string $version + * @return $this + */ + public function setVersion($version) + { + $this->version = $version; + + $this->setHeaders([ + 'Usergrid-Version' => (string)$version, + ]); + return $this; + } + + /** + * @return string + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * @param string $userAgent + * @return $this + */ + public function setUserAgent($userAgent) + { + $this->userAgent = $userAgent; + + return $this; + } + + /** + * Returns the Guzzle client headers. + * + * @return array + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Sets the Guzzle client headers. + * + * @param array $headers + * @return $this + */ + public function setHeaders(array $headers = []) + { + $this->headers = array_merge($this->headers, $headers); + + return $this; + } + + /** + * Returns the current request payload. + * + * @param string $method + * @return array + */ + protected function buildPayload($method) + { + $operations = $this->getRequestManifestPayload($method); + + $manifest = $this->getRequestManifestPayload('manifest', false); + + return array_merge($manifest, compact('operations')); + } + + /** + * Returns the given file manifest data. + * + * @param string $file + * @param bool $includeErrors + * @return array + */ + protected function getRequestManifestPayload($file, $includeErrors = true) + { + $file = ucwords($file); + + /** @noinspection PhpUnusedLocalVariableInspection */ + $baseURL = $this->baseUrl; + + if (!$manifest = array_get($this->manifests, $file)) { + if ($includeErrors) { + /** @noinspection PhpUnusedLocalVariableInspection */ + $errors = $this->getRequestManifestPayload('errors', false); + } + + /** @noinspection PhpIncludeInspection */ + $manifest = require_once $this->getManifestFilePath($file); + + array_set($this->manifests, $file, $manifest); + } + + return $manifest; + } + + /** + * Determines if the request is a single request. + * + * @param $method + * @return bool + */ + protected function isSingleRequest($method) + { + return (str_singular($method) === $method && $this->manifestExists(str_plural($method))); + } + + /** + * Handles a single request. + * + * @param string $method + * @param array $arguments + * @return \Guzzle\Service\Client + * @throws \InvalidArgumentException + */ + protected function handleSingleRequest($method, array $arguments = []) + { + // Check if we have any arguments + if (empty($arguments)) { + throw new InvalidArgumentException('Not enough arguments provided!'); + } + + // Pluralize the method name + $pluralMethod = str_plural($method); + + // Get the request manifest payload data + $manifest = $this->getRequestManifestPayload($pluralMethod); + + if (!$parameters = array_get($manifest, 'find')) { + throw new InvalidArgumentException("Undefined method [{$method}] called.");; + } + + // Get the required parameters for the request + $required = array_where(array_get($parameters, 'parameters'), function ($key, $value) { + return $value['required'] === true; + }); + + // Prepare the arguments for the request + $arguments = array_combine( + array_keys($required), + count($required) === 1 ? (array)$arguments[0] : $arguments + ); + + // Execute the request + return $this->handleRequest($pluralMethod)->find($arguments); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php new file mode 100755 index 0000000..b03d4a7 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/AuthorizationCode.php @@ -0,0 +1,77 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType; + +use Guzzle\Common\Collection; +use Guzzle\Http\ClientInterface; + +/** + * Authorization code grant type. + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * + * @link http://tools.ietf.org/html/rfc6749#section-4.1 + */ +class AuthorizationCode implements GrantTypeInterface +{ + /** @var ClientInterface The token endpoint client */ + protected $client; + + /** @var Collection Configuration settings */ + protected $config; + + public function __construct(ClientInterface $client, $config) + { + $this->client = $client; + $this->config = Collection::fromConfig($config, array( + 'client_secret' => '', + 'scope' => '', + 'redirect_uri' => '', + ), array( + 'client_id', + 'code', + )); + } + + /** + * {@inheritdoc} + */ + public function getTokenData() + { + $postBody = array( + 'grant_type' => 'authorization_code', + 'code' => $this->config['code'], + ); + if ($this->config['scope']) { + $postBody['scope'] = $this->config['scope']; + } + if ($this->config['redirect_uri']) { + $postBody['redirect_uri'] = $this->config['redirect_uri']; + } + $request = $this->client->post(null, array(), $postBody); + $request->setAuth($this->config['client_id'], $this->config['client_secret']); + $response = $request->send(); + $data = $response->json(); + + $requiredData = array_flip(array('access_token', 'expires_in', 'refresh_token')); + return array_intersect_key($data, $requiredData); + } +} http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php new file mode 100755 index 0000000..729f6a5 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/ClientCredentials.php @@ -0,0 +1,73 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType; + +use Guzzle\Common\Collection; +use Guzzle\Http\ClientInterface; + +/** + * Client credentials grant type. + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * + * @link http://tools.ietf.org/html/rfc6749#section-4.4 + */ +class ClientCredentials implements GrantTypeInterface +{ + /** @var ClientInterface The token endpoint client */ + protected $client; + + /** @var Collection Configuration settings */ + protected $config; + + public function __construct(ClientInterface $client, $config) + { + $this->client = $client; + $this->config = Collection::fromConfig($config, array( + 'client_secret' => '', + 'scope' => '', + ), array( + 'client_id', + )); + } + + /** + * {@inheritdoc} + */ + public function getTokenData() + { + $postBody = array( + 'grant_type' => 'client_credentials', + 'client_id' => $this->config['client_id'], + 'client_secret' => $this->config['client_secret'] + ); + if ($this->config['scope']) { + $postBody['scope'] = $this->config['scope']; + } + $request = $this->client->post(null, array(), $postBody); +// $request->setAuth($this->config['client_id'], $this->config['client_secret']); + $response = $request->send(); + $data = $response->json(); + + $requiredData = array_flip(array('access_token', 'expires_in', 'refresh_token')); + return array_intersect_key($data, $requiredData); + } +} http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/GrantTypeInterface.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/GrantTypeInterface.php b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/GrantTypeInterface.php new file mode 100755 index 0000000..99096c0 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/GrantTypeInterface.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType; + + +/** + * Interface GrantTypeInterface + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * @link http://baas-platform.com + */ +interface GrantTypeInterface +{ + /** + * Get the token data returned by the OAuth2 server. + * + * @return array An array with the following keys: + * - access_token: The access token. + * - expires_in: The access token lifetime, in seconds. + * - refresh_token: The refresh token, if present. + */ + public function getTokenData(); +} http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php new file mode 100755 index 0000000..f30d593 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/HWIOAuthBundleRefreshToken.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType; + +use HWI\Bundle\OAuthBundle\Security\Http\ResourceOwnerMap; +use Symfony\Component\Security\Core\SecurityContextInterface; + +/** + * HWIOAuthBundle Aware Refresh token grant type. + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * + * @link http://tools.ietf.org/html/rfc6749#section-6 + */ +class HWIOAuthBundleRefreshToken implements GrantTypeInterface +{ + /** @var SecurityContextInterface Symfony2 security component */ + protected $securityContext; + + /** @var ResourceOwnerMap HWIOAuthBundle OAuth2 ResourceOwnerMap */ + protected $resourceOwnerMap; + + public function __construct(ResourceOwnerMap $resourceOwnerMap, SecurityContextInterface $securityContext) + { + $this->securityContext = $securityContext; + $this->resourceOwnerMap = $resourceOwnerMap; + } + + /** + * {@inheritdoc} + */ + public function getTokenData($refreshToken = null) + { + $token = $this->securityContext->getToken(); + $resourceName = $token->getResourceOwnerName(); + $resourceOwner = $this->resourceOwnerMap->getResourceOwnerByName($resourceName); + + $data = $resourceOwner->refreshAccessToken($refreshToken); + $token->setRawToken($data); + $requiredData = array_flip(array('access_token', 'expires_in', 'refresh_token')); + + return array_intersect_key($data, $requiredData); + } +} http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php new file mode 100755 index 0000000..6afc482 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/PasswordCredentials.php @@ -0,0 +1,75 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType; + +use Guzzle\Common\Collection; +use Guzzle\Http\ClientInterface; + +/** + * Resource owner password credentials grant type. + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * + * @link http://tools.ietf.org/html/rfc6749#section-4.3 + */ +class PasswordCredentials implements GrantTypeInterface +{ + /** @var ClientInterface The token endpoint client */ + protected $client; + + /** @var Collection Configuration settings */ + protected $config; + + public function __construct(ClientInterface $client, $config) + { + $this->client = $client; + $this->config = Collection::fromConfig($config, array( + 'client_secret' => '', + 'scope' => '', + ), array( + 'client_id', + 'username', + 'password' + )); + } + + /** + * {@inheritdoc} + */ + public function getTokenData() + { + $postBody = array( + 'grant_type' => 'password', + 'username' => $this->config['username'], + 'password' => $this->config['password'], + ); + if ($this->config['scope']) { + $postBody['scope'] = $this->config['scope']; + } + $request = $this->client->post(null, array(), $postBody); + //Note: Usergrid it not using Oauth2 to spec so it dose not need a Auth type set no need to client id + secret when using password +// $request->setAuth($this->config['client_id'], $this->config['client_secret']); + $response = $request->send(); + $data = $response->json(); + + $requiredData = array_flip(array('access_token', 'expires_in', 'refresh_token')); + return array_intersect_key($data, $requiredData); + } +} http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php new file mode 100755 index 0000000..149d570 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/GrantType/RefreshToken.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +namespace Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType; + +use Guzzle\Common\Collection; +use Guzzle\Http\ClientInterface; + +/** + * Refresh token grant type. + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * + * @link http://tools.ietf.org/html/rfc6749#section-6 + */ +class RefreshToken implements GrantTypeInterface +{ + /** @var ClientInterface The token endpoint client */ + protected $client; + + /** @var Collection Configuration settings */ + protected $config; + + public function __construct(ClientInterface $client, $config) + { + $this->client = $client; + $this->config = Collection::fromConfig($config, array( + 'client_secret' => '', + 'refresh_token' => '', + 'scope' => '', + ), array( + 'client_id', + )); + } + + /** + * {@inheritdoc} + */ + public function getTokenData($refreshToken = null) + { + $postBody = array( + 'grant_type' => 'refresh_token', + // If no refresh token was provided to the method, use the one + // provided to the constructor. + 'refresh_token' => $refreshToken ?: $this->config['refresh_token'], + ); + if ($this->config['scope']) { + $postBody['scope'] = $this->config['scope']; + } + $request = $this->client->post(null, array(), $postBody); + $request->setAuth($this->config['client_id'], $this->config['client_secret']); + $response = $request->send(); + $data = $response->json(); + + $requiredData = array_flip(array('access_token', 'expires_in', 'refresh_token')); + return array_intersect_key($data, $requiredData); + } +} http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php new file mode 100755 index 0000000..8454309 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Guzzle/Plugin/Oauth2/Oauth2Plugin.php @@ -0,0 +1,212 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +namespace Apache\Usergrid\Guzzle\Plugin\Oauth2; + +use Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType\GrantTypeInterface; +use Guzzle\Common\Event; +use Guzzle\Http\Exception\BadResponseException; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * OAuth2 plugin + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * + * @link http://tools.ietf.org/html/rfc6749 + */ +class Oauth2Plugin implements EventSubscriberInterface +{ + + /** @var GrantTypeInterface The grant type implementation used to acquire access tokens */ + protected $grantType; + + /** @var GrantTypeInterface The grant type implementation used to refresh access tokens */ + protected $refreshTokenGrantType; + + /** @var array An array with the "access_token" and "expires" keys */ + protected $accessToken; + + /** @var string The refresh token string. * */ + protected $refreshToken; + + /** + * Create a new Oauth2 plugin + * @param GrantTypeInterface $grantType + * @param GrantTypeInterface $refreshTokenGrantType + */ + public function __construct(GrantTypeInterface $grantType = null, GrantTypeInterface $refreshTokenGrantType = null) + { + $this->grantType = $grantType; + $this->refreshTokenGrantType = $refreshTokenGrantType; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() + { + return array( + 'request.before_send' => 'onRequestBeforeSend', + 'request.error' => 'onRequestError', + ); + } + + /** + * Request before-send event handler. + * + * Adds the Authorization header if an access token was found. + * + * @param Event $event Event received + */ + public function onRequestBeforeSend(Event $event) + { + $accessToken = $this->getAccessToken(); + if ($accessToken) { + $event['request']->setHeader('Authorization', 'Bearer ' . $accessToken['access_token']); + } + } + + /** + * Get the access token. + * + * Handles token expiration for tokens with an "expires" timestamp. + * In case no valid token was found, tries to acquire a new one. + * + * @return array|null + */ + public function getAccessToken() + { + if (isset($this->accessToken['expires']) && $this->accessToken['expires'] < time()) { + // The access token has expired. + $this->accessToken = null; + } + if (!$this->accessToken) { + // Try to acquire a new access token from the server. + $this->acquireAccessToken(); + } + + return $this->accessToken; + } + + /** + * Set the access token. + * + * @param array|string $accessToken The access token + */ + public function setAccessToken(array $accessToken) + { + $this->accessToken = $accessToken; + } + + /** + * Acquire a new access token from the server. + * + * @return array|null + */ + protected function acquireAccessToken() + { + if ($this->refreshTokenGrantType && $this->refreshToken) { + try { + // Get an access token using the stored refresh token. + $tokenData = $this->refreshTokenGrantType->getTokenData($this->refreshToken); + } catch (BadResponseException $e) { + // The refresh token has probably expired. + $this->refreshToken = null; + } + } + if ($this->grantType && !isset($tokenData)) { + // Get a new access token. + $tokenData = $this->grantType->getTokenData(); + } + + $this->accessToken = null; + if (isset($tokenData)) { + // Process the returned data. Both expired_in and refresh_token + // are optional parameters. + $this->accessToken = array( + 'access_token' => $tokenData['access_token'], + ); + if (isset($tokenData['expires_in'])) { + $this->accessToken['expires'] = time() + $tokenData['expires_in']; + } + if (isset($tokenData['refresh_token'])) { + $this->refreshToken = $tokenData['refresh_token']; + } + } + + return $this->accessToken; + } + + /** + * Request error event handler. + * + * Handles unauthorized errors by acquiring a new access token and + * retrying the request. + * + * @param Event $event Event received + */ + public function onRequestError(Event $event) + { + if ($event['response']->getStatusCode() == 401) { + if ($event['request']->getHeader('X-Guzzle-Retry')) { + // We already retried once, give up. + return; + } + + // Acquire a new access token, and retry the request. + $newAccessToken = $this->acquireAccessToken(); + if ($newAccessToken) { + $newRequest = clone $event['request']; + $newRequest->setHeader('Authorization', 'Bearer ' . $newAccessToken['access_token']); + $newRequest->setHeader('X-Guzzle-Retry', '1'); + $event['response'] = $newRequest->send(); + $event->stopPropagation(); + } + } + } + + /** + * Get the refresh token. + * + * @return string + */ + public function getRefreshToken() + { + return $this->refreshToken; + } + + /** + * Set the refresh token. + * + * @param string $refreshToken The refresh token + */ + public function setRefreshToken($refreshToken) + { + $this->refreshToken = $refreshToken; + } + + /** + * @return GrantTypeInterface + */ + public function getGrantType() + { + return $this->grantType; + } +} http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Laravel/ApacheUsergridServiceProvider.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Laravel/ApacheUsergridServiceProvider.php b/sdks/other/php5/apache-usergrid/src/Laravel/ApacheUsergridServiceProvider.php new file mode 100644 index 0000000..57807ad --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Laravel/ApacheUsergridServiceProvider.php @@ -0,0 +1,159 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ +namespace Apache\Usergrid\Laravel; + + +use Apache\Usergrid\Api\Usergrid; +use Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType\ClientCredentials; +use Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType\PasswordCredentials; +use Apache\Usergrid\Guzzle\Plugin\Oauth2\GrantType\RefreshToken; +use Apache\Usergrid\Guzzle\Plugin\Oauth2\Oauth2Plugin; +use Guzzle\Http\Client; +use Illuminate\Support\ServiceProvider; + +/** + * Class ApacheUsergridServiceProvider + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * @link http://baas-platform.com + */ +class ApacheUsergridServiceProvider extends ServiceProvider +{ + + protected $oauth2Plugin = null; + + /** + * + */ + public function boot() + { + $this->package('apache/usergrid', 'apache/usergrid', __DIR__ . '/..'); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + // register Usergrid + $this->registerUsergrid(); + + } + + protected function registerUsergrid() + { + + $this->app['usergrid'] = $this->app->share(function ($app) { + + /** Note: I had to move this to here from the register function as the below config values would not get set and would be null + * unless I has this with the package namespace missing but doing that would mean that it would not find the enable_oauth2_plugin + * value .. This has been driving me crazy as I tried to read the config values from a rout and they would not show up + * then I did . Also this would not find the config values if the boot function did not have the package method called with + * all 3 args + * $enable_oauth2_plugin = $this->app['config']->get('usergrid.enable_oauth2_plugin'); + * + * //check if user managed oauth auth flow + * if($enable_oauth2_plugin){ + * // Create the Oauth2 Guzzle Plugin. + * $this->createGuzzleOauth2Plugin(); + * } + */ + $enable_oauth2_plugin = $app['config']->get('apache/usergrid::usergrid.enable_oauth2_plugin'); + + //check if user managed oauth auth flow + if ($enable_oauth2_plugin) { + // Create the Oauth2 Guzzle Plugin. + $this->createGuzzleOauth2Plugin(); + } + + $baseUrl = $app['config']->get('apache/usergrid::usergrid.url'); + + $orgName = $app['config']->get('apache/usergrid::usergrid.orgName'); + + $appName = $app['config']->get('apache/usergrid::usergrid.appName'); + + $manifestPath = $app['config']->get('apache/usergrid::usergrid.manifestPath'); + + $version = $app['config']->get('apache/usergrid::usergrid.version'); + + return new Usergrid($orgName, $appName, $manifestPath, $version, $baseUrl, $this->oauth2Plugin); + }); + + $this->app->alias('usergrid', 'Apache\Usergrid\Api\Usergrid'); + } + + + protected function createGuzzleOauth2Plugin() + { + + $base_url = $this->app['config']->get('apache/usergrid::usergrid.url'); + + $org_name = $this->app['config']->get('apache/usergrid::usergrid.orgName'); + + $app_name = $this->app['config']->get('apache/usergrid::usergrid.appName'); + + $grant_type = $this->app['config']->get('apache/usergrid::usergrid.grant_type'); + + $client_id = $this->app['config']->get('apache/usergrid::usergrid.clientId'); + + $client_secret = $this->app['config']->get('apache/usergrid::usergrid.clientSecret'); + + $username = $this->app['config']->get('apache/usergrid::usergrid.username'); + + $password = $this->app['config']->get('apache/usergrid::usergrid.password'); + + + if ($this->app['config']->get('apache/usergrid::usergrid.auth_type') == 'organization') { + + $url = $base_url . '/management/token'; + + } elseif ($this->app['config']->get('apache/usergrid::usergrid.auth_type') == 'application') { + $url = $base_url . '/' . $org_name . '/' . $app_name . '/token'; + } + + $oauth2Client = new Client($url); + + if ($grant_type == 'client_credentials') { + $config = [ + 'client_id' => $client_id, + 'client_secret' => $client_secret, + + ]; + $grantType = new ClientCredentials($oauth2Client, $config); + $refreshTokenGrantType = new RefreshToken($oauth2Client, $config); + $this->oauth2Plugin = new Oauth2Plugin($grantType, $refreshTokenGrantType); + + } elseif ($grant_type == 'password') { + $config = [ + 'username' => $username, + 'password' => $password, + 'client_id' => $client_id, + 'client_secret' => $client_secret + ]; + $grantType = new PasswordCredentials($oauth2Client, $config); + $refreshTokenGrantType = new RefreshToken($oauth2Client, $config); + $this->oauth2Plugin = new Oauth2Plugin($grantType, $refreshTokenGrantType); + } + + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/other/php5/apache-usergrid/src/Laravel/Facades/Usergrid.php ---------------------------------------------------------------------- diff --git a/sdks/other/php5/apache-usergrid/src/Laravel/Facades/Usergrid.php b/sdks/other/php5/apache-usergrid/src/Laravel/Facades/Usergrid.php new file mode 100644 index 0000000..1ea29f2 --- /dev/null +++ b/sdks/other/php5/apache-usergrid/src/Laravel/Facades/Usergrid.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright 2010-2014 baas-platform.com, Pty Ltd. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +namespace Apache\Usergrid\Laravel\Facades; + + +use Illuminate\Support\Facades\Facade; + +/** + * Class Usergrid + * + * @package Apache/Usergrid + * @version 1.0.0 + * @author Jason Kristian <[email protected]> + * @license Apache License, Version 2.0 + * @copyright (c) 2008-2014, Baas Platform Pty. Ltd + * @link http://baas-platform.com + */ +class Usergrid extends Facade +{ + /** + * @return string + */ + protected static function getFacadeAccessor() + { + return "usergrid"; + } + +} \ No newline at end of file
