aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php')
-rw-r--r--vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php46
1 files changed, 43 insertions, 3 deletions
diff --git a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php
index f165538ba..b10c2dd09 100644
--- a/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php
+++ b/vendor/bshaffer/oauth2-server-php/src/OAuth2/GrantType/UserCredentials.php
@@ -6,30 +6,46 @@ use OAuth2\Storage\UserCredentialsInterface;
use OAuth2\ResponseType\AccessTokenInterface;
use OAuth2\RequestInterface;
use OAuth2\ResponseInterface;
+use LogicException;
/**
- *
* @author Brent Shaffer <bshafs at gmail dot com>
*/
class UserCredentials implements GrantTypeInterface
{
+ /**
+ * @var array
+ */
private $userInfo;
+ /**
+ * @var UserCredentialsInterface
+ */
protected $storage;
/**
- * @param OAuth2\Storage\UserCredentialsInterface $storage REQUIRED Storage class for retrieving user credentials information
+ * @param UserCredentialsInterface $storage - REQUIRED Storage class for retrieving user credentials information
*/
public function __construct(UserCredentialsInterface $storage)
{
$this->storage = $storage;
}
- public function getQuerystringIdentifier()
+ /**
+ * @return string
+ */
+ public function getQueryStringIdentifier()
{
return 'password';
}
+ /**
+ * @param RequestInterface $request
+ * @param ResponseInterface $response
+ * @return bool|mixed|null
+ *
+ * @throws LogicException
+ */
public function validateRequest(RequestInterface $request, ResponseInterface $response)
{
if (!$request->request("password") || !$request->request("username")) {
@@ -61,21 +77,45 @@ class UserCredentials implements GrantTypeInterface
return true;
}
+ /**
+ * Get client id
+ *
+ * @return mixed|null
+ */
public function getClientId()
{
return null;
}
+ /**
+ * Get user id
+ *
+ * @return mixed
+ */
public function getUserId()
{
return $this->userInfo['user_id'];
}
+ /**
+ * Get scope
+ *
+ * @return null|string
+ */
public function getScope()
{
return isset($this->userInfo['scope']) ? $this->userInfo['scope'] : null;
}
+ /**
+ * Create access token
+ *
+ * @param AccessTokenInterface $accessToken
+ * @param mixed $client_id - client identifier related to the access token.
+ * @param mixed $user_id - user id associated with the access token
+ * @param string $scope - scopes to be stored in space-separated string.
+ * @return array
+ */
public function createAccessToken(AccessTokenInterface $accessToken, $client_id, $user_id, $scope)
{
return $accessToken->createAccessToken($client_id, $user_id, $scope);