-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
373 additions
and
24 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
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Libraries\OAuth; | ||
|
||
use App\Models\OAuth\Token; | ||
use League\OAuth2\Server\Grant\RefreshTokenGrant as BaseRefreshTokenGrant; | ||
use League\OAuth2\Server\ResponseTypes\ResponseTypeInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
class RefreshTokenGrant extends BaseRefreshTokenGrant | ||
{ | ||
private ?array $oldRefreshToken = null; | ||
|
||
public function respondToAccessTokenRequest( | ||
ServerRequestInterface $request, | ||
ResponseTypeInterface $responseType, | ||
\DateInterval $accessTokenTTL | ||
) { | ||
$refreshTokenData = parent::respondToAccessTokenRequest($request, $responseType, $accessTokenTTL); | ||
|
||
// Copy previous verification state | ||
$accessToken = (new \ReflectionProperty($refreshTokenData, 'accessToken'))->getValue($refreshTokenData); | ||
Token::where('id', $accessToken->getIdentifier())->update([ | ||
'verified' => Token::select('verified')->find($this->oldRefreshToken['access_token_id'])->verified, | ||
]); | ||
$this->oldRefreshToken = null; | ||
|
||
return $refreshTokenData; | ||
} | ||
|
||
protected function validateOldRefreshToken(ServerRequestInterface $request, $clientId) | ||
{ | ||
return $this->oldRefreshToken = parent::validateOldRefreshToken($request, $clientId); | ||
} | ||
} |
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
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
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,25 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Providers; | ||
|
||
use App\Libraries\OAuth\RefreshTokenGrant; | ||
use Laravel\Passport\Bridge\RefreshTokenRepository; | ||
use Laravel\Passport\Passport; | ||
use Laravel\Passport\PassportServiceProvider as BasePassportServiceProvider; | ||
|
||
class PassportServiceProvider extends BasePassportServiceProvider | ||
{ | ||
protected function makeRefreshTokenGrant() | ||
{ | ||
$repository = $this->app->make(RefreshTokenRepository::class); | ||
|
||
return tap(new RefreshTokenGrant($repository), function ($grant) { | ||
$grant->setRefreshTokenTTL(Passport::refreshTokensExpireIn()); | ||
}); | ||
} | ||
} |
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
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
Oops, something went wrong.