-
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.
Merge remote-tracking branch 'origin/master' into score-legacy-toggle-ui
- Loading branch information
Showing
318 changed files
with
4,383 additions
and
2,990 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
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,19 @@ | ||
<?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. | ||
|
||
namespace App\Enums; | ||
|
||
enum ScoreRank: string | ||
{ | ||
case A = 'A'; | ||
case B = 'B'; | ||
case C = 'C'; | ||
case D = 'D'; | ||
case F = 'F'; | ||
case S = 'S'; | ||
case SH = 'SH'; | ||
case X = 'X'; | ||
case XH = 'XH'; | ||
} |
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
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
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,45 @@ | ||
<?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 Defuse\Crypto\Crypto; | ||
use Firebase\JWT\JWT; | ||
use Laravel\Passport\Passport; | ||
use Laravel\Passport\RefreshToken; | ||
|
||
class EncodeToken | ||
{ | ||
public static function encodeAccessToken(Token $token): string | ||
{ | ||
$privateKey = $GLOBALS['cfg']['passport']['private_key'] | ||
?? file_get_contents(Passport::keyPath('oauth-private.key')); | ||
|
||
return JWT::encode([ | ||
'aud' => $token->client_id, | ||
'exp' => $token->expires_at->timestamp, | ||
'iat' => $token->created_at->timestamp, // issued at | ||
'jti' => $token->getKey(), | ||
'nbf' => $token->created_at->timestamp, // valid after | ||
'sub' => $token->user_id, | ||
'scopes' => $token->scopes, | ||
], $privateKey, 'RS256'); | ||
} | ||
|
||
public static function encodeRefreshToken(RefreshToken $refreshToken, Token $accessToken): string | ||
{ | ||
return Crypto::encryptWithPassword(json_encode([ | ||
'client_id' => (string) $accessToken->client_id, | ||
'refresh_token_id' => $refreshToken->getKey(), | ||
'access_token_id' => $accessToken->getKey(), | ||
'scopes' => $accessToken->scopes, | ||
'user_id' => $accessToken->user_id, | ||
'expire_time' => $refreshToken->expires_at->timestamp, | ||
]), \Crypt::getKey()); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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.