2019-05-20 07:37:41 +02:00
|
|
|
<?php
|
|
|
|
|
2022-11-17 16:54:14 +01:00
|
|
|
use App\Http\Controllers\Auth\ForgotPasswordController;
|
|
|
|
use App\Http\Controllers\Auth\LoginController;
|
|
|
|
use App\Http\Controllers\Auth\PasswordController;
|
|
|
|
use App\Http\Controllers\Auth\RegisterController;
|
|
|
|
use App\Http\Controllers\Auth\ResetPasswordController;
|
2023-11-20 23:25:36 +01:00
|
|
|
use App\Http\Controllers\Auth\SocialiteController;
|
2022-11-17 16:54:14 +01:00
|
|
|
use App\Http\Controllers\Auth\UserController;
|
2022-03-15 14:47:07 +01:00
|
|
|
use App\Http\Controllers\Auth\WebAuthnDeviceLostController;
|
2022-11-17 16:54:14 +01:00
|
|
|
use App\Http\Controllers\Auth\WebAuthnLoginController;
|
|
|
|
use App\Http\Controllers\Auth\WebAuthnManageController;
|
2022-03-15 14:47:07 +01:00
|
|
|
use App\Http\Controllers\Auth\WebAuthnRecoveryController;
|
2022-11-17 16:54:14 +01:00
|
|
|
use App\Http\Controllers\Auth\WebAuthnRegisterController;
|
|
|
|
use App\Http\Controllers\SinglePageController;
|
|
|
|
use App\Http\Controllers\SystemController;
|
2024-11-17 20:39:27 +01:00
|
|
|
use App\Http\Middleware\AddContentSecurityPolicyHeaders;
|
2024-06-26 17:14:30 +02:00
|
|
|
use App\Http\Middleware\CustomCreateFreshApiToken;
|
|
|
|
use App\Http\Middleware\SetLanguage;
|
|
|
|
use Illuminate\Routing\Middleware\SubstituteBindings;
|
|
|
|
// use Illuminate\Foundation\Events\DiagnosingHealth;
|
|
|
|
// use Illuminate\Support\Facades\Event;
|
2022-11-17 16:54:14 +01:00
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
use Laravel\Passport\Http\Controllers\PersonalAccessTokenController;
|
2022-03-15 14:47:07 +01:00
|
|
|
|
2024-04-15 00:44:18 +02:00
|
|
|
// use App\Models\User;
|
2024-06-28 16:13:45 +02:00
|
|
|
// use App\Notifications\SignedInWithNewDeviceNotification;
|
2024-04-23 16:28:42 +02:00
|
|
|
// use App\Models\AuthLog;
|
2024-04-15 00:44:18 +02:00
|
|
|
|
2019-05-20 07:37:41 +02:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| Web Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2022-03-24 14:58:30 +01:00
|
|
|
/**
|
2024-10-27 07:17:00 +01:00
|
|
|
* Routes that only work for unauthenticated user (otherwise, the user is logged out)
|
2022-03-24 14:58:30 +01:00
|
|
|
*/
|
2024-10-26 18:45:30 +02:00
|
|
|
Route::group(['middleware' => ['rejectIfDemoMode', 'RejectIfSsoOnlyAndNotForAdmin', 'forceLogout']], function () {
|
2022-11-17 16:54:14 +01:00
|
|
|
Route::post('user', [RegisterController::class, 'register'])->name('user.register');
|
|
|
|
Route::post('user/password/lost', [ForgotPasswordController::class, 'sendResetLinkEmail'])->name('user.password.lost');
|
|
|
|
Route::post('user/password/reset', [ResetPasswordController::class, 'reset'])->name('password.reset');
|
2022-03-24 14:58:30 +01:00
|
|
|
Route::post('webauthn/login/options', [WebAuthnLoginController::class, 'options'])->name('webauthn.login.options');
|
|
|
|
Route::post('webauthn/lost', [WebAuthnDeviceLostController::class, 'sendRecoveryEmail'])->name('webauthn.lost');
|
2022-11-14 17:13:24 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Routes that can be requested max 10 times per minute by the same IP
|
|
|
|
*/
|
2024-10-26 18:45:30 +02:00
|
|
|
Route::group(['middleware' => ['rejectIfDemoMode', 'throttle:10,1', 'RejectIfSsoOnlyAndNotForAdmin', 'forceLogout']], function () {
|
2022-03-24 14:58:30 +01:00
|
|
|
Route::post('webauthn/recover', [WebAuthnRecoveryController::class, 'recover'])->name('webauthn.recover');
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2024-10-27 07:17:00 +01:00
|
|
|
* Routes that only work for unauthenticated user (otherwise, the user is logged out)
|
|
|
|
* that can be requested max 10 times per minute by the same IP
|
2022-03-24 14:58:30 +01:00
|
|
|
*/
|
2024-10-26 18:45:30 +02:00
|
|
|
Route::group(['middleware' => ['forceLogout', 'throttle:10,1']], function () {
|
2024-09-26 23:50:01 +02:00
|
|
|
Route::post('user/login', [LoginController::class, 'login'])->name('user.login')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
2024-09-20 10:50:25 +02:00
|
|
|
Route::post('webauthn/login', [WebAuthnLoginController::class, 'login'])->name('webauthn.login')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
2023-11-20 23:25:36 +01:00
|
|
|
|
|
|
|
Route::get('/socialite/redirect/{driver}', [SocialiteController::class, 'redirect'])->name('socialite.redirect');
|
|
|
|
Route::get('/socialite/callback/{driver}', [SocialiteController::class, 'callback'])->name('socialite.callback');
|
2022-03-24 14:58:30 +01:00
|
|
|
});
|
2019-05-20 07:37:41 +02:00
|
|
|
|
2022-03-24 14:58:30 +01:00
|
|
|
/**
|
2024-09-20 10:50:25 +02:00
|
|
|
* Routes protected by an authentication guard but rejected when the reverse-proxy
|
|
|
|
* guard is enabled or SSO only is enabled
|
2022-03-24 14:58:30 +01:00
|
|
|
*/
|
2022-03-29 15:02:43 +02:00
|
|
|
Route::group(['middleware' => ['behind-auth', 'rejectIfReverseProxy']], function () {
|
2022-11-17 16:54:14 +01:00
|
|
|
Route::put('user', [UserController::class, 'update'])->name('user.update');
|
|
|
|
Route::patch('user/password', [PasswordController::class, 'update'])->name('user.password.update')->middleware('rejectIfDemoMode');
|
|
|
|
Route::get('user/logout', [LoginController::class, 'logout'])->name('user.logout');
|
|
|
|
Route::delete('user', [UserController::class, 'delete'])->name('user.delete')->middleware('rejectIfDemoMode');
|
|
|
|
|
2024-09-20 10:50:25 +02:00
|
|
|
Route::get('oauth/personal-access-tokens', [PersonalAccessTokenController::class, 'forUser'])->name('passport.personal.tokens.index')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
|
|
|
Route::post('oauth/personal-access-tokens', [PersonalAccessTokenController::class, 'store'])->name('passport.personal.tokens.store')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
|
|
|
Route::delete('oauth/personal-access-tokens/{token_id}', [PersonalAccessTokenController::class, 'destroy'])->name('passport.personal.tokens.destroy')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
2022-03-24 14:58:30 +01:00
|
|
|
|
2024-09-20 10:50:25 +02:00
|
|
|
Route::post('webauthn/register/options', [WebAuthnRegisterController::class, 'options'])->name('webauthn.register.options')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
|
|
|
Route::post('webauthn/register', [WebAuthnRegisterController::class, 'register'])->name('webauthn.register')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
|
|
|
Route::get('webauthn/credentials', [WebAuthnManageController::class, 'index'])->name('webauthn.credentials.index')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
|
|
|
Route::patch('webauthn/credentials/{credential}/name', [WebAuthnManageController::class, 'rename'])->name('webauthn.credentials.rename')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
|
|
|
Route::delete('webauthn/credentials/{credential}', [WebAuthnManageController::class, 'delete'])->name('webauthn.credentials.delete')->middleware('RejectIfSsoOnlyAndNotForAdmin');
|
2022-03-15 14:47:07 +01:00
|
|
|
});
|
|
|
|
|
2024-02-22 14:12:47 +01:00
|
|
|
/**
|
|
|
|
* Routes protected by an authentication guard and restricted to administrators
|
|
|
|
*/
|
2024-03-29 09:42:54 +01:00
|
|
|
Route::group(['middleware' => ['behind-auth', 'admin']], function () {
|
2024-03-07 14:13:02 +01:00
|
|
|
Route::get('system/infos', [SystemController::class, 'infos'])->name('system.infos');
|
|
|
|
Route::post('system/test-email', [SystemController::class, 'testEmail'])->name('system.testEmail');
|
2024-02-22 14:12:47 +01:00
|
|
|
});
|
|
|
|
|
2024-03-07 14:13:02 +01:00
|
|
|
Route::get('system/optimize', [SystemController::class, 'optimize'])->name('system.optimize');
|
|
|
|
Route::get('system/clear-cache', [SystemController::class, 'clear'])->name('system.clear');
|
|
|
|
Route::get('system/latestRelease', [SystemController::class, 'latestRelease'])->name('system.latestRelease');
|
|
|
|
|
|
|
|
Route::get('refresh-csrf', function () {
|
|
|
|
return csrf_token();
|
|
|
|
});
|
2022-07-14 17:07:28 +02:00
|
|
|
|
2024-06-26 17:14:30 +02:00
|
|
|
Route::withoutMiddleware([
|
2024-09-26 23:50:01 +02:00
|
|
|
SubstituteBindings::class,
|
|
|
|
SetLanguage::class,
|
|
|
|
CustomCreateFreshApiToken::class,
|
|
|
|
])->get('/up', function () {
|
2024-06-26 17:14:30 +02:00
|
|
|
//Event::dispatch(new DiagnosingHealth);
|
|
|
|
return view('health');
|
|
|
|
});
|
|
|
|
|
2024-04-15 00:44:18 +02:00
|
|
|
// Route::get('/notification', function () {
|
|
|
|
// $user = User::find(1);
|
2024-06-28 16:13:45 +02:00
|
|
|
// return (new SignedInWithNewDeviceNotification(AuthLog::find(9)))
|
2024-04-15 00:44:18 +02:00
|
|
|
// ->toMail($user);
|
|
|
|
// });
|
|
|
|
|
2022-03-24 14:58:30 +01:00
|
|
|
/**
|
|
|
|
* Route for the main landing view
|
|
|
|
*/
|
2024-11-17 20:39:27 +01:00
|
|
|
Route::get('/{any}', [SinglePageController::class, 'index'])->where('any', '.*')->name('landing')->middleware(AddContentSecurityPolicyHeaders::class);
|