use config() to read env

This commit is contained in:
xiaomlove
2025-03-29 15:08:34 +07:00
parent 43df3ed492
commit bd9b4d7e1d
3 changed files with 10 additions and 5 deletions
+2 -2
View File
@@ -49,9 +49,9 @@ class Test extends Command
*/ */
public function handle() public function handle()
{ {
$r = PersonalAccessToken::query()->find(11); $r = config('nexus.ammds_secret');
// $r = SearchBox::query()->find(4)->ss()->orWhere("mode", 0)->get(); // $r = SearchBox::query()->find(4)->ss()->orWhere("mode", 0)->get();
dd($r->abilitiesText); dd($r);
} }
} }
+3 -3
View File
@@ -44,7 +44,7 @@ class AuthenticateRepository extends BaseRepository
public function nasToolsApprove(string $json) public function nasToolsApprove(string $json)
{ {
$key = env('NAS_TOOLS_KEY'); $key = config('nexus.nas_tools_key');
$encrypter = new Encrypter($key); $encrypter = new Encrypter($key);
$decrypted = $encrypter->decryptString($json); $decrypted = $encrypter->decryptString($json);
$data = json_decode($decrypted, true); $data = json_decode($decrypted, true);
@@ -65,7 +65,7 @@ class AuthenticateRepository extends BaseRepository
public function iyuuApprove($token, $id, $verity) public function iyuuApprove($token, $id, $verity)
{ {
$secret = env('IYUU_SECRET'); $secret = config('nexus.iyuu_secret');
$user = User::query()->findOrFail($id, User::$commonFields); $user = User::query()->findOrFail($id, User::$commonFields);
$user->checkIsNormal(); $user->checkIsNormal();
$encryptedResult = md5($token . $id . sha1($user->passkey) . $secret); $encryptedResult = md5($token . $id . sha1($user->passkey) . $secret);
@@ -90,7 +90,7 @@ class AuthenticateRepository extends BaseRepository
$user->checkIsNormal(); $user->checkIsNormal();
$passkeyHash = hash('sha256', $user->passkey); $passkeyHash = hash('sha256', $user->passkey);
$dataToSign = sprintf("%s%s%s%s", $user->id, $passkeyHash, $request->timestamp, $request->nonce); $dataToSign = sprintf("%s%s%s%s", $user->id, $passkeyHash, $request->timestamp, $request->nonce);
$signatureKey = env('AMMDS_SECRET'); $signatureKey = config('nexus.ammds_secret');
$serverSignature = hash_hmac('sha256', $dataToSign, $signatureKey); $serverSignature = hash_hmac('sha256', $dataToSign, $signatureKey);
if (!hash_equals($serverSignature, $request->signature)) { if (!hash_equals($serverSignature, $request->signature)) {
do_log(sprintf( do_log(sprintf(
+5
View File
@@ -56,4 +56,9 @@ return [
'master_key' => nexus_env('MEILISEARCH_MASTER_KEY', ''), 'master_key' => nexus_env('MEILISEARCH_MASTER_KEY', ''),
], ],
'nas_tools_key' => nexus_env('NAS_TOOLS_KEY', ''),
'iyuu_secret' => nexus_env('IYUU_SECRET', ''),
'ammds_secret' => nexus_env('AMMDS_SECRET', ''),
]; ];