47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Dedoc\Scramble\Scramble;
|
|
use Dedoc\Scramble\Support\Generator\OpenApi;
|
|
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
|
use Illuminate\Support\Facades\URL;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register any application services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap any application services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
if ($this->app->environment('production')) {
|
|
URL::forceScheme('https');
|
|
}
|
|
|
|
Scramble::auth(function ($request) {
|
|
// Option A : Autoriser tout le monde (Attention : Ta doc sera publique !)
|
|
return true;
|
|
|
|
/* // Option B : Autoriser seulement certains emails (Recommandé)
|
|
return in_array($request->user()?->email, [
|
|
'admin@tondomaine.com',
|
|
]);
|
|
*/
|
|
});
|
|
Scramble::afterOpenApiGenerated(function (OpenApi $openApi) {
|
|
$openApi->secure(
|
|
SecurityScheme::http('bearer')
|
|
);
|
|
});
|
|
}
|
|
}
|