mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 22:35:18 +00:00
add refresh token grant type
This commit is contained in:
parent
d2771649a8
commit
06b51d1f86
4 changed files with 12 additions and 2 deletions
|
@ -6,6 +6,7 @@ use Code\Lib\System;
|
|||
use OAuth2\Server;
|
||||
use OAuth2\Storage\Memory;
|
||||
use OAuth2\GrantType\ClientCredentials;
|
||||
use OAuth2\GrantType\RefreshToken;
|
||||
use OAuth2\OpenID\GrantType\AuthorizationCode;
|
||||
|
||||
class OAuth2Server extends Server
|
||||
|
@ -32,7 +33,8 @@ class OAuth2Server extends Server
|
|||
// Need to use OpenID\GrantType to return id_token
|
||||
// (see:https://github.com/bshaffer/oauth2-server-php/issues/443)
|
||||
$this->addGrantType(new AuthorizationCode($storage));
|
||||
|
||||
// Add the "Refresh Token" grant type
|
||||
$this->addGrantType(new RefreshToken($storage));
|
||||
$keyStorage = new Memory([
|
||||
'keys' => [
|
||||
'public_key' => get_config('system', 'pubkey'),
|
||||
|
|
|
@ -8,6 +8,7 @@ use Code\Lib\Channel;
|
|||
use Code\Web\Controller;
|
||||
use Code\Identity\OAuth2Server;
|
||||
use Code\Identity\OAuth2Storage;
|
||||
use OAuth2\GrantType\RefreshToken;
|
||||
use OAuth2\Request;
|
||||
use OAuth2\Response;
|
||||
use OAuth2\GrantType;
|
||||
|
@ -61,7 +62,8 @@ class Authorize extends Controller
|
|||
$server->addGrantType(new GrantType\ClientCredentials($storage));
|
||||
// Add the "Authorization Code" grant type (this is where the oauth magic happens)
|
||||
$server->addGrantType(new GrantType\AuthorizationCode($storage));
|
||||
|
||||
// Add the "Refresh Token" grant type
|
||||
$server->addGrantType(new GrantType\RefreshToken($storage));
|
||||
|
||||
// TODO: The automatic client registration protocol below should adhere more
|
||||
// closely to "OAuth 2.0 Dynamic Client Registration Protocol" defined
|
||||
|
|
|
@ -44,6 +44,9 @@ class Token extends Controller
|
|||
$server->addGrantType(new GrantType\ClientCredentials($storage));
|
||||
// Add the "Authorization Code" grant type (this is where the oauth magic happens)
|
||||
$server->addGrantType(new GrantType\AuthorizationCode($storage));
|
||||
// Add the "Refresh Token" grant type
|
||||
$server->addGrantType(new GrantType\RefreshToken($storage));
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $server->handleTokenRequest($request);
|
||||
$response->send();
|
||||
|
|
|
@ -39,6 +39,9 @@ function api_login()
|
|||
$server->addGrantType(new GrantType\ClientCredentials($storage));
|
||||
// Add the "Authorization Code" grant type (this is where the oauth magic happens)
|
||||
$server->addGrantType(new GrantType\AuthorizationCode($storage));
|
||||
// Add the "Refresh Token" grant type
|
||||
$server->addGrantType(new GrantType\RefreshToken($storage));
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
if ($server->verifyResourceRequest($request)) {
|
||||
$token = $server->getAccessTokenData($request);
|
||||
|
|
Loading…
Reference in a new issue