File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 4949 'user_verify_url ' => env ('FRONTEND_APP_URL ' ).'/verify/{id}/{emailHash} ' ,
5050 ],
5151
52+ /*
53+ |--------------------------------------------------------------------------
54+ | RestifyJS
55+ |--------------------------------------------------------------------------
56+ |
57+ | This configuration is used for supporting the RestifyJS
58+ |
59+ */
60+ 'restifyjs ' => [
61+ /*
62+ | Token to authorize the setup endpoint.
63+ */
64+ 'token ' => env ('RESTIFYJS_TOKEN ' , 'testing ' ),
65+ ],
66+
5267 /*
5368 |--------------------------------------------------------------------------
5469 | Restify Base Route
Original file line number Diff line number Diff line change 2020use Binaryk \LaravelRestify \Http \Controllers \RepositoryUpdateBulkController ;
2121use Binaryk \LaravelRestify \Http \Controllers \RepositoryUpdateController ;
2222use Binaryk \LaravelRestify \Http \Controllers \RestifyJsSetupController ;
23+ use Binaryk \LaravelRestify \Http \Middleware \RestifySanctumAuthenticate ;
2324use Illuminate \Support \Facades \Route ;
2425
2526// Global Search...
3132Route::post ('/profile/avatar ' , '\\' .ProfileAvatarController::class);
3233
3334// RestifyJS
34- Route::get ('/restifyjs/setup ' , '\\' .RestifyJsSetupController::class);
35+ Route::get ('/restifyjs/setup ' , '\\' .RestifyJsSetupController::class)->withoutMiddleware (
36+ RestifySanctumAuthenticate::class,
37+ );
3538
3639// Filters
3740Route::get ('/{repository}/filters ' , '\\' .RepositoryFilterController::class);
Original file line number Diff line number Diff line change 55use Binaryk \LaravelRestify \Http \Requests \RestifyRequest ;
66use Binaryk \LaravelRestify \Repositories \Repository ;
77use Binaryk \LaravelRestify \Restify ;
8+ use Illuminate \Http \Request ;
89use Illuminate \Routing \Controller ;
10+ use Illuminate \Support \Facades \App ;
911use Illuminate \Support \Str ;
1012
1113class RestifyJsSetupController extends Controller
1214{
1315 public function __invoke (RestifyRequest $ request )
1416 {
17+ if (App::environment ('production ' )) {
18+ $ this ->authorize ($ request );
19+ }
20+
1521 return response ()->json ([
1622 'config ' => $ this ->config (),
1723 'repositories ' => $ this ->repositories ($ request ),
@@ -46,4 +52,11 @@ private function deleteFirstAndLastSlash(string $domain): string
4652
4753 return $ domain ;
4854 }
55+
56+ private function authorize (Request $ request )
57+ {
58+ if ($ request ->input ('token ' ) !== config ('restify.restifyjs.token ' )) {
59+ abort (401 , 'You are not authorized to see this request. ' );
60+ }
61+ }
4962}
You can’t perform that action at this time.
0 commit comments