mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Resolves #2. Implemented authlib-injector support
This commit is contained in:
@@ -17,7 +17,7 @@ return [
|
||||
'authserverHost' => 'localhost',
|
||||
],
|
||||
'container' => [
|
||||
'definitions' => [
|
||||
'singletons' => [
|
||||
api\components\ReCaptcha\Validator::class => function() {
|
||||
return new class(new GuzzleHttp\Client()) extends api\components\ReCaptcha\Validator {
|
||||
protected function validateValue($value) {
|
||||
@@ -34,6 +34,45 @@ return [
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function profile(string $username, bool $signed = false): ?array {
|
||||
$account = common\models\Account::findOne(['username' => $username]);
|
||||
$uuid = $account ? str_replace('-', '', $account->uuid) : '00000000000000000000000000000000';
|
||||
|
||||
$profile = [
|
||||
'name' => $username,
|
||||
'id' => $uuid,
|
||||
'properties' => [
|
||||
[
|
||||
'name' => 'textures',
|
||||
'value' => base64_encode(json_encode([
|
||||
'timestamp' => Carbon\Carbon::now()->getPreciseTimestamp(3),
|
||||
'profileId' => $uuid,
|
||||
'profileName' => $username,
|
||||
'textures' => [
|
||||
'SKIN' => [
|
||||
'url' => 'http://ely.by/skin.png',
|
||||
],
|
||||
],
|
||||
])),
|
||||
],
|
||||
[
|
||||
'name' => 'ely',
|
||||
'value' => 'but why are you asking?',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
if ($signed) {
|
||||
$profile['properties'][0]['signature'] = 'signature';
|
||||
}
|
||||
|
||||
return $profile;
|
||||
}
|
||||
|
||||
public function getSignatureVerificationKey(string $format = 'pem'): string {
|
||||
return "-----BEGIN PUBLIC KEY-----\nMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANbUpVCZkMKpfvYZ08W3lumdAaYxLBnm\nUDlzHBQH3DpYef5WCO32TDU6feIJ58A0lAywgtZ4wwi2dGHOz/1hAvcCAwEAAQ==\n-----END PUBLIC KEY-----";
|
||||
}
|
||||
};
|
||||
},
|
||||
],
|
||||
|
@@ -46,4 +46,10 @@ return [
|
||||
'/mojang/profiles/<username>' => 'mojang/api/uuid-by-username',
|
||||
'/mojang/profiles/<uuid>/names' => 'mojang/api/usernames-by-uuid',
|
||||
'POST /mojang/profiles' => 'mojang/api/uuids-by-usernames',
|
||||
|
||||
// authlib-injector
|
||||
'/authlib-injector/authserver/<action>' => 'authserver/authentication/<action>',
|
||||
'/authlib-injector/sessionserver/session/minecraft/join' => 'session/session/join',
|
||||
'/authlib-injector/sessionserver/session/minecraft/hasJoined' => 'session/session/has-joined',
|
||||
'/authlib-injector/sessionserver/session/minecraft/profile/<uuid>' => 'session/session/profile',
|
||||
];
|
||||
|
Reference in New Issue
Block a user