-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from zf-fr/interfaces
Add interfaces
- Loading branch information
Showing
6 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ | |
* @author Michaël Gallego <[email protected]> | ||
* @licence MIT | ||
*/ | ||
class AuthorizationServer implements EventManagerAwareInterface | ||
class AuthorizationServer implements AuthorizationServerInterface, EventManagerAwareInterface | ||
{ | ||
use EventManagerAwareTrait; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. | ||
*/ | ||
|
||
namespace ZfrOAuth2\Server; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use ZfrOAuth2\Server\Entity\TokenOwnerInterface; | ||
use ZfrOAuth2\Server\Exception\OAuth2Exception; | ||
|
||
/** | ||
* The authorization server main role is to create access tokens or refresh tokens | ||
*/ | ||
interface AuthorizationServerInterface | ||
{ | ||
/** | ||
* Check if the authorization server supports this grant | ||
* | ||
* @param string $grant | ||
* @return bool | ||
*/ | ||
public function hasGrant($grant); | ||
|
||
/** | ||
* Check if the authorization server supports this response type | ||
* | ||
* @param string $responseType | ||
* @return bool | ||
*/ | ||
public function hasResponseType($responseType); | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @param TokenOwnerInterface|null $owner | ||
* @return ResponseInterface | ||
* @throws OAuth2Exception If no "response_type" could be found in the GET parameters | ||
*/ | ||
public function handleAuthorizationRequest(ServerRequestInterface $request, TokenOwnerInterface $owner = null); | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @param TokenOwnerInterface|null $owner | ||
* @return ResponseInterface | ||
* @throws OAuth2Exception If no "grant_type" could be found in the POST parameters | ||
*/ | ||
public function handleTokenRequest(ServerRequestInterface $request, TokenOwnerInterface $owner = null); | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @return ResponseInterface | ||
* @throws OAuth2Exception If no "token" is present | ||
*/ | ||
public function handleRevocationRequest(ServerRequestInterface $request); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
|
||
namespace ZfrOAuth2\Server\Grant; | ||
|
||
use ZfrOAuth2\Server\AuthorizationServer; | ||
use ZfrOAuth2\Server\AuthorizationServerInterface; | ||
|
||
/** | ||
* @author Michaël Gallego <[email protected]> | ||
|
@@ -27,14 +27,14 @@ | |
trait AuthorizationServerAwareTrait | ||
{ | ||
/** | ||
* @var AuthorizationServer | ||
* @var AuthorizationServerInterface | ||
*/ | ||
protected $authorizationServer; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function setAuthorizationServer(AuthorizationServer $authorizationServer) | ||
public function setAuthorizationServer(AuthorizationServerInterface $authorizationServer) | ||
{ | ||
$this->authorizationServer = $authorizationServer; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
* @author Michaël Gallego <[email protected]> | ||
* @licence MIT | ||
*/ | ||
class ResourceServer | ||
class ResourceServer implements ResourceServerInterface | ||
{ | ||
/** | ||
* @var TokenService | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* This software consists of voluntary contributions made by many individuals | ||
* and is licensed under the MIT license. | ||
*/ | ||
|
||
namespace ZfrOAuth2\Server; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use ZfrOAuth2\Server\Entity\AccessToken; | ||
use ZfrOAuth2\Server\Entity\Scope; | ||
|
||
/** | ||
* The resource server main role is to validate the access token and that its scope covers the | ||
* requested resource | ||
* | ||
* Currently, the resource server only implements the Bearer token usage, as described in the | ||
* RFC 6750 (http://tools.ietf.org/html/rfc6750) | ||
*/ | ||
interface ResourceServerInterface | ||
{ | ||
/** | ||
* Get the access token | ||
* | ||
* @param ServerRequestInterface $request | ||
* @param array|string|Scope[] $scopes | ||
* @return AccessToken|null | ||
* @throws Exception\InvalidAccessTokenException If given access token is invalid or expired | ||
*/ | ||
public function getAccessToken(ServerRequestInterface $request, $scopes = []); | ||
} |