Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /revoke route as per RFC 7009 #17

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/Revoke.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Chadicus\Slim\OAuth2\Routes;

use Chadicus\Slim\OAuth2\Http\MessageBridge;
use OAuth2;
use Slim\Slim;

/**
* The revoke class.
*
*/
class Revoke
{
const ROUTE = '/revoke';

/**
* The slim framework application instance.
*
* @var Slim
*/
private $slim;

/**
* The oauth2 server instance.
*
* @var OAuth2\Server
*/
private $server;

/**
* Construct a new instance of Authorize.
*
* @param Slim $slim The slim framework application instance.
* @param OAuth2\Server $server The oauth2 server imstance.
*/
public function __construct(Slim $slim, OAuth2\Server $server)
{
$this->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');
}
}