This commit is contained in:
2026-03-10 22:25:43 -05:00
parent 23bfcb65db
commit b47e4f1af0
4 changed files with 422 additions and 49 deletions

View File

@@ -37,55 +37,16 @@ class EveLoginController extends Controller
try {
$ssoUser = Socialite::driver('eveonline')->user();
$characterId = strtr($ssoUser['sub'], ['CHARACTER:EVE:' => '']);
$characterName = $ssoUser['name'];
$characterOwnerHash = $ssoUser['owner'];
$avatar = 'https://image.eveonline.com/Character/' . $characterId . '_128.jpg';
$token = $ssoUser->token;
$refreshToken = $ssoUser->refreshToken ?? null;
$expiresIn = $ssoUser->expiresIn ?? null;
$scopes = is_array($ssoUser['scp']) ? $ssoUser['scp'] : [$ssoUser['scp']];
//Add user to the database
$user = User::updateOrCreate(
['character_id' => $characterId],
[
'avatar' => $avatar,
'character_name' => $characterName,
'character_owner_hash' => $characterOwnerHash,
'token' => $token,
'refresh_token' => $refreshToken,
'expiresIn' => $expiresIn,
]
);
//Add scopes to the scope database
EsiScope::where(['character_id' => $characterId])->delete();
foreach($scopes as $scope) {
$data = new EsiScope;
$data->character_id = $characterId;
$data->scope = $scope;
$data->save();
}
//Add Esi Token to the token database
$esiToken = EsiToken::updateOrCreate(
['character_id' => $characterId],
[
'access_token' => $token,
'refresh_token' => $refreshToken,
'inserted_at' => time(),
'expires_in' => $expiresIn,
]
);
$user = $this->CreateOrUpdateUser($ssoUser);
// Always regenerate JWT on successful login
$jwtService->forceRefresh($user);
//Login the user
Auth::login($user, true);
//Regenerate the session
$request->session()->regenerate();
return redirect()->route('dashboard');
//Send the user to the dashboard
return redirect()->route('dashboard')->with($user->token, 'Token');
} catch (ClientException $e) {
Log::error('EVE SSO Client Exception', [
'message' => $e->getMessage(),
@@ -108,4 +69,51 @@ class EveLoginController extends Controller
->with('error', 'SSO login failed. Please try again.' . $e);
}
}
private function CreateOrUpdateUser($ssoUser)
{
$characterId = strtr($ssoUser['sub'], ['CHARACTER:EVE:' => '']);
$characterName = $ssoUser['name'];
$characterOwnerHash = $ssoUser['owner'];
$avatar = 'https://image.eveonline.com/Character/' . $characterId . '_128.jpg';
$token = $ssoUser->token;
$refreshToken = $ssoUser->refreshToken ?? null;
$expiresIn = $ssoUser->expiresIn ?? null;
$scopes = is_array($ssoUser['scp']) ? $ssoUser['scp'] : [$ssoUser['scp']];
//Add user to the database
$user = User::updateOrCreate(
['character_id' => $characterId],
[
'avatar' => $avatar,
'character_name' => $characterName,
'character_owner_hash' => $characterOwnerHash,
'token' => $token,
'refresh_token' => $refreshToken,
'expiresIn' => $expiresIn,
]
);
//Delete currently saved scopes, then add the scopes used to login with.
EsiScope::where(['character_id' => $characterId])->delete();
foreach($scopes as $scope) {
$data = new EsiScope;
$data->character_id = $characterId;
$data->scope = $scope;
$data->save();
}
//Add Esi Token to the token database
$esiToken = EsiToken::updateOrCreate(
['character_id' => $characterId],
[
'access_token' => $token,
'refresh_token' => $refreshToken,
'inserted_at' => time(),
'expires_in' => $expiresIn,
]
);
return $user;
}
}

View File

@@ -2,12 +2,32 @@
namespace App\Http\Controllers\Dashboard;
//Internal Library
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
//Application Library
use App\Library\Esi\Esi;
//Models
use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
use App\Models\Auth\UserPermission;
use App\Models\Auth\UserRole;
class DashboardController extends Controller
{
public function __construct() {
$this->middleware('auth');
$this->middleware('role:User');
}
public function displayDashboard() {
return view('dashboard.dashboard');
}
}

View File

@@ -6,14 +6,16 @@
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "^8.2",
"drkthunder02/eseye": "^0.1.0",
"php": "^8.4",
"asantibanez/livewire-charts": "^4.2",
"drkthunder02/eseye": "0.1.0",
"firebase/php-jwt": "^7.0",
"laravel/framework": "^12.0",
"laravel/horizon": "^5.44",
"laravel/tinker": "^2.10.1",
"laravel/ui": "^4.6",
"socialiteproviders/eveonline": "^4.4"
"socialiteproviders/eveonline": "^4.4",
"spatie/laravel-prometheus": "^1.5"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^4.1",

347
composer.lock generated
View File

@@ -4,8 +4,70 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a6ca21d50e67ef5fcc522aeffba97342",
"content-hash": "c38eb63675202b3bd42d1dcdda9d15ae",
"packages": [
{
"name": "asantibanez/livewire-charts",
"version": "v4.2.0",
"source": {
"type": "git",
"url": "https://github.com/asantibanez/livewire-charts.git",
"reference": "f318e25e66c4eacc20457dfba60e9b946ee77f92"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/asantibanez/livewire-charts/zipball/f318e25e66c4eacc20457dfba60e9b946ee77f92",
"reference": "f318e25e66c4eacc20457dfba60e9b946ee77f92",
"shasum": ""
},
"require": {
"illuminate/support": "^7.0|^8.0|^9.0|^10.0|^11.0|^12.0",
"livewire/livewire": "^3.0",
"php": "^7.2|^7.3|^7.4|^8.0|^8.2|^8.3"
},
"require-dev": {
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0",
"phpunit/phpunit": "^8.0|^9.5.10|^10.5"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"LivewireCharts": "Asantibanez\\LivewireCharts\\LivewireChartsFacade"
},
"providers": [
"Asantibanez\\LivewireCharts\\LivewireChartsServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Asantibanez\\LivewireCharts\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andrés Santibáñez",
"email": "santibanez.andres@gmail.com",
"role": "Developer"
}
],
"description": "Livewire Charts",
"homepage": "https://github.com/asantibanez/livewire-charts",
"keywords": [
"asantibanez",
"livewire-charts"
],
"support": {
"issues": "https://github.com/asantibanez/livewire-charts/issues",
"source": "https://github.com/asantibanez/livewire-charts/tree/v4.2.0"
},
"time": "2025-12-18T16:58:46+00:00"
},
{
"name": "brick/math",
"version": "0.14.8",
@@ -2511,6 +2573,82 @@
],
"time": "2026-01-15T06:54:53+00:00"
},
{
"name": "livewire/livewire",
"version": "v3.7.11",
"source": {
"type": "git",
"url": "https://github.com/livewire/livewire.git",
"reference": "addd6e8e9234df75f29e6a327ee2a745a7d67bb6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/addd6e8e9234df75f29e6a327ee2a745a7d67bb6",
"reference": "addd6e8e9234df75f29e6a327ee2a745a7d67bb6",
"shasum": ""
},
"require": {
"illuminate/database": "^10.0|^11.0|^12.0|^13.0",
"illuminate/routing": "^10.0|^11.0|^12.0|^13.0",
"illuminate/support": "^10.0|^11.0|^12.0|^13.0",
"illuminate/validation": "^10.0|^11.0|^12.0|^13.0",
"laravel/prompts": "^0.1.24|^0.2|^0.3",
"league/mime-type-detection": "^1.9",
"php": "^8.1",
"symfony/console": "^6.0|^7.0|^8.0",
"symfony/http-kernel": "^6.2|^7.0|^8.0"
},
"require-dev": {
"calebporzio/sushi": "^2.1",
"laravel/framework": "^10.15.0|^11.0|^12.0|^13.0",
"mockery/mockery": "^1.3.1",
"orchestra/testbench": "^8.21.0|^9.0|^10.0|^11.0",
"orchestra/testbench-dusk": "^8.24|^9.1|^10.0|^11.0",
"phpunit/phpunit": "^10.4|^11.5|^12.5",
"psy/psysh": "^0.11.22|^0.12"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Livewire": "Livewire\\Livewire"
},
"providers": [
"Livewire\\LivewireServiceProvider"
]
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Livewire\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Caleb Porzio",
"email": "calebporzio@gmail.com"
}
],
"description": "A front-end framework for Laravel.",
"support": {
"issues": "https://github.com/livewire/livewire/issues",
"source": "https://github.com/livewire/livewire/tree/v3.7.11"
},
"funding": [
{
"url": "https://github.com/livewire",
"type": "github"
}
],
"time": "2026-02-26T00:58:19+00:00"
},
{
"name": "monolog/monolog",
"version": "3.10.0",
@@ -3390,6 +3528,74 @@
],
"time": "2022-01-05T17:46:08+00:00"
},
{
"name": "promphp/prometheus_client_php",
"version": "v2.14.1",
"source": {
"type": "git",
"url": "https://github.com/PromPHP/prometheus_client_php.git",
"reference": "a283aea8269287dc35313a0055480d950c59ac1f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PromPHP/prometheus_client_php/zipball/a283aea8269287dc35313a0055480d950c59ac1f",
"reference": "a283aea8269287dc35313a0055480d950c59ac1f",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.4|^8.0"
},
"replace": {
"endclothing/prometheus_client_php": "*",
"jimdo/prometheus_client_php": "*",
"lkaemmerling/prometheus_client_php": "*"
},
"require-dev": {
"guzzlehttp/guzzle": "^6.3|^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.5.4",
"phpstan/phpstan-phpunit": "^1.1.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpunit/phpunit": "^9.4",
"squizlabs/php_codesniffer": "^3.6",
"symfony/polyfill-apcu": "^1.6"
},
"suggest": {
"ext-apc": "Required if using APCu.",
"ext-pdo": "Required if using PDO.",
"ext-redis": "Required if using Redis.",
"promphp/prometheus_push_gateway_php": "An easy client for using Prometheus PushGateway.",
"symfony/polyfill-apcu": "Required if you use APCu on PHP8.0+"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Prometheus\\": "src/Prometheus/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Lukas Kämmerling",
"email": "kontakt@lukas-kaemmerling.de"
}
],
"description": "Prometheus instrumentation library for PHP applications.",
"support": {
"issues": "https://github.com/PromPHP/prometheus_client_php/issues",
"source": "https://github.com/PromPHP/prometheus_client_php/tree/v2.14.1"
},
"time": "2025-04-14T07:59:43+00:00"
},
{
"name": "psr/clock",
"version": "1.0.0",
@@ -4204,6 +4410,143 @@
},
"time": "2025-02-24T19:33:30+00:00"
},
{
"name": "spatie/laravel-package-tools",
"version": "1.93.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-package-tools.git",
"reference": "0d097bce95b2bf6802fb1d83e1e753b0f5a948e7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/0d097bce95b2bf6802fb1d83e1e753b0f5a948e7",
"reference": "0d097bce95b2bf6802fb1d83e1e753b0f5a948e7",
"shasum": ""
},
"require": {
"illuminate/contracts": "^10.0|^11.0|^12.0|^13.0",
"php": "^8.1"
},
"require-dev": {
"mockery/mockery": "^1.5",
"orchestra/testbench": "^8.0|^9.2|^10.0|^11.0",
"pestphp/pest": "^2.1|^3.1|^4.0",
"phpunit/php-code-coverage": "^10.0|^11.0|^12.0",
"phpunit/phpunit": "^10.5|^11.5|^12.5",
"spatie/pest-plugin-test-time": "^2.2|^3.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\LaravelPackageTools\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"role": "Developer"
}
],
"description": "Tools for creating Laravel packages",
"homepage": "https://github.com/spatie/laravel-package-tools",
"keywords": [
"laravel-package-tools",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-package-tools/issues",
"source": "https://github.com/spatie/laravel-package-tools/tree/1.93.0"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2026-02-21T12:49:54+00:00"
},
{
"name": "spatie/laravel-prometheus",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-prometheus.git",
"reference": "4dbff129ca710f1ca65ce2a0684d9ae60cfbc6c1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-prometheus/zipball/4dbff129ca710f1ca65ce2a0684d9ae60cfbc6c1",
"reference": "4dbff129ca710f1ca65ce2a0684d9ae60cfbc6c1",
"shasum": ""
},
"require": {
"illuminate/config": "^12.0|^13.0",
"illuminate/contracts": "^12.0|^13.0",
"illuminate/support": "^12.0|^13.0",
"php": "^8.4",
"promphp/prometheus_client_php": "^2.7.1",
"spatie/laravel-package-tools": "^1.15.0"
},
"require-dev": {
"ext-redis": "*",
"larastan/larastan": "^3.0",
"laravel/horizon": "^5.28",
"laravel/pint": "^1.10",
"mockery/mockery": "^1.6",
"orchestra/testbench": "^10.0|^11.0",
"pestphp/pest": "^4.4",
"pestphp/pest-plugin-arch": "^4.0",
"pestphp/pest-plugin-laravel": "^4.1",
"spatie/laravel-ray": "^1.32.4",
"spatie/pest-plugin-snapshots": "^2.0"
},
"type": "library",
"extra": {
"laravel": {
"aliases": {
"Prometheus": "Spatie\\Prometheus\\Facades\\Prometheus"
},
"providers": [
"Spatie\\Prometheus\\PrometheusServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\Prometheus\\": "src/",
"Spatie\\Prometheus\\Database\\Factories\\": "database/factories/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"role": "Developer"
}
],
"description": "Export Laravel metrics to Prometheus",
"homepage": "https://github.com/spatie/laravel-prometheus",
"keywords": [
"laravel",
"laravel-prometheus",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-prometheus/issues",
"source": "https://github.com/spatie/laravel-prometheus/tree/1.5.0"
},
"time": "2026-03-06T08:39:22+00:00"
},
{
"name": "spomky-labs/base64url",
"version": "v2.0.4",
@@ -10258,7 +10601,7 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^8.2"
"php": "^8.4"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"