2023-03-17 14:33:48 +00:00
|
|
|
<?php
|
|
|
|
|
2023-04-19 10:42:15 +00:00
|
|
|
use App\Http\Controllers\ApplicationController;
|
2023-06-07 13:08:35 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
2023-08-08 09:51:36 +00:00
|
|
|
use App\Http\Controllers\DatabaseController;
|
2023-06-07 13:08:35 +00:00
|
|
|
use App\Http\Controllers\MagicController;
|
2023-03-28 20:13:08 +00:00
|
|
|
use App\Http\Controllers\ProjectController;
|
2023-09-20 13:42:41 +00:00
|
|
|
use App\Http\Livewire\Boarding\Index as BoardingIndex;
|
2023-09-21 15:48:31 +00:00
|
|
|
use App\Http\Livewire\Project\Service\Index as ServiceIndex;
|
2023-09-22 09:23:49 +00:00
|
|
|
use App\Http\Livewire\Project\Service\Show as ServiceShow;
|
2023-10-04 12:40:33 +00:00
|
|
|
use App\Http\Livewire\Dev\Compose as Compose;
|
2023-08-29 12:36:17 +00:00
|
|
|
use App\Http\Livewire\Dashboard;
|
2023-10-20 10:34:53 +00:00
|
|
|
use App\Http\Livewire\Project\CloneProject;
|
2023-10-02 11:38:16 +00:00
|
|
|
use App\Http\Livewire\Project\Shared\Logs;
|
2023-10-20 12:51:01 +00:00
|
|
|
use App\Http\Livewire\Security\ApiTokens;
|
2023-08-29 12:36:17 +00:00
|
|
|
use App\Http\Livewire\Server\All;
|
2023-10-09 09:00:18 +00:00
|
|
|
use App\Http\Livewire\Server\Create;
|
|
|
|
use App\Http\Livewire\Server\Destination\Show as DestinationShow;
|
|
|
|
use App\Http\Livewire\Server\PrivateKey\Show as PrivateKeyShow;
|
|
|
|
use App\Http\Livewire\Server\Proxy\Show as ProxyShow;
|
2023-10-11 09:00:40 +00:00
|
|
|
use App\Http\Livewire\Server\Proxy\Logs as ProxyLogs;
|
2023-08-29 12:36:17 +00:00
|
|
|
use App\Http\Livewire\Server\Show;
|
2023-11-07 08:44:47 +00:00
|
|
|
use App\Http\Livewire\Source\Github\Change as GitHubChange;
|
2023-10-11 07:55:05 +00:00
|
|
|
use App\Http\Livewire\Subscription\Show as SubscriptionShow;
|
2023-09-01 07:34:25 +00:00
|
|
|
use App\Http\Livewire\Waitlist\Index as WaitlistIndex;
|
2023-08-08 09:51:36 +00:00
|
|
|
use App\Models\GitlabApp;
|
2023-05-03 10:38:57 +00:00
|
|
|
use App\Models\PrivateKey;
|
2023-08-08 09:51:36 +00:00
|
|
|
use App\Models\Server;
|
2023-05-02 10:47:52 +00:00
|
|
|
use App\Models\StandaloneDocker;
|
|
|
|
use App\Models\SwarmDocker;
|
2023-10-09 12:20:55 +00:00
|
|
|
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
2023-05-08 11:36:49 +00:00
|
|
|
use Illuminate\Http\Request;
|
2023-06-12 14:39:48 +00:00
|
|
|
use Illuminate\Support\Facades\Password;
|
2023-03-17 14:33:48 +00:00
|
|
|
use Illuminate\Support\Facades\Route;
|
2023-05-08 19:56:44 +00:00
|
|
|
use Illuminate\Support\Str;
|
2023-06-12 14:39:48 +00:00
|
|
|
use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse;
|
|
|
|
use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse;
|
|
|
|
use Laravel\Fortify\Fortify;
|
2023-03-17 14:33:48 +00:00
|
|
|
|
2023-10-04 12:40:33 +00:00
|
|
|
if (isDev()) {
|
|
|
|
Route::get('/dev/compose', Compose::class)->name('dev.compose');
|
|
|
|
}
|
2023-06-12 14:39:48 +00:00
|
|
|
Route::post('/forgot-password', function (Request $request) {
|
2023-06-16 12:27:34 +00:00
|
|
|
if (is_transactional_emails_active()) {
|
2023-09-13 18:27:58 +00:00
|
|
|
$arrayOfRequest = $request->only(Fortify::email());
|
|
|
|
$request->merge([
|
|
|
|
'email' => Str::lower($arrayOfRequest['email']),
|
|
|
|
]);
|
2023-08-31 13:00:59 +00:00
|
|
|
$type = set_transanctional_email_settings();
|
|
|
|
if (!$type) {
|
|
|
|
return response()->json(['message' => 'Transactional emails are not active'], 400);
|
|
|
|
}
|
2023-06-12 14:39:48 +00:00
|
|
|
$request->validate([Fortify::email() => 'required|email']);
|
|
|
|
$status = Password::broker(config('fortify.passwords'))->sendResetLink(
|
|
|
|
$request->only(Fortify::email())
|
|
|
|
);
|
2023-06-16 12:27:34 +00:00
|
|
|
if ($status == Password::RESET_LINK_SENT) {
|
|
|
|
return app(SuccessfulPasswordResetLinkRequestResponse::class, ['status' => $status]);
|
|
|
|
}
|
|
|
|
if ($status == Password::RESET_THROTTLED) {
|
|
|
|
return response('Already requested a password reset in the past minutes.', 400);
|
|
|
|
}
|
|
|
|
return app(FailedPasswordResetLinkRequestResponse::class, ['status' => $status]);
|
2023-06-12 13:47:42 +00:00
|
|
|
}
|
2023-06-12 14:39:48 +00:00
|
|
|
return response()->json(['message' => 'Transactional emails are not active'], 400);
|
2023-06-12 13:47:42 +00:00
|
|
|
})->name('password.forgot');
|
2023-10-09 12:20:55 +00:00
|
|
|
|
|
|
|
|
2023-09-01 07:34:25 +00:00
|
|
|
Route::get('/waitlist', WaitlistIndex::class)->name('waitlist.index');
|
2023-10-09 12:20:55 +00:00
|
|
|
|
|
|
|
Route::get('/verify', function () {
|
|
|
|
return view('auth.verify-email');
|
|
|
|
})->middleware('auth')->name('verify.email');
|
|
|
|
|
|
|
|
Route::get('/email/verify/{id}/{hash}', function (EmailVerificationRequest $request) {
|
|
|
|
$request->fulfill();
|
2023-10-11 12:24:19 +00:00
|
|
|
send_internal_notification("User {$request->user()->name} verified their email address.");
|
2023-10-09 12:20:55 +00:00
|
|
|
return redirect('/');
|
|
|
|
})->middleware(['auth'])->name('verify.verify');
|
|
|
|
|
2023-09-11 14:51:38 +00:00
|
|
|
Route::middleware(['throttle:login'])->group(function () {
|
2023-09-06 10:07:34 +00:00
|
|
|
Route::get('/auth/link', [Controller::class, 'link'])->name('auth.link');
|
|
|
|
});
|
2023-06-06 09:35:50 +00:00
|
|
|
Route::prefix('magic')->middleware(['auth'])->group(function () {
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/servers', [MagicController::class, 'servers']);
|
|
|
|
Route::get('/destinations', [MagicController::class, 'destinations']);
|
|
|
|
Route::get('/projects', [MagicController::class, 'projects']);
|
|
|
|
Route::get('/environments', [MagicController::class, 'environments']);
|
2023-06-15 07:15:41 +00:00
|
|
|
Route::get('/project/new', [MagicController::class, 'newProject']);
|
|
|
|
Route::get('/environment/new', [MagicController::class, 'newEnvironment']);
|
2023-06-05 22:18:48 +00:00
|
|
|
});
|
2023-06-07 13:08:35 +00:00
|
|
|
|
2023-10-09 12:20:55 +00:00
|
|
|
Route::middleware(['auth', 'verified'])->group(function () {
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/projects', [ProjectController::class, 'all'])->name('projects');
|
|
|
|
Route::get('/project/{project_uuid}', [ProjectController::class, 'show'])->name('project.show');
|
2023-10-20 10:34:53 +00:00
|
|
|
Route::get('/project/{project_uuid}/edit', [ProjectController::class, 'edit'])->name('project.edit');
|
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/clone', CloneProject::class)->name('project.clone');
|
|
|
|
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/new', [ProjectController::class, 'new'])->name('project.resources.new');
|
|
|
|
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');
|
2023-08-09 14:47:24 +00:00
|
|
|
|
|
|
|
// Applications
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ApplicationController::class, 'configuration'])->name('project.application.configuration');
|
2023-06-22 13:25:57 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', [ApplicationController::class, 'deployments'])->name('project.application.deployments');
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get(
|
|
|
|
'/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}',
|
|
|
|
[ApplicationController::class, 'deployment']
|
|
|
|
)->name('project.application.deployment');
|
2023-08-09 14:47:24 +00:00
|
|
|
|
2023-10-02 11:38:16 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/logs', Logs::class)->name('project.application.logs');
|
|
|
|
|
2023-08-09 14:47:24 +00:00
|
|
|
// Databases
|
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}', [DatabaseController::class, 'configuration'])->name('project.database.configuration');
|
2023-08-10 13:52:54 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}/backups', [DatabaseController::class, 'backups'])->name('project.database.backups.all');
|
2023-08-11 08:42:57 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}/backups/{backup_uuid}', [DatabaseController::class, 'executions'])->name('project.database.backups.executions');
|
2023-10-02 11:38:16 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/database/{database_uuid}/logs', Logs::class)->name('project.database.logs');
|
|
|
|
|
2023-09-20 13:42:41 +00:00
|
|
|
|
|
|
|
// Services
|
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}', ServiceIndex::class)->name('project.service');
|
2023-09-22 09:23:49 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}', ServiceShow::class)->name('project.service.show');
|
2023-10-02 11:38:16 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/service/{service_uuid}/{service_name}/logs', Logs::class)->name('project.service.logs');
|
2023-06-07 13:08:35 +00:00
|
|
|
});
|
2023-04-25 07:38:05 +00:00
|
|
|
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
2023-08-29 12:36:17 +00:00
|
|
|
Route::get('/servers', All::class)->name('server.all');
|
2023-10-09 09:00:18 +00:00
|
|
|
Route::get('/server/new', Create::class)->name('server.create');
|
2023-08-29 12:36:17 +00:00
|
|
|
Route::get('/server/{server_uuid}', Show::class)->name('server.show');
|
2023-10-09 09:00:18 +00:00
|
|
|
Route::get('/server/{server_uuid}/proxy', ProxyShow::class)->name('server.proxy');
|
2023-10-11 09:00:40 +00:00
|
|
|
Route::get('/server/{server_uuid}/proxy/logs', ProxyLogs::class)->name('server.proxy.logs');
|
2023-10-09 09:00:18 +00:00
|
|
|
Route::get('/server/{server_uuid}/private-key', PrivateKeyShow::class)->name('server.private-key');
|
|
|
|
Route::get('/server/{server_uuid}/destinations', DestinationShow::class)->name('server.destinations');
|
2023-06-07 13:08:35 +00:00
|
|
|
});
|
2023-04-25 07:38:05 +00:00
|
|
|
|
|
|
|
|
2023-10-09 12:20:55 +00:00
|
|
|
Route::middleware(['auth', 'verified'])->group(function () {
|
2023-08-29 12:36:17 +00:00
|
|
|
Route::get('/', Dashboard::class)->name('dashboard');
|
2023-09-20 13:42:41 +00:00
|
|
|
Route::get('/boarding', BoardingIndex::class)->name('boarding');
|
2023-08-29 12:36:17 +00:00
|
|
|
Route::middleware(['throttle:force-password-reset'])->group(function () {
|
2023-08-15 12:27:45 +00:00
|
|
|
Route::get('/force-password-reset', [Controller::class, 'force_passoword_reset'])->name('auth.force-password-reset');
|
|
|
|
});
|
2023-10-11 07:55:05 +00:00
|
|
|
Route::get('/subscription', SubscriptionShow::class)->name('subscription.index');
|
2023-06-07 20:07:26 +00:00
|
|
|
Route::get('/settings', [Controller::class, 'settings'])->name('settings.configuration');
|
2023-07-14 10:09:56 +00:00
|
|
|
Route::get('/settings/license', [Controller::class, 'license'])->name('settings.license');
|
2023-08-11 18:48:52 +00:00
|
|
|
Route::get('/profile', fn () => view('profile', ['request' => request()]))->name('profile');
|
2023-08-30 14:01:38 +00:00
|
|
|
Route::get('/team', [Controller::class, 'team'])->name('team.index');
|
2023-08-11 18:48:52 +00:00
|
|
|
Route::get('/team/new', fn () => view('team.create'))->name('team.create');
|
|
|
|
Route::get('/team/notifications', fn () => view('team.notifications'))->name('team.notifications');
|
2023-08-07 13:31:42 +00:00
|
|
|
Route::get('/team/storages', [Controller::class, 'storages'])->name('team.storages.all');
|
2023-08-11 18:48:52 +00:00
|
|
|
Route::get('/team/storages/new', fn () => view('team.storages.create'))->name('team.storages.new');
|
2023-08-07 13:31:42 +00:00
|
|
|
Route::get('/team/storages/{storage_uuid}', [Controller::class, 'storages_show'])->name('team.storages.show');
|
2023-07-13 20:03:27 +00:00
|
|
|
Route::get('/team/members', [Controller::class, 'members'])->name('team.members');
|
2023-08-11 18:48:52 +00:00
|
|
|
Route::get('/command-center', fn () => view('command-center', ['servers' => Server::isReachable()->get()]))->name('command-center');
|
2023-06-15 07:15:41 +00:00
|
|
|
Route::get('/invitations/{uuid}', [Controller::class, 'acceptInvitation'])->name('team.invitation.accept');
|
|
|
|
Route::get('/invitations/{uuid}/revoke', [Controller::class, 'revokeInvitation'])->name('team.invitation.revoke');
|
2023-04-25 07:38:05 +00:00
|
|
|
});
|
|
|
|
|
2023-05-03 10:38:57 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
2023-09-04 07:44:44 +00:00
|
|
|
Route::get('/security', fn () => view('security.index'))->name('security.index');
|
|
|
|
Route::get('/security/private-key', fn () => view('security.private-key.index', [
|
2023-09-29 09:01:58 +00:00
|
|
|
'privateKeys' => PrivateKey::ownedByCurrentTeam(['name', 'uuid', 'is_git_related'])->get()
|
2023-09-04 07:44:44 +00:00
|
|
|
]))->name('security.private-key.index');
|
|
|
|
Route::get('/security/private-key/new', fn () => view('security.private-key.new'))->name('security.private-key.new');
|
|
|
|
Route::get('/security/private-key/{private_key_uuid}', fn () => view('security.private-key.show', [
|
2023-06-19 08:58:00 +00:00
|
|
|
'private_key' => PrivateKey::ownedByCurrentTeam(['name', 'description', 'private_key', 'is_git_related'])->whereUuid(request()->private_key_uuid)->firstOrFail()
|
2023-09-04 07:44:44 +00:00
|
|
|
]))->name('security.private-key.show');
|
2023-10-20 12:51:01 +00:00
|
|
|
Route::get('/security/api-tokens', ApiTokens::class)->name('security.api-tokens');
|
|
|
|
|
2023-05-03 10:38:57 +00:00
|
|
|
});
|
2023-06-07 13:08:35 +00:00
|
|
|
|
|
|
|
|
2023-05-08 11:36:49 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
2023-08-11 18:48:52 +00:00
|
|
|
Route::get('/source/new', fn () => view('source.new'))->name('source.new');
|
2023-06-12 20:02:10 +00:00
|
|
|
Route::get('/sources', function () {
|
2023-08-22 15:44:49 +00:00
|
|
|
$sources = currentTeam()->sources();
|
2023-06-12 20:02:10 +00:00
|
|
|
return view('source.all', [
|
|
|
|
'sources' => $sources,
|
|
|
|
]);
|
|
|
|
})->name('source.all');
|
2023-11-07 08:44:47 +00:00
|
|
|
Route::get('/source/github/{github_app_uuid}', GitHubChange::class)->name('source.github.show');
|
2023-06-12 20:02:10 +00:00
|
|
|
Route::get('/source/gitlab/{gitlab_app_uuid}', function (Request $request) {
|
|
|
|
$gitlab_app = GitlabApp::where('uuid', request()->gitlab_app_uuid)->first();
|
|
|
|
return view('source.gitlab.show', [
|
|
|
|
'gitlab_app' => $gitlab_app,
|
|
|
|
]);
|
|
|
|
})->name('source.gitlab.show');
|
2023-05-08 11:36:49 +00:00
|
|
|
});
|
2023-04-25 08:47:13 +00:00
|
|
|
|
2023-05-02 10:47:52 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
2023-06-13 08:02:58 +00:00
|
|
|
Route::get('/destinations', function () {
|
|
|
|
$servers = Server::all();
|
|
|
|
$destinations = collect([]);
|
|
|
|
foreach ($servers as $server) {
|
|
|
|
$destinations = $destinations->merge($server->destinations());
|
|
|
|
}
|
|
|
|
return view('destination.all', [
|
|
|
|
'destinations' => $destinations,
|
|
|
|
]);
|
|
|
|
})->name('destination.all');
|
2023-05-03 09:16:08 +00:00
|
|
|
Route::get('/destination/new', function () {
|
2023-07-14 11:38:24 +00:00
|
|
|
$servers = Server::isUsable()->get();
|
2023-05-12 11:10:09 +00:00
|
|
|
$pre_selected_server_uuid = data_get(request()->query(), 'server');
|
|
|
|
if ($pre_selected_server_uuid) {
|
|
|
|
$server = $servers->firstWhere('uuid', $pre_selected_server_uuid);
|
|
|
|
if ($server) {
|
|
|
|
$server_id = $server->id;
|
|
|
|
}
|
|
|
|
}
|
2023-05-03 09:16:08 +00:00
|
|
|
return view('destination.new', [
|
2023-05-04 09:14:37 +00:00
|
|
|
"servers" => $servers,
|
2023-05-12 11:10:09 +00:00
|
|
|
"server_id" => $server_id ?? null,
|
2023-05-03 09:16:08 +00:00
|
|
|
]);
|
|
|
|
})->name('destination.new');
|
2023-05-02 10:47:52 +00:00
|
|
|
Route::get('/destination/{destination_uuid}', function () {
|
|
|
|
$standalone_dockers = StandaloneDocker::where('uuid', request()->destination_uuid)->first();
|
|
|
|
$swarm_dockers = SwarmDocker::where('uuid', request()->destination_uuid)->first();
|
|
|
|
if (!$standalone_dockers && !$swarm_dockers) {
|
|
|
|
abort(404);
|
|
|
|
}
|
|
|
|
$destination = $standalone_dockers ? $standalone_dockers : $swarm_dockers;
|
|
|
|
return view('destination.show', [
|
2023-05-04 09:14:37 +00:00
|
|
|
'destination' => $destination->load(['server']),
|
2023-05-02 10:47:52 +00:00
|
|
|
]);
|
|
|
|
})->name('destination.show');
|
2023-08-08 09:51:36 +00:00
|
|
|
});
|