mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 10:53:37 +00:00
Create keys by hand if not existing.
This commit is contained in:
@@ -40,7 +40,9 @@ use Google2FA;
|
|||||||
use Hash;
|
use Hash;
|
||||||
use Illuminate\Contracts\Auth\Guard;
|
use Illuminate\Contracts\Auth\Guard;
|
||||||
use Laravel\Passport\ClientRepository;
|
use Laravel\Passport\ClientRepository;
|
||||||
|
use Laravel\Passport\Passport;
|
||||||
use Log;
|
use Log;
|
||||||
|
use phpseclib\Crypt\RSA;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Session;
|
use Session;
|
||||||
use View;
|
use View;
|
||||||
@@ -202,7 +204,12 @@ class ProfileController extends Controller
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
// check if client token thing exists (default one)
|
// check if client token thing exists (default one)
|
||||||
$count = DB::table('oauth_clients')->whereNull('user_id')->count();
|
$count = DB::table('oauth_clients')
|
||||||
|
->where('personal_access_client', 1)
|
||||||
|
->whereNull('user_id')->count();
|
||||||
|
|
||||||
|
$this->createOAuthKeys();
|
||||||
|
|
||||||
if ($count === 0) {
|
if ($count === 0) {
|
||||||
/** @var ClientRepository $repository */
|
/** @var ClientRepository $repository */
|
||||||
$repository = app(ClientRepository::class);
|
$repository = app(ClientRepository::class);
|
||||||
@@ -415,6 +422,28 @@ class ProfileController extends Controller
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private function createOAuthKeys()
|
||||||
|
{
|
||||||
|
$rsa = new RSA();
|
||||||
|
$keys = $rsa->createKey(4096);
|
||||||
|
|
||||||
|
[$publicKey, $privateKey] = [
|
||||||
|
Passport::keyPath('oauth-public.key'),
|
||||||
|
Passport::keyPath('oauth-private.key'),
|
||||||
|
];
|
||||||
|
|
||||||
|
if (file_exists($publicKey) || file_exists($privateKey)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Log::alert('NO OAuth keys were found. They have been created.');
|
||||||
|
|
||||||
|
file_put_contents($publicKey, array_get($keys, 'publickey'));
|
||||||
|
file_put_contents($privateKey, array_get($keys, 'privatekey'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user