2019-05-20 07:37:41 +02:00
|
|
|
<?php
|
|
|
|
|
2022-11-17 16:54:14 +01:00
|
|
|
use App\Api\v1\Controllers\GroupController;
|
|
|
|
use App\Api\v1\Controllers\IconController;
|
|
|
|
use App\Api\v1\Controllers\QrCodeController;
|
|
|
|
use App\Api\v1\Controllers\SettingController;
|
|
|
|
use App\Api\v1\Controllers\TwoFAccountController;
|
|
|
|
use App\Api\v1\Controllers\UserController;
|
2023-03-22 15:40:44 +01:00
|
|
|
use Illuminate\Support\Facades\Date;
|
2022-03-24 14:58:30 +01:00
|
|
|
use Illuminate\Support\Facades\Route;
|
2019-05-20 07:37:41 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| API Routes
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2023-03-22 15:40:44 +01:00
|
|
|
/**
|
|
|
|
* DEPRECATED - Unprotected routes
|
|
|
|
*/
|
2023-03-26 17:13:32 +02:00
|
|
|
Route::get('user/name', function () {
|
2023-03-22 15:40:44 +01:00
|
|
|
return response()->json(['deprecation' => true], 200, ['Deprecation' => Date::createFromDate(2023, 03, 21)->toRfc7231String()]);
|
|
|
|
});
|
|
|
|
|
2022-03-24 14:58:30 +01:00
|
|
|
/**
|
|
|
|
* Routes protected by the api authentication guard
|
|
|
|
*/
|
|
|
|
Route::group(['middleware' => 'auth:api-guard'], function () {
|
2022-11-17 16:54:14 +01:00
|
|
|
Route::get('user', [UserController::class, 'show'])->name('user.show'); // Returns email address in addition to the username
|
|
|
|
|
2023-02-17 17:12:53 +01:00
|
|
|
Route::get('user/preferences/{preferenceName}', [UserController::class, 'showPreference'])->name('user.preferences.show');
|
|
|
|
Route::get('user/preferences', [UserController::class, 'allPreferences'])->name('user.preferences.all');
|
|
|
|
Route::put('user/preferences/{preferenceName}', [UserController::class, 'setPreference'])->name('user.preferences.set');
|
2022-11-17 16:54:14 +01:00
|
|
|
|
|
|
|
Route::delete('twofaccounts', [TwoFAccountController::class, 'batchDestroy'])->name('twofaccounts.batchDestroy');
|
|
|
|
Route::patch('twofaccounts/withdraw', [TwoFAccountController::class, 'withdraw'])->name('twofaccounts.withdraw');
|
|
|
|
Route::post('twofaccounts/reorder', [TwoFAccountController::class, 'reorder'])->name('twofaccounts.reorder');
|
|
|
|
Route::post('twofaccounts/migration', [TwoFAccountController::class, 'migrate'])->name('twofaccounts.migrate');
|
|
|
|
Route::post('twofaccounts/preview', [TwoFAccountController::class, 'preview'])->name('twofaccounts.preview');
|
2022-12-13 15:57:33 +01:00
|
|
|
Route::get('twofaccounts/export', [TwoFAccountController::class, 'export'])->name('twofaccounts.export');
|
2022-11-17 16:54:14 +01:00
|
|
|
Route::get('twofaccounts/{twofaccount}/qrcode', [QrCodeController::class, 'show'])->name('twofaccounts.show.qrcode');
|
|
|
|
Route::get('twofaccounts/count', [TwoFAccountController::class, 'count'])->name('twofaccounts.count');
|
|
|
|
Route::get('twofaccounts/{id}/otp', [TwoFAccountController::class, 'otp'])->where('id', '[0-9]+')->name('twofaccounts.show.otp');
|
|
|
|
Route::post('twofaccounts/otp', [TwoFAccountController::class, 'otp'])->name('twofaccounts.otp');
|
|
|
|
Route::apiResource('twofaccounts', TwoFAccountController::class);
|
|
|
|
|
|
|
|
Route::get('groups/{group}/twofaccounts', [GroupController::class, 'accounts'])->name('groups.show.twofaccounts');
|
|
|
|
Route::post('groups/{group}/assign', [GroupController::class, 'assignAccounts'])->name('groups.assign.twofaccounts');
|
|
|
|
Route::apiResource('groups', GroupController::class);
|
|
|
|
|
|
|
|
Route::post('qrcode/decode', [QrCodeController::class, 'decode'])->name('qrcode.decode');
|
|
|
|
|
|
|
|
Route::post('icons/default', [IconController::class, 'fetch'])->name('icons.fetch');
|
|
|
|
Route::post('icons', [IconController::class, 'upload'])->name('icons.upload');
|
|
|
|
Route::delete('icons/{icon}', [IconController::class, 'delete'])->name('icons.delete');
|
|
|
|
});
|
2023-02-17 17:12:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Routes protected by the api authentication guard and restricted to administrators
|
|
|
|
*/
|
|
|
|
Route::group(['middleware' => ['auth:api-guard', 'admin']], function () {
|
|
|
|
Route::get('settings/{settingName}', [SettingController::class, 'show'])->name('settings.show');
|
|
|
|
Route::get('settings', [SettingController::class, 'index'])->name('settings.index');
|
|
|
|
Route::post('settings', [SettingController::class, 'store'])->name('settings.store');
|
|
|
|
Route::put('settings/{settingName}', [SettingController::class, 'update'])->name('settings.update');
|
|
|
|
Route::delete('settings/{settingName}', [SettingController::class, 'destroy'])->name('settings.destroy');
|
|
|
|
});
|