From 892ae3a0d35bbf8fa2a089842eadaab45a84a55d Mon Sep 17 00:00:00 2001 From: Daniel Horrigan Date: Tue, 22 Jan 2013 11:25:51 -0500 Subject: [PATCH] Started adding some Server methods, adding some Util classes and adding a way to get the token from the Resource --- src/OAuth2/Resource.php | 10 ++++ src/OAuth2/Server.php | 83 +++++++++++++++++++++++++++++++++ src/OAuth2/Util/RedirectUri.php | 12 +++++ src/OAuth2/Util/SecureKey.php | 21 +++++++++ 4 files changed, 126 insertions(+) create mode 100644 src/OAuth2/Util/RedirectUri.php create mode 100644 src/OAuth2/Util/SecureKey.php diff --git a/src/OAuth2/Resource.php b/src/OAuth2/Resource.php index 4e2d540b..80590049 100644 --- a/src/OAuth2/Resource.php +++ b/src/OAuth2/Resource.php @@ -80,6 +80,16 @@ class Resource return $this->ownerId; } + /** + * Gets the Access Token. + * + * @return string + */ + public function getAccessToken() + { + return $this->accessToken; + } + /** * Checks if the Access Token is valid or not. * diff --git a/src/OAuth2/Server.php b/src/OAuth2/Server.php index 386a6cb5..09ef8a37 100644 --- a/src/OAuth2/Server.php +++ b/src/OAuth2/Server.php @@ -16,6 +16,8 @@ class Server protected $grantTypes = array(); + protected $request = null; + public function __construct($storage) { @@ -29,14 +31,95 @@ class Server $this->grantTypes[$identifier] = $grant_type; } + public function getScopeDelimeter() + { + return $this->scopeDelimeter; + } + public function setScopeDelimeter($scope_delimeter) { $this->scopeDelimeter = $scope_delimeter; } + public function getExpiresIn() + { + return $this->expiresIn; + } + public function setExpiresIn($expires_in) { $this->expiresIn = $expires_in; } + /** + * Sets the Request Object + * + * @param RequestInterface The Request Object + */ + public function setRequest(RequestInterface $request) + { + $this->request = $request; + } + + /** + * Gets the Request object. It will create one from the globals if one is not set. + * + * @return RequestInterface + */ + public function getRequest() + { + if ($this->request === null) { + $this->request = Request::buildFromGlobals(); + } + + return $this->request; + } + + /** + * Check client authorise parameters + * + * @access public + * @param array $authParams Optional array of parsed $_GET keys + * @return array Authorise request parameters + */ + public function checkClientAuthoriseParams($authParams = null) + { + + } + + /** + * Parse a new authorise request + * + * @param string $type The session owner's type + * @param string $typeId The session owner's ID + * @param array $authoriseParams The authorise request $_GET parameters + * @return string An authorisation code + */ + public function newAuthoriseRequest($type, $typeId, $authoriseParams) + { + + } + + /** + * Issue an access token + * + * @access public + * @param array $authParams Optional array of parsed $_POST keys + * @return array Authorise request parameters + */ + public function issueAccessToken($authParams = null) + { + + } + + + protected function getCurrentGrantType() + { + $grantType = $this->getRequest()->post('grant_type'); + + if (is_null($grantType)) { + throw new Exception + } + } + } diff --git a/src/OAuth2/Util/RedirectUri.php b/src/OAuth2/Util/RedirectUri.php new file mode 100644 index 00000000..7e75ab44 --- /dev/null +++ b/src/OAuth2/Util/RedirectUri.php @@ -0,0 +1,12 @@ +