From e499b98b518751a7a0d7b544faa9bbd4bc3d6a5d Mon Sep 17 00:00:00 2001 From: earllapura Date: Tue, 26 Apr 2016 15:58:17 +0800 Subject: [PATCH 1/2] Add /revoke route as per RFC 7009 Added /revoke route as per RFC 7009 (https://tools.ietf.org/html/rfc7009#section-2) integrated into bshaffer/oauth2-server-php. Request parameters as outlined in the server library should have 'token_type_hint' which is either 'access_token' or 'refresh_token', and 'token' which is the actual token. --- src/Revoke.php | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/Revoke.php diff --git a/src/Revoke.php b/src/Revoke.php new file mode 100644 index 0000000..aa483ae --- /dev/null +++ b/src/Revoke.php @@ -0,0 +1,65 @@ +slim = $slim; + $this->server = $server; + } + + /** + * Call this class as a function. + * + * @return void + */ + public function __invoke() + { + $request = MessageBridge::newOAuth2Request($this->slim->request()); + MessageBridge::mapResponse( + $this->server->handleRevokeRequest($request), + $this->slim->response() + ); + } + + /** + * Register this route with the given Slim application and OAuth2 server + * + * @param Slim $slim The slim framework application instance. + * @param OAuth2\Server $server The oauth2 server instance. + * + * @return void + */ + public static function register(Slim $slim, OAuth2\Server $server) + { + $slim->post(self::ROUTE, new static($slim, $server))->name('revoke'); + } +} From 5873e0a3938a245d6f0428a5a4bebff03d767e84 Mon Sep 17 00:00:00 2001 From: earllapura Date: Tue, 26 Apr 2016 16:29:12 +0800 Subject: [PATCH 2/2] Applied coding standards as per Scrutinizer --- src/Revoke.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Revoke.php b/src/Revoke.php index aa483ae..ce9ce34 100644 --- a/src/Revoke.php +++ b/src/Revoke.php @@ -6,6 +6,10 @@ use OAuth2; use Slim\Slim; +/** + * The revoke class. + * + */ class Revoke { const ROUTE = '/revoke'; @@ -27,8 +31,8 @@ class Revoke /** * Construct a new instance of Authorize. * - * @param Slim $slim The slim framework application instance. - * @param OAuth2\Server $server The oauth2 server imstance. + * @param Slim $slim The slim framework application instance. + * @param OAuth2\Server $server The oauth2 server imstance. */ public function __construct(Slim $slim, OAuth2\Server $server) { @@ -53,8 +57,8 @@ public function __invoke() /** * Register this route with the given Slim application and OAuth2 server * - * @param Slim $slim The slim framework application instance. - * @param OAuth2\Server $server The oauth2 server instance. + * @param Slim $slim The slim framework application instance. + * @param OAuth2\Server $server The oauth2 server instance. * * @return void */