Skip to content

Commit

Permalink
Hotfix to use the default generator for refresh tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
jonoradich committed Feb 24, 2016
1 parent 3c7f688 commit 7936198
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/League/OAuth2/Server/Grant/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function checkAuthoriseParams($inputParams = array())
public function newAuthoriseRequest($type, $typeId, $authParams = array())
{
// Generate an auth code.
// We want to use the default generator for this
// Use the default token generator for this
$authCode = (new DefaultGenerator())->generate();

// Remove any old sessions the user might have
Expand Down Expand Up @@ -251,7 +251,8 @@ public function completeFlow($inputParams = null)

// Associate a refresh token if set
if ($this->authServer->hasGrantType('refresh_token')) {
$refreshToken = $this->getTokenGenerator()->generate();
// Use the default token generator for this
$refreshToken = (new DefaultGenerator())->generate();
$refreshTokenTTL = time() + $this->authServer->getGrantType('refresh_token')->getRefreshTokenTTL();
$this->authServer->getStorage('session')->associateRefreshToken($accessTokenId, $refreshToken, $refreshTokenTTL, $authParams['client_id']);
$response['refresh_token'] = $refreshToken;
Expand Down
4 changes: 3 additions & 1 deletion src/League/OAuth2/Server/Grant/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use League\OAuth2\Server\Authorization;
use League\OAuth2\Server\Exception;
use League\OAuth2\Server\Util\DefaultGenerator;

/**
* Password grant class
Expand Down Expand Up @@ -176,7 +177,8 @@ public function completeFlow($inputParams = null)

// Associate a refresh token if set
if ($this->authServer->hasGrantType('refresh_token')) {
$refreshToken = $this->getTokenGenerator()->generate();
// Use the default token generator for this
$refreshToken = (new DefaultGenerator())->generate();
$refreshTokenTTL = time() + $this->authServer->getGrantType('refresh_token')->getRefreshTokenTTL();
$this->authServer->getStorage('session')->associateRefreshToken($accessTokenId, $refreshToken, $refreshTokenTTL, $authParams['client_id']);
$response['refresh_token'] = $refreshToken;
Expand Down
6 changes: 4 additions & 2 deletions src/League/OAuth2/Server/Grant/RefreshToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use League\OAuth2\Server\Authorization;
use League\OAuth2\Server\Exception;
use League\OAuth2\Server\Util\DefaultGenerator;

/**
* Referesh token grant
Expand Down Expand Up @@ -148,8 +149,9 @@ public function completeFlow($inputParams = null)

if ($this->rotateRefreshTokens === true) {

// Generate a new refresh token
$refreshToken = $this->getTokenGenerator()->generate();
// Generate a new refresh token.
// Use the default token generator for this
$refreshToken = (new DefaultGenerator())->generate();
$refreshTokenExpires = time() + $this->getRefreshTokenTTL();

// Revoke the old refresh token
Expand Down

0 comments on commit 7936198

Please sign in to comment.