Compare commits

...
Sign in to create a new pull request.

25 commits

Author SHA1 Message Date
Jérémy Munsch
441c43f3b0
fixes avec vincent bootstrap 2022-09-20 10:33:39 +02:00
Vincent BRIDIER
27247cae04
Update README 2022-09-19 13:23:17 +02:00
Vincent BRIDIER
55671653ea
Update package lock 2022-09-19 13:22:04 +02:00
Vincent BRIDIER
61377d9347
Add missing folder 2022-09-19 13:21:49 +02:00
Vincent BRIDIER
5bedc1aeb7
Update vscode config 2022-09-19 13:21:32 +02:00
Vincent BRIDIER
96683a0f5a
Update OTP Code 2022-09-19 13:21:10 +02:00
Vincent BRIDIER
746e502b49
Update SAML login 2022-09-19 13:20:19 +02:00
Jérémy Munsch
b4797d92fc
Add Missing Foreign Keys 2022-06-15 14:09:52 +02:00
Jérémy Munsch
3d6b775d3d
LdcNetwork api fix 2022-06-15 13:43:05 +02:00
Jérémy Munsch
6992c5d6d0
Fix UpdateProjectStatusRequest 2022-06-15 13:39:23 +02:00
Jérémy Munsch
9f786cbe17
fixed dash board routes
Fix status checker .index bo codes
2022-06-15 13:33:01 +02:00
Jérémy Munsch
dded73e14a
Fix api routes 2022-06-15 13:31:46 +02:00
Jérémy Munsch
b16b4a2107
php cs fix 2022-06-15 13:09:00 +02:00
Jérémy Munsch
1d983f3ff4
Api MIse au propre 2022-06-15 13:05:30 +02:00
Jérémy Munsch
4419445105
Rewrite and refactor fukcing everything ! 2022-06-15 12:07:34 +02:00
Jérémy Munsch
71c09ba141
Code Rfactor and PHPCS compliance (Controllers and Request) WIP 2022-06-13 18:22:08 +02:00
Jérémy Munsch
39676cf557
Code Rfactor and PHPCS compliance 2022-06-13 17:40:44 +02:00
Jérémy Munsch
fe40e02f7c
Refactor Commands 2022-06-13 16:39:07 +02:00
Jérémy Munsch
3e2ef50e6d
Fix laravel 8 composer + PHPCBF bump 2022-06-13 15:49:59 +02:00
Jérémy Munsch
4441f6d547
- Remove Risk WPAutoLogin component (is now included in WPAutoLogin component)
- Fix LoginIdComponent usage
2022-06-13 15:40:33 +02:00
Jérémy Munsch
c6e15928f1
TypeScript + Vue 3 2022-06-13 14:31:15 +02:00
Jérémy Munsch
81c8cbde69
Add peacock color 2022-06-13 13:02:45 +02:00
Jérémy Munsch
27c296aaff
update gitignore 2022-06-13 13:02:18 +02:00
Jérémy Munsch
96729e4a53
npm update 2022-06-13 12:56:06 +02:00
Jérémy Munsch
2696e19b0e
bump composer deps 2022-06-13 12:55:19 +02:00
204 changed files with 10375 additions and 8164 deletions

View file

@ -44,4 +44,7 @@ MAILJET_SMSENDPOINT=
MAILJET_SMSFROM=
WEBHOOKS_GITLAB_NOTIFY=
WEBHOOKS_GITLAB_TOKEN=
WEBHOOKS_GITLAB_TOKEN=
MEMCACHED_HOST=
MEMCACHED_PORT=

16
.gitignore vendored
View file

@ -3,17 +3,29 @@
/public/storage
/public/css
/public/js
/public/images
/public/fonts
/public/webfonts
/public/medias
/public/uploads
/public/assets
/public/cache
/public/mix-manifest.json
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.idea/
/.idea
/.vscode
/public/.htpasswd
/public/.htaccess
/resourcesLegacy

23
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,23 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#385567",
"activityBar.activeBorder": "#b06e97",
"activityBar.background": "#385567",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#b06e97",
"activityBarBadge.foreground": "#15202b",
"sash.hoverBorder": "#385567",
"statusBar.background": "#263a46",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#385567",
"statusBarItem.remoteBackground": "#263a46",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#263a46",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#263a4699",
"titleBar.inactiveForeground": "#e7e7e799",
"commandCenter.border": "#e7e7e799"
},
"peacock.remoteColor": "#263a46"
}

View file

@ -1,78 +1,12 @@
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[British Software Development](https://www.britishsoftware.co)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- [UserInsights](https://userinsights.com)
- [Fragrantica](https://www.fragrantica.com)
- [SOFTonSOFA](https://softonsofa.com/)
- [User10](https://user10.com)
- [Soumettre.fr](https://soumettre.fr/)
- [CodeBrisk](https://codebrisk.com)
- [1Forge](https://1forge.com)
- [TECPRESSO](https://tecpresso.co.jp/)
- [Runtime Converter](http://runtimeconverter.com/)
- [WebL'Agence](https://weblagence.com/)
- [Invoice Ninja](https://www.invoiceninja.com)
- [iMi digital](https://www.imi-digital.de/)
- [Earthlink](https://www.earthlink.ro/)
- [Steadfast Collective](https://steadfastcollective.com/)
- [We Are The Robots Inc.](https://watr.mx/)
- [Understand.io](https://www.understand.io/)
- [Abdel Elrafa](https://abdelelrafa.com)
- [Hyper Host](https://hyper.host)
- [Appoly](https://www.appoly.co.uk)
- [OP.GG](https://op.gg)
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
# LDC WEB
## Installation
```
cp .env.example .env
php artisan key:generate
```
## Front
```
npm install && npm run prod
```
## Dependencies
- Memcached

View file

@ -0,0 +1,117 @@
<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
/**
* Creates a new user
*/
class CreateAdmin extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'user:create';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a backend admin user';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$email = $this->getInput(
'Type the wanted user email',
'email',
'required|ends_with:@ldc.fr|unique:users,email|email:rfc,dns',
'equipe.web@ldc.fr'
);
$firstname = $this->getInput(
'Type the wanted user firstname',
'firstname',
'required|min:5,max:255',
'Saitama'
);
$lastname = $this->getInput(
'Type the wanted user lastname',
'lastname',
'required|min:5,max:255',
'Hagemanto'
);
$phone = $this->getInput(
'Type the wanted user phone',
'phone',
'required|phone:FR|unique:users,phone|min:5,max:255'
);
$password = null;
while (
($password = $this->secret(
(!\is_null($password) ? 'Failed to confirm, ' : '') . 'Type the wanted user password'
)) !== $this->secret('Confirm the password')
) {
continue;
};
$admin = new User([
'firstname' => $firstname,
'lastname' => $lastname,
'email' => $email,
'phone' => $phone,
'password' => $password,
'equipe_web_member' => $this->confirm('Is the user an member of equipe web ?')
]);
$admin->saveOrFail();
$this->info('User created.');
return 0;
}
/**
* Get User Input
*
* @param string $message
* @param string $inputName
* @param string|array $rules
* @param string|null $defaultValue
* @return mixed
*/
private function getInput(string $message, string $inputName, $rules, ?string $defaultValue = null)
{
$out = null;
while (is_null($out)) {
try {
$tmp = $this->ask($message, $defaultValue);
$validator = Validator::make([$inputName => $tmp], [
$inputName => $rules
]);
$validator->validate();
$out = $tmp;
} catch (ValidationException $e) {
$this->error(sprintf(
"'Please provide a valid $inputName %s'",
\implode(',', collect($e->errors())->flatten()->all())
));
continue;
}
}
return $out;
}
}

View file

@ -3,12 +3,13 @@
namespace App\Console\Commands;
use App\Models\DatastorePcc;
use App\Models\DomainNames;
use App\Models\GitRepos;
use App\Models\LDCNetworks;
use App\Models\Projects;
use App\Models\Servers;
use App\Models\DomainName;
use App\Models\GitRepo;
use App\Models\LDCNetwork;
use App\Models\Project;
use App\Models\Server;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Storage;
class ExportDatas extends Command
@ -27,37 +28,34 @@ class ExportDatas extends Command
*/
protected $description = 'Export data in Excel format';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
* @return integer
*/
public function handle()
{
$this->ExportProjects("EDL_WEB.csv");
$this->ExportServers("EDL_Servers.csv");
$this->ExportDatastorePcc("EDL_Datastore_pcc.csv");
$this->ExportDomainNames("EDL_Domain_Names.csv");
$this->ExportLdcNetworks("EDL_LDC_Networks.csv");
$this->ExportGitRepos("EDL_GIT_Repos.csv");
$this->exportProjects("EDL_WEB.csv");
$this->exportServers("EDL_Servers.csv");
$this->exportDatastorePcc("EDL_Datastore_pcc.csv");
$this->exportDomainNames("EDL_Domain_Names.csv");
$this->exportLdcNetworks("EDL_LDC_Networks.csv");
$this->exportGitRepos("EDL_GIT_Repos.csv");
return 0;
}
private function ExportGitRepos($filename)
/**
* Export git repos as filename.csv
*
* @param string $filename
* @return void
*/
private function exportGitRepos(string $filename)
{
$repos = GitRepos::orderBy('name', 'ASC')->get();
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\GitRepo> */
$repos = GitRepo::orderBy('name', 'ASC')->get();
Storage::disk('export')->append($filename, "Nom");
foreach ($repos as $repo) {
$infos = [
@ -68,9 +66,16 @@ class ExportDatas extends Command
}
}
private function ExportLdcNetworks($filename)
/**
* Export ldc networks as filename.csv
*
* @param string $filename
* @return void
*/
private function exportLdcNetworks(string $filename)
{
$networks = LDCNetworks::all();
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\LDCNetwork> */
$networks = LDCNetwork::all();
Storage::disk('export')->append($filename, "CIDR;First IP;Last IP");
foreach ($networks as $network) {
$infos = [
@ -83,10 +88,20 @@ class ExportDatas extends Command
}
}
private function ExportDomainNames($filename)
/**
* Export domain names as filename.csv
*
* @param string $filename
* @return void
*/
private function exportDomainNames(string $filename)
{
$domains = DomainNames::all();
Storage::disk('export')->append($filename, "ASCII;UTF-8;DATE D'EXPIRATION;RENOUVELLEMENT;MARQUE REF.;DNS REDIRIGES;TYPE CERTIFICATS;COMMENTAIRE");
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\DomainName> */
$domains = DomainName::all();
Storage::disk('export')->append(
$filename,
"ASCII;UTF-8;DATE D'EXPIRATION;RENOUVELLEMENT;MARQUE REF.;DNS REDIRIGES;TYPE CERTIFICATS;COMMENTAIRE"
);
foreach ($domains as $domain) {
$infos = [
trim($domain->ascii_name),
@ -103,8 +118,15 @@ class ExportDatas extends Command
}
}
private function ExportDatastorePcc($filename)
/**
* Export data store pcc as filename.csv
*
* @param string $filename
* @return void
*/
private function exportDatastorePcc(string $filename)
{
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\DatastorePcc> */
$datastores = DatastorePcc::all();
Storage::disk('export')->append($filename, "NOM;COMMENTAIRE");
foreach ($datastores as $datastore) {
@ -117,10 +139,20 @@ class ExportDatas extends Command
}
}
private function ExportServers($filename)
/**
* Export servers as filename.csv
*
* @param string $filename
* @return void
*/
private function exportServers(string $filename)
{
$servers = Servers::orderBy('env', 'DESC')->get();
Storage::disk('export')->append($filename, "ENV;NOM;TITRE;FUNCTION;SSH;IP INFRAWEB;VIRTUAL IP;DATASTORE PCC;COMMENTAIRE");
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Server> */
$servers = Server::orderBy('env', 'DESC')->get();
Storage::disk('export')->append(
$filename,
"ENV;NOM;TITRE;FUNCTION;SSH;IP INFRAWEB;VIRTUAL IP;DATASTORE PCC;COMMENTAIRE"
);
foreach ($servers as $server) {
$infos = [
trim($server->env),
@ -138,10 +170,17 @@ class ExportDatas extends Command
}
}
private function ExportProjects($filename)
/**
* Export projects as filename.csv
*
* @param string $filename
* @return void
*/
private function exportProjects(string $filename)
{
$projects = Projects::orderBy('name', 'ASC')->get();
$fields = [
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Project> */
$projects = Project::orderBy('name', 'ASC')->get();
$fields = [
'DEV',
'name',
'dev_haproxy_id',
@ -163,21 +202,34 @@ class ExportDatas extends Command
'dev_whitelist_fw',
];
Storage::disk('export')->append($filename, "ENV;NOM;ID HAPROXY;URL;HTTPS;PHP;SERVEUR WEB;SSH;USER UNIX;PWD UNIX;DOCUMENT ROOT;SERVEUR BDD;SSH;USER DB;PWD DB;HTACCESS USER;HTACCESS PWD;COMMENTAIRE;FLUX EAI;WHITELIST FW");
Storage::disk('export')->append(
$filename,
// phpcs:ignore
"ENV;NOM;ID HAPROXY;URL;HTTPS;PHP;SERVEUR WEB;SSH;USER UNIX;PWD UNIX;DOCUMENT ROOT;SERVEUR BDD;SSH;USER DB;PWD DB;HTACCESS USER;HTACCESS PWD;COMMENTAIRE;FLUX EAI;WHITELIST FW"
);
$this->writeProjectExport($projects, $fields, $filename);
$prod = implode(";", $fields);
$prod = str_replace("dev", "prod", $prod);
$prod = str_replace("DEV", "PROD", $prod);
$prod = str_replace("prod_htaccess_user", "BLANK", $prod);
$prod = str_replace("prod_htaccess_pwd", "BLANK", $prod);
$prod = implode(";", $fields);
$prod = str_replace("dev", "prod", $prod);
$prod = str_replace("DEV", "PROD", $prod);
$prod = str_replace("prod_htaccess_user", "BLANK", $prod);
$prod = str_replace("prod_htaccess_pwd", "BLANK", $prod);
$fields = explode(";", $prod);
$this->writeProjectExport($projects, $fields, $filename);
}
private function writeProjectExport($projects, $fields, $filename)
/**
* Append Project to filename.csv
*
* @param Collection $projects
* @param string[] $fields
* @param string $filename
* @return void
*/
private function writeProjectExport(Collection $projects, array $fields, string $filename)
{
/** @var \Illuminate\Database\Eloquent\Collection<\App\Models\Project> $projects */
foreach ($projects as $project) {
$infos = [];
foreach ($fields as $field) {
@ -187,13 +239,13 @@ class ExportDatas extends Command
$infos[] = $field;
break;
case 'https':
$infos[] = $project->{$field} === 1 ? 'OUI' : 'NON';
$infos[] = $project->{$field} === 1 ? 'OUI' : 'NON';
break;
case 'dev_web_server_id':
case 'dev_db_server_id':
case 'prod_web_server_id':
case 'prod_db_server_id':
$server = Servers::find($project->{$field});
$server = Server::find($project->{$field});
$infos[] = trim($server->name);
$infos[] = trim($server->ssh);
break;
@ -202,9 +254,9 @@ class ExportDatas extends Command
break;
default:
$infos[] = trim($project->{$field});
}
}
}//end switch
}//end foreach
Storage::disk('export')->append($filename, implode(";", $infos));
}
}//end foreach
}
}

View file

@ -7,25 +7,14 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
}
/**
@ -35,7 +24,7 @@ class Kernel extends ConsoleKernel
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
$this->load(__DIR__ . '/Commands');
require base_path('routes/console.php');
}

40
app/Enums/Environment.php Normal file
View file

@ -0,0 +1,40 @@
<?php
namespace App\Enums;
use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* SMTP Types
*
* @method static self DEV()
* @method static self PROD()
*/
final class Environment extends BaseEnumRoutable
{
/**
* Enum values
*
* @return array
*/
protected static function values(): array
{
return [
'DEV' => 0,
'PROD' => 1,
];
}
/**
* Enum labels
*
* @return array
*/
protected static function labels(): array
{
return [
'DEV' => 'Developpement',
'PROD' => 'Production'
];
}
}

49
app/Enums/PhpVersion.php Normal file
View file

@ -0,0 +1,49 @@
<?php
namespace App\Enums;
use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* Servers Different Types
*
* @method static self v5_6()
* @method static self v7_3()
* @method static self v7_4()
* @method static self v8()
* @method static self v8_1()
*/
final class PhpVersion extends BaseEnumRoutable
{
/**
* Enum values
*
* @return array
*/
protected static function values(): array
{
return [
'v5_6' => 0,
'v7_3' => 1,
'v7_4' => 2,
'v8' => 3,
'v8_1' => 4
];
}
/**
* Enum labels
*
* @return array
*/
protected static function labels(): array
{
return [
'v5_6' => 'PHP 5.6',
'v7_3' => 'PHP 7.3',
'v7_4' => 'PHP 7.4',
'v8' => 'PHP 8',
'v8_1' => 'PHP 8.1'
];
}
}

View file

@ -12,8 +12,13 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
* @method static self laravel() Laravel
* @method static self symfony() Symfony
*/
final class ProjectTypes extends BaseEnumRoutable
final class ProjectType extends BaseEnumRoutable
{
/**
* Enum values
*
* @return array
*/
protected static function values(): array
{
return [
@ -24,6 +29,11 @@ final class ProjectTypes extends BaseEnumRoutable
];
}
/**
* Enum labels
*
* @return array
*/
protected static function labels(): array
{
return [

43
app/Enums/ServerType.php Normal file
View file

@ -0,0 +1,43 @@
<?php
namespace App\Enums;
use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* Servers Different Types
*
* @method static self DB()
* @method static self WEB()
* @method static self ELASTIC()
*/
final class ServerType extends BaseEnumRoutable
{
/**
* Enum values
*
* @return array
*/
protected static function values(): array
{
return [
'DB' => 0,
'WEB' => 1,
'ELASTIC' => 2
];
}
/**
* Enum labels
*
* @return array
*/
protected static function labels(): array
{
return [
'DB' => trans('Base de données'),
'WEB' => trans('WEB'),
'ELASTIC' => trans('Eslatic Search')
];
}
}

View file

@ -11,8 +11,13 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
* @method static self mailjet() Mailjet Relay
* @method static self sendinblue() Sendinblue Relay
*/
final class Smtp extends BaseEnumRoutable
final class SmtpEnum extends BaseEnumRoutable
{
/**
* Enum values
*
* @return array
*/
protected static function values(): array
{
return [
@ -22,6 +27,11 @@ final class Smtp extends BaseEnumRoutable
];
}
/**
* Enum labels
*
* @return array
*/
protected static function labels(): array
{
return [

View file

@ -2,55 +2,37 @@
namespace App\Exceptions;
use Throwable;
use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;
use Illuminate\Support\Facades\Mail;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];
protected $dontReport = [];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Report or log an exception.
* Register the exception handling callbacks for the application.
*
* @param \Throwable $exception
* @return void
*
* @throws \Throwable
*/
public function report(Throwable $e)
public function register()
{
parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Exception
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
$this->reportable(function (Throwable $e) {
});
}
}

View file

@ -3,28 +3,19 @@
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Models\LDCNetworks;
use Illuminate\Http\Request;
use App\Http\Resources\Api\LDCNetworkResource;
use App\Models\LDCNetwork;
class LDCNetworksController extends Controller
{
public function index(Request $request) {
$token = $request->token;
if ($token !== 'CE8S52Qq7stf5k8frF4T')
return response('Unauthorized', 401);
$ips = [];
$networks = LDCNetworks::all();
foreach ($networks as $network) {
$infos = explode('.', $network->first_ip);
$min = $infos[3];
$max = explode('.', $network->last_ip)[3];
for ($i = $min; $i <= $max; $i++) {
$ips[] = "$infos[0].$infos[1].$infos[2].$i";
}
}
return response($ips);
/**
* Api LDC Networks
*
* @return \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory
*/
public function index()
{
$networks = LDCNetwork::all();
return \response()->json((new LDCNetworkResource($networks)));
}
}

View file

@ -3,44 +3,24 @@
namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use App\Models\Projects;
use App\Http\Requests\Api\UpdateProjectStatusRequest;
use App\Models\ProjectsStatusChecker;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class StatusCheckerController extends Controller
{
public function index(Request $request) {
$token = $request->token;
$datas = $request->datas;
/**
* Undocumented function
*
* @param \App\Http\Requests\Api\UpdateProjectStatusRequest $request
* @return \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory
*/
public function index(UpdateProjectStatusRequest $request)
{
/** @var \App\Models\ProjectsStatusChecker */
$project_sc = ProjectsStatusChecker::where('project_uuid', '=', $request->uuid)
->firstOrNew();
if ($token !== 'CE8S52Qq7stf5k8frF4T')
return response('Unauthorized', 401);
$oDatas = json_decode($datas);
$app_uuid = $oDatas->uuid;
$sitemap = $oDatas->sitemap;
$robots = $oDatas->robots;
$code = json_encode($oDatas->code);
$logs = $oDatas->logs;
$project_sc = ProjectsStatusChecker::where('project_uuid', '=', $app_uuid)->first();
if (!$project_sc) {
$project = Projects::where('uuid', '=', $app_uuid)->first();
if (!$project)
return response('Unknown', 404);
$project_sc = new ProjectsStatusChecker();
$project_sc->project_uuid = $app_uuid;
}
$project_sc->code = $code;
$project_sc->sitemap = $sitemap;
$project_sc->robots = $robots;
$project_sc->logs = $logs;
$project_sc->updated_at = NOW();
$project_sc->save();
return response('OK');
$project_sc->fill($request->validated());
return $project_sc->save() ? response('OK') : response('KO');
}
}

View file

@ -9,5 +9,7 @@ use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests;
use DispatchesJobs;
use ValidatesRequests;
}

View file

@ -2,79 +2,113 @@
namespace App\Http\Controllers;
use App\Http\Requests\DatastorePccs\StoreDatastorePccRequest;
use App\Http\Requests\DatastorePccs\UpdateDatastorePccRequest;
use App\Http\Requests\ValidateOtpRequest;
use App\Models\DatastorePcc;
use App\Models\Servers;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use lfkeitel\phptotp\Base32;
use lfkeitel\phptotp\Totp;
use App\Models\Server;
class DatastorePCCController extends Controller
{
public function index(Request $request) {
$dpccs = DatastorePcc::all();
return view('dpccs.index', ['dpccs' => $dpccs]);
}
public function add(Request $request) {
return view('dpccs.add');
}
public function edit(Request $request) {
$dpcc_id = $request->id;
$dpcc = DatastorePcc::findOrFail($dpcc_id);
return view('dpccs.edit', ['dpcc' => $dpcc]);
}
public function update(Request $request) {
$dpcc_id = $request->id;
$dpcc = DatastorePcc::findOrFail($dpcc_id);
$this->makeChanges($request, $dpcc);
return redirect()->route('dpccs.edit', ['id' => $dpcc->id])->with('status', 'Sauvegardé !');
}
public function store(Request $request) {
$dpcc = new DatastorePcc();
$this->makeChanges($request, $dpcc);
return redirect()->route('dpccs.edit', ['id' => $dpcc->id])->with('status', 'Sauvegardé !');
}
public function delete(Request $request) {
$dpcc_id = $request->id;
$dpcc = DatastorePcc::findOrFail($dpcc_id);
$isUsed = Servers::where('datastore_pcc_id', '=', $dpcc->id)->get();
if ($isUsed->count() === 0)
$isUsed = false;
return view('dpccs.delete', ['dpcc' => $dpcc, 'isUsed' => $isUsed]);
}
public function forceDelete(Request $request)
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$dpcc_id = $request->id;
$otp = $request->otp;
$lastCode = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret), Carbon::now()->subSeconds(30)->timestamp);
$code = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret));
if ($otp === $code || $otp === $lastCode) {
$dpcc = DatastorePcc::findOrFail($dpcc_id);
$dpcc->delete();
return redirect()->route('dpccs.index')->with('status', 'Datastore PCC supprimé !');
}else{
return redirect()->route('dpccs.edit', ['id' => $dpcc_id])->with('error', 'Code de vérification invalide.');
}
$datastore_pccs = DatastorePcc::all();
return view('datastore_pccs.index', ['datastore_pccs' => $datastore_pccs]);
}
private function makeChanges($request, $dpcc) {
$title = $request->title;
$comment = $request->comment;
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('datastore_pccs.create');
}
$dpcc->title = $title;
$dpcc->comment = $comment;
$dpcc->save();
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\DatastorePccs\StoreDatastorePccRequest $request
* @return \Illuminate\Http\Response
*/
public function store(StoreDatastorePccRequest $request)
{
$datastore_pcc = new DatastorePcc();
$datastore_pcc->fill($request->validated());
if ($datastore_pcc->saveOrFail()) {
return redirect()->route('datastore_pccs.edit', compact('datastore_pcc'))
->with('success', trans('Datastore Pcc créé créé.'));
}
return \back();
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\DatastorePcc $datastore_pcc
* @return \Illuminate\Http\Response
*/
public function edit(DatastorePcc $datastore_pcc)
{
return view('datastore_pccs.edit', ['datastore_pcc' => $datastore_pcc]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\DatastorePccs\UpdateDatastorePccRequest $request
* @param \App\Models\DatastorePcc $datastore_pcc
* @return \Illuminate\Http\Response
*/
public function update(UpdateDatastorePccRequest $request, DatastorePcc $datastore_pcc)
{
$datastore_pcc->fill($request->validated());
if ($datastore_pcc->saveOrFail()) {
return redirect()->route('datastore_pccs.edit', compact('datastore_pcc'))
->with('success', trans('Datastore Pcc mis à jour.'));
}
return \back();
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\DatastorePcc $datastore_pcc
* @return \Illuminate\Http\Response
*/
public function destroy(DatastorePcc $datastore_pcc)
{
$isUsed = Server::where('datastore_pcc_id', '=', $datastore_pcc->id)->get();
if ($isUsed->count() === 0) {
$isUsed = false;
}
return view('datastore_pccs.delete', compact('datastore_pcc', 'isUsed'));
}
/**
* Remove the specified resource from storage.
*
* @param \App\Http\Requests\ValidateOtpRequest $request
* @param \App\Models\DatastorePcc $datastore_pcc
* @return \Illuminate\Http\Response
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
*/
public function destroySubmit(ValidateOtpRequest $request, DatastorePcc $datastore_pcc)
{
// phpcs:enable
if ($datastore_pcc->deleteOrFail()) {
return redirect()->route('datastore_pccs.index')
->with('warning', 'Datastore Pcc supprimée !');
}
return back();
}
}

View file

@ -0,0 +1,115 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\DomainNames\StoreDomainNameRequest;
use App\Http\Requests\DomainNames\UpdateDomainNameRequest;
use App\Http\Requests\ValidateOtpRequest;
use App\Models\DomainName;
use App\Models\EmailAddress;
class DomainNameController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$domain_names = DomainName::all();
return view('domain-names.index', compact('domain_names'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('domain-names.create');
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\DomainNames\StoreDomainNameRequest $request
* @return \Illuminate\Http\Response
*/
public function store(StoreDomainNameRequest $request)
{
$domain_name = new DomainName();
$domain_name->fill($request->validated());
if ($domain_name->saveOrFail()) {
return redirect()->route('domain-names.edit', compact('domain_name'))
->with('success', trans('Nom de domaine créé créé.'));
}
return \back();
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\DomainName $domain_name
* @return \Illuminate\Http\Response
*/
public function edit(DomainName $domain_name)
{
return view('domain-names.edit', ['domain_name' => $domain_name]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\DomainNames\UpdateDomainNameRequest $request
* @param \App\Models\DomainName $domain_name
* @return \Illuminate\Http\Response
*/
public function update(UpdateDomainNameRequest $request, DomainName $domain_name)
{
$domain_name->fill($request->validated());
if ($domain_name->saveOrFail()) {
return redirect()->route('domain-names.edit', compact('domain_name'))
->with('success', trans('Nom de domaine mis à jour.'));
}
return \back();
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\DomainName $domain_name
* @return \Illuminate\Http\Response
*/
public function destroy(DomainName $domain_name)
{
$emails = EmailAddress::whereHas('domainName', function ($q) use ($domain_name) {
$q->whereId($domain_name->id);
})->get();
return view('domain-names.delete', [
'domain_name' => $domain_name,
'isUsed' => $emails->count() ? $emails : false
]);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Http\Requests\ValidateOtpRequest $request
* @param \App\Models\DomainName $domain_name
* @return \Illuminate\Http\Response
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
*/
public function destroySubmit(ValidateOtpRequest $request, DomainName $domain_name)
{
// phpcs:enable
if ($domain_name->deleteOrFail()) {
return redirect()->route('domain-names.index')
->with('warning', 'Nom de domaine supprimée !');
}
return back();
}
}

View file

@ -1,98 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\DomainNames;
use App\Models\EmailAddresses;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use lfkeitel\phptotp\Base32;
use lfkeitel\phptotp\Totp;
class DomainNamesController extends Controller
{
public function index(Request $request)
{
$dms = DomainNames::all();
return view('domain-names.index', ['dms' => $dms]);
}
public function add(Request $request)
{
return view('domain-names.add');
}
public function edit(Request $request)
{
$dm_id = $request->id;
$dm = DomainNames::findOrFail($dm_id);
return view('domain-names.edit', ['dm' => $dm]);
}
public function update(Request $request)
{
$dm_id = $request->id;
$dm = DomainNames::findOrFail($dm_id);
$this->makeChanges($request, $dm);
return redirect()->route('domain-names.edit', ['id' => $dm->id])->with('status', 'Sauvegardé !');
}
public function store(Request $request)
{
$dm = new DomainNames();
$this->makeChanges($request, $dm);
return redirect()->route('domain-names.edit', ['id' => $dm->id])->with('status', 'Sauvegardé !');
}
public function delete(Request $request)
{
$dm_id = $request->id;
$dm = DomainNames::findOrFail($dm_id);
$isUsed = EmailAddresses::where('domain_name_id', '=', $dm->id)->get();
if ($isUsed->count() === 0)
$isUsed = false;
return view('domain-names.delete', ['dm' => $dm, 'isUsed' => $isUsed]);
}
public function forceDelete(Request $request)
{
$dm_id = $request->id;
$otp = $request->otp;
$lastCode = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret), Carbon::now()->subSeconds(30)->timestamp);
$code = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret));
if ($otp === $code || $otp === $lastCode) {
$dm = DomainNames::findOrFail($dm_id);
$dm->delete();
return redirect()->route('domain-names.index')->with('status', 'Nom de domaine supprimé !');
} else {
return redirect()->route('domain-names.edit', ['id' => $dm_id])->with('error', 'Code de vérification invalide.');
}
}
private function makeChanges($request, $dm)
{
$ascii_name = $request->ascii_name;
$utf8_name = $request->utf8_name;
$exp_date = $request->expiration_date;
$renew = $request->renew;
$related_brand = $request->related_brand;
$redirect_dns = $request->redirect_dns;
$certificats = $request->certificats;
$comment = $request->comment;
$dm->ascii_name = $ascii_name;
$dm->utf8_name = $utf8_name;
$dm->expiration_date = $exp_date;
$dm->renew = $renew;
$dm->related_brand = $related_brand;
$dm->redirect_dns = $redirect_dns;
$dm->certificats = $certificats;
$dm->comment = $comment;
$dm->save();
}
}

View file

@ -0,0 +1,114 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\EmailAddresses\StoreEmailAddressRequest;
use App\Http\Requests\EmailAddresses\UpdateEmailAddressRequest;
use App\Http\Requests\ValidateOtpRequest;
use App\Models\DomainName;
use App\Models\EmailAddress;
class EmailAddressController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$email_addresses = EmailAddress::all();
return view('email-addresses.index', compact('email_addresses'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$domain_names = DomainName::orderBy('utf8_name')->get();
return view('email-addresses.create', compact('domain_names'));
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\EmailAddresses\StoreEmailAddressRequest $request
* @return \Illuminate\Http\Response
*/
public function store(StoreEmailAddressRequest $request)
{
$email_address = new EmailAddress();
$email_address->fill($request->validated());
if ($email_address->saveOrFail()) {
return redirect()->route('email-addresses.edit', compact('email_address'))
->with('success', trans('Adresse email créé créé.'));
}
return \back();
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\EmailAddress $email_address
* @return \Illuminate\Http\Response
*/
public function edit(EmailAddress $email_address)
{
$domain_names = DomainName::orderBy('utf8_name')->get();
return view('email-addresses.edit', [
'email_address' => $email_address,
'domain_names' => $domain_names
]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\EmailAddresses\UpdateEmailAddressRequest $request
* @param \App\Models\EmailAddress $email_address
* @return \Illuminate\Http\Response
*/
public function update(UpdateEmailAddressRequest $request, EmailAddress $email_address)
{
$email_address->fill($request->validated());
if ($email_address->saveOrFail()) {
return redirect()->route('email-addresses.edit', compact('email_address'))
->with('success', trans('Adresse email mis à jour.'));
}
return \back();
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\EmailAddress $email_address
* @return \Illuminate\Http\Response
*/
public function destroy(EmailAddress $email_address)
{
return view('email-addresses.delete', ['email_address' => $email_address]);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Http\Requests\ValidateOtpRequest $request
* @param \App\Models\EmailAddress $email_address
* @return \Illuminate\Http\Response
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
*/
public function destroySubmit(ValidateOtpRequest $request, EmailAddress $email_address)
{
// phpcs:enable
if ($email_address->deleteOrFail()) {
return redirect()->route('email-addresses.index')
->with('warning', 'Adresse email supprimée !');
}
return back();
}
}

View file

@ -1,78 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\DomainNames;
use App\Models\EmailAddresses;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use lfkeitel\phptotp\Base32;
use lfkeitel\phptotp\Totp;
class EmailAddressesController extends Controller
{
public function index(Request $request) {
$emails = EmailAddresses::all();
return view('email-addresses.index', ['emails' => $emails]);
}
public function add(Request $request) {
$dms = DomainNames::orderBy('utf8_name')->get();
return view('email-addresses.add', ['dms' => $dms]);
}
public function edit(Request $request) {
$email_id = $request->id;
$email = EmailAddresses::findOrFail($email_id);
$dms = DomainNames::orderBy('utf8_name')->get();
return view('email-addresses.edit', ['email' => $email, 'dms' => $dms]);
}
public function update(Request $request) {
$email_id = $request->id;
$email = EmailAddresses::findOrFail($email_id);
$this->makeChanges($request, $email);
return redirect()->route('email-addresses.edit', ['id' => $email->id])->with('status', 'Sauvegardée !');
}
public function store(Request $request) {
$email = new EmailAddresses();
$this->makeChanges($request, $email);
return redirect()->route('email-addresses.edit', ['id' => $email->id])->with('status', 'Sauvegardée !');
}
public function delete(Request $request) {
$email_id = $request->id;
$email = EmailAddresses::findOrFail($email_id);
return view('email-addresses.delete', ['email' => $email]);
}
public function forceDelete(Request $request)
{
$email_id = $request->id;
$otp = $request->otp;
$lastCode = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret), Carbon::now()->subSeconds(30)->timestamp);
$code = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret));
if ($otp === $code || $otp === $lastCode) {
$email = EmailAddresses::findOrFail($email_id);
$email->delete();
return redirect()->route('email-addresses.index')->with('status', 'Adresse email supprimée !');
}else{
return redirect()->route('email-addresses.edit', ['id' => $email_id])->with('error', 'Code de vérification invalide.');
}
}
private function makeChanges($request, $email) {
$account = $request->account;
$password = $request->password;
$domain_name_id = $request->d_n_id;
$email->account = $account;
$email->password = $password;
$email->domain_name_id = $domain_name_id;
$email->save();
}
}

View file

@ -0,0 +1,92 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\GitRepos\StoreGitRepoRequest;
use App\Http\Requests\GitRepos\UpdateGitRepoRequest;
use App\Models\GitRepo;
class GitRepoController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$git_repos = GitRepo::all();
return view('git-repos.index', compact('git_repos'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('git-repos.create');
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\GitRepos\StoreGitRepoRequest $request
* @return \Illuminate\Http\Response
*/
public function store(StoreGitRepoRequest $request)
{
$git_repo = new GitRepo();
$git_repo->fill($request->validated());
if ($git_repo->saveOrFail()) {
return redirect()->route('git-repos.edit', compact('git_repo'))
->with('success', trans('Dépôt Git créé.'));
}
return \back();
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\GitRepo $git_repo
* @return \Illuminate\Http\Response
*/
public function edit(GitRepo $git_repo)
{
return view('git-repos.edit', ['git_repo' => $git_repo]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\GitRepos\UpdateGitRepoRequest $request
* @param \App\Models\GitRepo $git_repo
* @return \Illuminate\Http\Response
*/
public function update(UpdateGitRepoRequest $request, GitRepo $git_repo)
{
$git_repo->fill($request->validated());
if ($git_repo->saveOrFail()) {
return redirect()->route('git-repos.edit', compact('git_repo'))
->with('success', trans('Dépôt Git mis à jour.'));
}
return \back();
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\GitRepo $git_repo
* @return \Illuminate\Http\Response
*/
public function destroy(GitRepo $git_repo)
{
if ($git_repo->deleteOrFail()) {
return redirect()->route('git-repos.index')
->with('warning', trans('Dépôt Git supprimé.'));
}
return \back();
}
}

View file

@ -1,97 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\GitReposStoreRequest;
use App\Http\Requests\GitReposUpdateRequest;
use App\Models\GitRepos;
class GitReposController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$repos = GitRepos::all();
return view('git-repos.index', compact('repos'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('git-repos.create');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\GitReposStoreRequest $request
* @return \Illuminate\Http\Response
*/
public function store(GitReposStoreRequest $request)
{
$datas = $request->validated();
$git_repo = new GitRepos();
$git_repo->fill($datas);
$git_repo->save();
return redirect()->route('git-repos.edit', ['git_repo' => $git_repo])->with('status', __('Dépôt Git créé.'));
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
abort('404');
}
/**
* Show the form for editing the specified resource.
*
* @param GitRepos $git_repo
* @return \Illuminate\Http\Response
*/
public function edit(GitRepos $git_repo)
{
return view('git-repos.edit', compact('git_repo'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\GitReposUpdateRequest $request
* @param GitRepos $git_repo
* @return \Illuminate\Http\Response
*/
public function update(GitReposUpdateRequest $request, GitRepos $git_repo)
{
$datas = $request->validated();
$git_repo->fill($datas);
$git_repo->save();
return redirect()->route('git-repos.edit', ['git_repo' => $git_repo])->with('status', __('Dépôt Git mis à jour.'));
}
/**
* Remove the specified resource from storage.
*
* @param GitRepos $git_repo
* @return \Illuminate\Http\Response
*/
public function destroy(GitRepos $git_repo)
{
$git_repo->delete();
return redirect()->route('git-repos.index')->with('status', __('Dépôt Git supprimé.'));
}
}

View file

@ -2,9 +2,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use lfkeitel\phptotp\{Base32,Totp};
use SimpleSoftwareIO\QrCode\Facades\QrCode;
class HomeController extends Controller
@ -14,19 +12,26 @@ class HomeController extends Controller
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(Request $request)
public function index()
{
//$secret = Totp::GenerateSecret(16);
# Display new key to user so they can enter it in Google Authenticator or Authy
//echo strtoupper(Base32::encode($secret));exit;
// $secret = Totp::GenerateSecret(16);
// Display new key to user so they can enter it in Google Authenticator or Authy
// echo strtoupper(Base32::encode($secret));exit;
// otpauth://totp/LDC%20WEB:mail@ldc.fr?secret=secret&issuer=LDC%20WEB
return view('home');
}
/**
* Generate QR code
*
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
*/
public function qr()
{
$user = Auth::user();
$qrcode = QrCode::size(200)->generate("otpauth://totp/LDC%20WEB:".$user->email."?secret=".$user->totp_secret."&issuer=LDC%20WEB");
$user = Auth::user();
$qrcode = QrCode::size(200)->generate(
"otpauth://totp/LDC%20WEB:$user->email?secret=$user->totp_secret&issuer=LDC%20WEB"
);
return view("qrcode", compact('qrcode'));
}
}

View file

@ -2,82 +2,107 @@
namespace App\Http\Controllers;
use App\Models\LDCNetworks;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use lfkeitel\phptotp\Base32;
use lfkeitel\phptotp\Totp;
use App\Http\Requests\LDCNetworks\StoreLDCNetwork;
use App\Http\Requests\LDCNetworks\UpdateLDCNetwork;
use App\Http\Requests\ValidateOtpRequest;
use App\Models\LDCNetwork;
class LDCNetworkController extends Controller
{
public function index(Request $request) {
$networks = LDCNetworks::all();
return view('ldc-networks.index', ['networks' => $networks]);
}
public function add(Request $request) {
return view('ldc-networks.add');
}
public function edit(Request $request) {
$network_id = $request->id;
$network = LDCNetworks::findOrFail($network_id);
return view('ldc-networks.edit', ['network' => $network]);
}
public function update(Request $request) {
$network_id = $request->id;
$network = LDCNetworks::findOrFail($network_id);
$this->makeChanges($request, $network);
return redirect()->route('ldc-networks.edit', ['id' => $network->id])->with('status', 'Sauvegardée !');
}
public function store(Request $request) {
$network = new LDCNetworks();
$this->makeChanges($request, $network);
return redirect()->route('ldc-networks.edit', ['id' => $network->id])->with('status', 'Sauvegardée !');
}
public function delete(Request $request) {
$network_id = $request->id;
$network = LDCNetworks::findOrFail($network_id);
return view('ldc-networks.delete', ['network' => $network]);
}
public function forceDelete(Request $request)
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$network_id = $request->id;
$otp = $request->otp;
$ldc_networks = LDCNetwork::all();
return view('ldc-networks.index', compact('ldc_networks'));
}
$lastCode = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret), Carbon::now()->subSeconds(30)->timestamp);
$code = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret));
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('ldc-networks.create');
}
if ($otp === $code || $otp === $lastCode) {
$network = LDCNetworks::findOrFail($network_id);
$network->delete();
return redirect()->route('ldc-networks.index')->with('status', 'IP supprimée !');
}else{
return redirect()->route('ldc-networks.edit', ['id' => $network_id])->with('error', 'Code de vérification invalide.');
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\LDCNetworks\StoreLDCNetwork $request
* @return \Illuminate\Http\Response
*/
public function store(StoreLDCNetwork $request)
{
$ldc_network = new LDCNetwork();
$ldc_network->fill($request->validated());
if ($ldc_network->saveOrFail()) {
return redirect()->route('ldc-networks.edit', compact('ldc_network'))
->with('success', trans('LDC Network créé.'));
}
return \back();
}
private function makeChanges($request, $network) {
$cidr = $request->cidr;
$range = $this->cidrToRange($cidr);
$network->cidr = $cidr;
$network->first_ip = $range[0];
$network->last_ip = $range[1];
$network->save();
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\LDCNetwork $ldc_network
* @return \Illuminate\Http\Response
*/
public function edit(LDCNetwork $ldc_network)
{
return view('ldc-networks.edit', ['ldc_network' => $ldc_network]);
}
private function cidrToRange($cidr) {
$range = array();
$cidr = explode('/', $cidr);
$range[0] = long2ip((ip2long($cidr[0])) & ((-1 << (32 - (int)$cidr[1]))));
$range[1] = long2ip((ip2long($range[0])) + pow(2, (32 - (int)$cidr[1])) - 1);
return $range;
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\LDCNetworks\UpdateLDCNetwork $request
* @param \App\Models\LDCNetwork $ldc_network
* @return \Illuminate\Http\Response
*/
public function update(UpdateLDCNetwork $request, LDCNetwork $ldc_network)
{
$ldc_network->fill($request->validated());
if ($ldc_network->saveOrFail()) {
return redirect()->route('ldc-networks.edit', compact('ldc_network'))
->with('success', trans('LDC Network mis à jour.'));
}
return \back();
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\LDCNetwork $ldc_network
* @return \Illuminate\Http\Response
*/
public function destroy(LDCNetwork $ldc_network)
{
return view('ldc-networks.delete', ['ldc_network' => $ldc_network]);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Http\Requests\ValidateOtpRequest $request
* @param \App\Models\LDCNetwork $ldc_network
* @return \Illuminate\Http\Response
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
*/
public function destroySubmit(ValidateOtpRequest $request, LDCNetwork $ldc_network)
{
// phpcs:enable
if ($ldc_network->deleteOrFail()) {
return redirect()->route('ldc-networks.index')
->with('warning', 'LDC Network supprimée !');
}
return back();
}
}

View file

@ -2,63 +2,79 @@
namespace App\Http\Controllers;
use App\Http\Requests\ValidateOtpRequest;
use App\Providers\RouteServiceProvider;
use Carbon\Carbon;
use Illuminate\Http\Request;
use lfkeitel\phptotp\{Base32,Totp};
use GuzzleHttp\Exception\RequestException;
use lfkeitel\phptotp\Base32;
use lfkeitel\phptotp\Totp;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
class OTPController extends Controller
{
public function verify(Request $request) {
/**
* Show verifiy otp page
*
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
*/
public function verify()
{
$user = session()->get('tmpUserOTP');
if (!$user)
if (!$user) {
return redirect(RouteServiceProvider::HOME);
}
return view('auth.verify');
}
public function check(Request $request) {
$otp = $request->otp;
$user = session()->get('tmpUserOTP');
if (!$user)
return redirect(RouteServiceProvider::HOME);
$lastCode = (new Totp())->GenerateToken(Base32::decode($user->totp_secret), Carbon::now()->subSeconds(30)->timestamp);
$code = (new Totp())->GenerateToken(Base32::decode($user->totp_secret));
if ($otp === $code || $otp === $lastCode) {
Auth::login($user);
return redirect(RouteServiceProvider::HOME);
} else {
Auth::logout();
Session::flush();
return redirect()->route('verification_failed');
}
/**
* Check OPT request
*
* @param ValidateOtpRequest $request
* @return \Illuminate\Http\RedirectResponse
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function check(ValidateOtpRequest $request)
{
//phpcs:enable
Auth::login(session()->get('tmpUserOTP'));
return \response()->redirectTo(RouteServiceProvider::HOME);
}
public function sendOTPBySMS()
/**
* Send OPT by SMS
*
* @return \Illuminate\Http\RedirectResponse
*/
public function sendOtpBySms()
{
$user = session()->get('tmpUserOTP');
if (!$user)
if (!$user) {
return back()->withErrors('User not found.');
}
if (is_null($user->phone))
if (is_null($user->phone)) {
return back()->withErrors('Phone number missing.');
}
$otp = (new Totp())->GenerateToken(Base32::decode($user->totp_secret));
if (!$otp) {
return back()->withErrors('Erreur lors de la génération du code OTP');
}
/** @var \App\Lib\LDC\MailjetSms */
$mj = app('MailjetSms');
$mjResponse = $mj->send("OTP : " . implode(' ', str_split($otp)), $user->phone);
/** @var \GuzzleHttp\Psr7\Response $mjResponse */
$responseStatus = $mjResponse->getStatusCode(); //"200"
$responsePhrase = $mjResponse->getReasonPhrase(); //"OK"
if ($responseStatus == 200) {
$mjSmsResponse = $mjResponse->getBody()->getContents();
return back()->with('success', "SMS envoyé.");
try {
$mjResponse = $mj->send("OTP : " . implode(' ', str_split($otp)), $user->phone);
/** @var \GuzzleHttp\Psr7\Response $mjResponse */
$responseStatus = $mjResponse->getStatusCode();
if ($responseStatus == 200) {
return back()->with('success', 'SMS envoyé.');
}
return back()->withErrors('SMS not sent.');
} catch (RequestException $e) {
report($e);
return back()->withErrors('Erreur lors de l\'envoi du SMS');
}
return back()->withErrors('SMS not sent.');
}
}

View file

@ -0,0 +1,151 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\Projects\StoreProjectRequest;
use App\Http\Requests\Projects\UpdateProjectRequest;
use App\Http\Requests\ValidateOtpRequest;
use App\Models\Project;
use App\Models\Server;
use Ramsey\Uuid\Uuid;
class ProjectController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$projects = Project::orderBy('name')->get();
return view('projects.index', ['projects' => $projects]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$dev_db_server = Server::where([
['env', 'DEV'],
['type', 'DB']
])->get();
$dev_web_server = Server::where([
['env', 'DEV'],
['type', 'WEB']
])->get();
$prod_db_server = Server::where([
['env', 'PROD'],
['type', 'DB']
])->get();
$prod_web_server = Server::where([
['env', 'PROD'],
['type', 'WEB']
])->get();
return view('projects.create', \compact(
'dev_db_server',
'dev_web_server',
'prod_db_server',
'prod_web_server'
));
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\Projects\StoreProjectRequest $request
* @return \Illuminate\Http\Response
*/
public function store(StoreProjectRequest $request)
{
$project = new Project();
$project->uuid = Uuid::uuid4();
$this->makeChanges($request, $project);
return redirect()->route('projects.edit', ['uuid' => $project->uuid])->with('status', 'Sauvegardé !');
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Project $project
* @return \Illuminate\Http\Response
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
*/
public function edit(Project $project)
{
// phpcs:enable
$dev_db_server = Server::where([
['env', 'DEV'],
['type', 'DB']
])->get();
$dev_web_server = Server::where([
['env', 'DEV'],
['type', 'WEB']
])->get();
$prod_db_server = Server::where([
['env', 'PROD'],
['type', 'DB']
])->get();
$prod_web_server = Server::where([
['env', 'PROD'],
['type', 'WEB']
])->get();
return view('projects.edit', \compact(
'project',
'dev_db_server',
'dev_web_server',
'prod_db_server',
'prod_web_server'
));
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\Projects\UpdateProjectRequest $request
* @param \App\Models\Project $project
* @return \Illuminate\Http\Response
*/
public function update(UpdateProjectRequest $request, Project $project)
{
$project->fill($request->validated());
if ($project->saveOrFail()) {
return redirect()->route('projects.edit', compact('project'))
->with('success', trans('Projet mis à jour.'));
}
return \back();
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Project $project
* @return \Illuminate\Http\Response
*/
public function destroy(Project $project)
{
return view('projects.delete', ['project' => $project]);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Http\Requests\ValidateOtpRequest $request
* @param \App\Models\Project $project
* @return \Illuminate\Http\Response
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
*/
public function destroySubmit(ValidateOtpRequest $request, Project $project)
{
// phpcs:enable
if ($project->deleteOrFail()) {
return redirect()->route('domain-names.index')
->with('warning', 'Nom de domaine supprimée !');
}
return back();
}
}

View file

@ -1,223 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\Projects\StoreProjects;
use App\Http\Requests\Projects\UpdateProjects;
use App\Models\Projects;
use App\Models\Servers;
use App\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use lfkeitel\phptotp\Base32;
use lfkeitel\phptotp\Totp;
use Ramsey\Uuid\Uuid;
class ProjectsController extends Controller
{
public function index(Request $request)
{
$projects = Projects::orderBy('name')->get();
return view('projects.index', ['projects' => $projects]);
}
public function WpAutoLogin(Request $request)
{
$url = $request->url;
$login = $request->login;
$pwd = $request->pwd;
return view('projects.wp-auto-login', ['url' => $url, 'login' => $login, 'pwd' => $pwd]);
}
public function add(Request $request)
{
$dev_db_server = Servers::where([
['env', 'DEV'],
['type', 'DB']
])->get();
$dev_web_server = Servers::where([
['env', 'DEV'],
['type', 'WEB']
])->get();
$prod_db_server = Servers::where([
['env', 'PROD'],
['type', 'DB']
])->get();
$prod_web_server = Servers::where([
['env', 'PROD'],
['type', 'WEB']
])->get();
return view('projects.add', ['dev_db_server' => $dev_db_server, 'dev_web_server' => $dev_web_server, 'prod_db_server' => $prod_db_server, 'prod_web_server' => $prod_web_server]);
}
public function edit(Request $request)
{
$uuid = $request->uuid;
$project = Projects::where('uuid', '=', $uuid)->first();
if (!$project)
abort(404);
$dev_db_server = Servers::where([
['env', 'DEV'],
['type', 'DB']
])->get();
$dev_web_server = Servers::where([
['env', 'DEV'],
['type', 'WEB']
])->get();
$prod_db_server = Servers::where([
['env', 'PROD'],
['type', 'DB']
])->get();
$prod_web_server = Servers::where([
['env', 'PROD'],
['type', 'WEB']
])->get();
return view('projects.edit', ['project' => $project, 'dev_db_server' => $dev_db_server, 'dev_web_server' => $dev_web_server, 'prod_db_server' => $prod_db_server, 'prod_web_server' => $prod_web_server]);
}
public function update(UpdateProjects $request)
{
$uuid = $request->uuid;
$project = Projects::where('uuid', '=', $uuid)->first();
if (!$project)
abort(404);
$this->makeChanges($request, $project);
return redirect()->route('projects.edit', ['uuid' => $project->uuid])->with('status', 'Sauvegardé !');
}
public function store(StoreProjects $request)
{
$project = new Projects();
$project->uuid = Uuid::uuid4();
$this->makeChanges($request, $project);
return redirect()->route('projects.edit', ['uuid' => $project->uuid])->with('status', 'Sauvegardé !');
}
public function delete(Request $request)
{
$uuid = $request->uuid;
$project = Projects::where('uuid', '=', $uuid)->first();
if (!$project)
abort(404);
return view('projects.delete', ['project' => $project]);
}
public function forceDelete(Request $request)
{
$uuid = $request->uuid;
$otp = $request->otp;
$lastCode = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret), Carbon::now()->subSeconds(30)->timestamp);
$code = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret));
if ($otp === $code || $otp === $lastCode) {
$project = Projects::where('uuid', '=', $uuid)->first();
if (!$project)
abort(404);
$project->delete();
return redirect()->route('projects.index')->with('status', 'Projet supprimé !');
} else {
return redirect()->route('projects.edit', ['uuid' => $uuid])->with('error', 'Code de vérification invalide.');
}
}
private function makeChanges(Request $request, $project)
{
$name = $request->name;
$display_name = $request->display_name;
$php = $request->php;
$type = $request->type;
$https = $request->https;
$prod_haproxy_id = $request->prod_haproxy_id;
$dev_haproxy_id = $request->dev_haproxy_id;
$prod_url = $request->prod_url;
$dev_url = $request->dev_url;
$prod_document_root = $request->prod_document_root;
$dev_document_root = $request->dev_document_root;
$prod_unix_user = $request->prod_unix_user;
$dev_unix_user = $request->dev_unix_user;
$prod_unix_pwd = $request->prod_unix_pwd;
$dev_unix_pwd = $request->dev_unix_pwd;
$prod_db_user = $request->prod_db_user;
$dev_db_user = $request->dev_db_user;
$prod_db_pwd = $request->prod_db_pwd;
$dev_db_pwd = $request->dev_db_pwd;
$prod_db_schema = $request->prod_db_schema;
$dev_db_schema = $request->dev_db_schema;
$prod_db_server_id = $request->prod_db_server_id;
$dev_db_server_id = $request->dev_db_server_id;
$prod_web_server_id = $request->prod_web_server_id;
$dev_web_server_id = $request->dev_web_server_id;
$prod_comment = $request->prod_comment;
$dev_comment = $request->dev_comment;
$prod_eai = $request->prod_eai;
$dev_eai = $request->dev_eai;
$prod_whitelist_fw = $request->prod_whitelist_fw;
$dev_whitelist_fw = $request->dev_whitelist_fw;
$dev_htaccess_user = $request->dev_htaccess_user;
$dev_htaccess_pwd = $request->dev_htaccess_pwd;
$prod_ga_id = $request->prod_ga_id;
$prod_laravel_app_key = $request->prod_laravel_app_key;
$dev_laravel_app_key = $request->dev_laravel_app_key;
$prod_smtp_config = $request->prod_smtp_config;
$prod_smtp_key = $request->prod_smtp_key;
if (Auth::user()->role === 1) {
$prod_login = $request->prod_login;
$dev_login = $request->dev_login;
$prod_bo_url = $request->prod_bo_url;
$dev_bo_url = $request->dev_bo_url;
}
$project->name = $name;
$project->display_name = $display_name;
$project->php = $php;
$project->type = $type;
$project->https = $https;
$project->prod_haproxy_id = $prod_haproxy_id;
$project->dev_haproxy_id = $dev_haproxy_id;
$project->prod_url = $prod_url;
$project->dev_url = $dev_url;
$project->prod_document_root = $prod_document_root;
$project->dev_document_root = $dev_document_root;
$project->prod_unix_user = $prod_unix_user;
$project->dev_unix_user = $dev_unix_user;
$project->prod_unix_pwd = $prod_unix_pwd;
$project->dev_unix_pwd = $dev_unix_pwd;
$project->prod_db_user = $prod_db_user;
$project->dev_db_user = $dev_db_user;
$project->prod_db_pwd = $prod_db_pwd;
$project->dev_db_pwd = $dev_db_pwd;
$project->prod_db_schema = $prod_db_schema;
$project->dev_db_schema = $dev_db_schema;
$project->prod_db_server_id = $prod_db_server_id;
$project->dev_db_server_id = $dev_db_server_id;
$project->prod_web_server_id = $prod_web_server_id;
$project->dev_web_server_id = $dev_web_server_id;
$project->prod_comment = $prod_comment;
$project->dev_comment = $dev_comment;
$project->prod_eai = $prod_eai;
$project->dev_eai = $dev_eai;
$project->prod_whitelist_fw = $prod_whitelist_fw;
$project->dev_whitelist_fw = $dev_whitelist_fw;
$project->dev_htaccess_user = $dev_htaccess_user;
$project->dev_htaccess_pwd = $dev_htaccess_pwd;
$project->prod_ga_id = $prod_ga_id;
$project->prod_laravel_app_key = $prod_laravel_app_key;
$project->dev_laravel_app_key = $dev_laravel_app_key;
$project->prod_smtp_config = $prod_smtp_config;
$project->prod_smtp_key = $prod_smtp_key;
if (Auth::user()->role === 1) {
$project->prod_login = $prod_login;
$project->dev_login = $dev_login;
$project->prod_bo_url = $prod_bo_url;
$project->dev_bo_url = $dev_bo_url;
}
$project->save();
}
}

View file

@ -0,0 +1,124 @@
<?php
namespace App\Http\Controllers;
use App\Http\Requests\Servers\StoreServerRequest;
use App\Http\Requests\Servers\UpdateServerRequest;
use App\Http\Requests\ValidateOtpRequest;
use App\Models\DatastorePcc;
use App\Models\Project;
use App\Models\Server;
class ServerController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$servers = Server::all();
return view('servers.index', compact('servers'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$datastores_pcc = DatastorePcc::orderBy('title')->get();
return view('servers.create', ['datastores_pcc' => $datastores_pcc]);
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\Servers\StoreServerRequest $request
* @return \Illuminate\Http\Response
*/
public function store(StoreServerRequest $request)
{
$server = new Server();
$server->fill($request->validated());
$this->makeChanges($request, $server);
if ($server->saveOrFail()) {
return redirect()->route('servers.edit', compact('servers'))
->with('success', trans('Server créé.'));
}
return \back();
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Server $server
* @return \Illuminate\Http\Response
*/
public function edit(Server $server)
{
$datastores_pcc = DatastorePcc::orderBy('title')->get();
return view('servers.edit', ['server' => $server, 'datastores_pcc' => $datastores_pcc]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\Servers\UpdateServerRequest $request
* @param \App\Models\Server $server
* @return \Illuminate\Http\Response
*/
public function update(UpdateServerRequest $request, Server $server)
{
$server->fill($request->validated());
if ($server->saveOrFail()) {
return redirect()->route('servers.edit', compact('server'))
->with('success', trans('Server mis à jour.'));
}
return \back();
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Server $server
* @return \Illuminate\Http\Response
*/
public function destroy(Server $server)
{
$isUsed = false;
if ($server->type === 'DB' || $server->type === 'WEB') {
$projects = Project::where('dev_db_server_id', '=', $server->id)
->orWhere('dev_web_server_id', '=', $server->id)
->orWhere('prod_db_server_id', '=', $server->id)
->orWhere('prod_web_server_id', '=', $server->id)
->get();
$isUsed = $projects->count() ? $projects : false;
}
return view('servers.delete', ['server' => $server, 'isUsed' => $isUsed]);
}
/**
* Remove the specified resource from storage.
*
* @param \App\Http\Requests\ValidateOtpRequest $request
* @param \App\Models\Server $server
* @return \Illuminate\Http\Response
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
*/
public function destroySubmit(ValidateOtpRequest $request, Server $server)
{
// phpcs:enable
if ($server->deleteOrFail()) {
return redirect()->route('servers.index')
->with('warning', 'Server supprimée !');
}
return back();
}
}

View file

@ -1,102 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Models\DatastorePcc;
use App\Models\Projects;
use App\Models\Servers;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use lfkeitel\phptotp\Base32;
use lfkeitel\phptotp\Totp;
class ServersController extends Controller
{
public function index(Request $request) {
$servers = Servers::all();
return view('servers.index', ['servers' => $servers]);
}
public function add(Request $request) {
$datastores_pcc = DatastorePcc::orderBy('title')->get();
return view('servers.add', ['datastores_pcc' => $datastores_pcc]);
}
public function edit(Request $request) {
$server_id = $request->id;
$server = Servers::findOrFail($server_id);
$datastores_pcc = DatastorePcc::orderBy('title')->get();
return view('servers.edit', ['server' => $server, 'datastores_pcc' => $datastores_pcc]);
}
public function update(Request $request) {
$server_id = $request->id;
$server = Servers::findOrFail($server_id);
$this->makeChanges($request, $server);
return redirect()->route('servers.edit', ['id' => $server_id])->with('status', 'Sauvegardé !');
}
public function store(Request $request) {
$server = new Servers();
$this->makeChanges($request, $server);
return redirect()->route('servers.edit', ['id' => $server->id])->with('status', 'Sauvegardé !');
}
public function delete(Request $request) {
$server_id = $request->id;
$server = Servers::findOrFail($server_id);
if ($server->type === 'DB' || $server->type === 'WEB') {
$isUsed = Projects::where('dev_db_server_id', '=', $server->id)->orWhere('dev_web_server_id', '=', $server->id)->orWhere('prod_db_server_id', '=', $server->id)->orWhere('prod_web_server_id', '=', $server->id)->get();
if ($isUsed->count() === 0)
$isUsed = false;
} else {
$isUsed = false;
}
return view('servers.delete', ['server' => $server, 'isUsed' => $isUsed]);
}
public function forceDelete(Request $request)
{
$server_id = $request->id;
$otp = $request->otp;
$lastCode = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret), Carbon::now()->subSeconds(30)->timestamp);
$code = (new Totp())->GenerateToken(Base32::decode(Auth::user()->totp_secret));
if ($otp === $code || $otp === $lastCode) {
$server = Servers::findOrFail($server_id);
$server->delete();
return redirect()->route('servers.index')->with('status', 'Serveur supprimé !');
}else{
return redirect()->route('servers.edit', ['id' => $server_id])->with('error', 'Code de vérification invalide.');
}
}
private function makeChanges($request, $server) {
$env = $request->env;
$virtual_ip = $request->virtual_ip;
$ssh = $request->ssh;
$infraweb_ip = $request->infraweb_ip;
$title = $request->title;
$name = $request->name;
$function = $request->function;
$dpcc = $request->datastore_pcc_id;
$comment = $request->comment;
$type = $request->type;
$server->env = $env;
$server->virtual_ip = $virtual_ip;
$server->ssh = $ssh;
$server->infraweb_ip = $infraweb_ip;
$server->title = $title;
$server->name = $name;
$server->function = $function;
$server->datastore_pcc_id = $dpcc;
$server->comment = $comment;
$server->type = $type;
$server->save();
}
}

View file

@ -2,28 +2,31 @@
namespace App\Http\Controllers;
use App\Models\Projects;
use Illuminate\Http\Request;
use App\Models\Project;
use Illuminate\Support\Facades\Http;
class StatusCheckerController extends Controller
{
public function index(Request $request) {
$wp_endpoint = 'https://api.wordpress.org/core/version-check/1.7/';
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $wp_endpoint);
$content = $response->getBody();
$oContent = json_decode($content);
/**
* Fetch Status
*
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
*/
public function index()
{
$wpReleases = Http::get(config('status-checker.wp_endpoint'))->json();
$laravelReleases = Http::withOptions([
'allow_redirects' => false,
])->asJson()->get(config('status-checker.laravel_endpoint'))->json();
$laravel_endpoint = 'https://github.com/laravel/laravel/releases/latest';
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $laravel_endpoint, [
'allow_redirects' => false
]);
$content = $response->getBody()->getContents();
$laravel_latest = substr($content, 84);
$laravel_latest = substr($laravel_latest, 0, -31);
$wp_latest = collect(collect(\collect($wpReleases)->get('offers'))->first())->get('version');
$laravel_latest = ltrim(collect(collect($laravelReleases)->first())->get('tag_name'), 'v');
$projects = Projects::orderBy('name')->get();
return view('status-checker.index', ['projects' => $projects, 'wp_latest' => $oContent->offers[0]->version, 'laravel_latest' => $laravel_latest]);
$projects = Project::orderBy('name')->get();
return view('status-checker.index', compact(
'projects',
'wp_latest',
'laravel_latest'
));
}
}

View file

@ -9,32 +9,39 @@ use Illuminate\Support\Facades\Mail;
class GitlabController extends Controller
{
/**
* Handle gitlab request
*
* @param GitlabRequest $request
* @return void
*/
public function handle(GitlabRequest $request)
{
// TODO: Check all request inputs, before sending unvalidated data by mail.
$event_type = $request->event_type;
if ($event_type === 'merge_request') {
// Si le state est <> de opened on ne fait rien
// Si le state est <> de opened on ne fait rien .
if ($request->object_attributes['state'] !== 'opened') {
exit;
}
// Si l'action est set et egale à approved on ne fait rien
// Si l'action est set et egale à approved on ne fait rien .
if (isset($request->object_attributes['action']) && $request->object_attributes['action'] === 'approved') {
exit;
}
$datas = [];
$datas['user'] = $request->user['name'];
$datas['project_name'] = $request->project['name'];
$datas['project_path'] = $request->project['path_with_namespace'];
$datas['attributes_description'] = $request->object_attributes['description'];
$datas['attributes_status'] = $request->object_attributes['merge_status'];
$datas = [];
$datas['user'] = $request->user['name'];
$datas['project_name'] = $request->project['name'];
$datas['project_path'] = $request->project['path_with_namespace'];
$datas['attributes_description'] = $request->object_attributes['description'];
$datas['attributes_status'] = $request->object_attributes['merge_status'];
$datas['attributes_request_status'] = $request->object_attributes['state'];
$datas['attributes_source_branch'] = $request->object_attributes['source_branch'];
$datas['attributes_target_branch'] = $request->object_attributes['target_branch'];
$datas['attributes_url'] = $request->object_attributes['url'];
$datas['last_commit_author'] = $request->object_attributes['last_commit']['author']['name'];
$datas['attributes_source_branch'] = $request->object_attributes['source_branch'];
$datas['attributes_target_branch'] = $request->object_attributes['target_branch'];
$datas['attributes_url'] = $request->object_attributes['url'];
$datas['last_commit_author'] = $request->object_attributes['last_commit']['author']['name'];
Mail::to(\explode(',', config('webhooks.gitlab.notify')))->send(new Gitlab($datas));
}
}//end if
}
}

View file

@ -11,11 +11,13 @@ class Kernel extends HttpKernel
*
* These middleware are run during every request to your application.
*
* @var array
* @var array<int, class-string|string>
*/
protected $middleware = [
\App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
@ -24,17 +26,19 @@ class Kernel extends HttpKernel
/**
* The application's route middleware groups.
*
* @var array
* @var array<string, array<int, class-string|string>>
*/
protected $middlewareGroups = [
'web' => [
'htmlsanitize',
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\SecureHeaders::class
],
'api' => [
@ -54,7 +58,7 @@ class Kernel extends HttpKernel
*
* These middleware may be assigned to groups or used individually.
*
* @var array
* @var array<string, class-string|string>
*/
protected $routeMiddleware = [
'auth' => \App\Http\Middleware\Authenticate::class,
@ -67,6 +71,8 @@ class Kernel extends HttpKernel
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'htmlsanitize' => \App\Http\Middleware\HtmlSanitizer::class,
'apiCheck' => \App\Http\Middleware\ApiCheckCredentialMiddleware::class
];
/**

View file

@ -0,0 +1,23 @@
<?php
namespace App\Http\Middleware;
class ApiCheckCredentialMiddleware
{
/**
* Handle an incoming request.
*
* @param mixed $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, \Closure $next)
{
if ($request->token !== \config('api.key')) {
return response('Unauthorized', 401);
}
/** @var \Illuminate\Http\Request $request */
return $next($request);
}
}

View file

@ -10,11 +10,12 @@ class Authenticate extends Middleware
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @param mixed $request
* @return string|null
*/
protected function redirectTo($request)
{
/** @var \Illuminate\Http\Request $request */
if (!$request->expectsJson()) {
session(['redirectURL' => URL::full()]);
return route('saml2_login', 'ldc');

View file

@ -1,17 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}

View file

@ -12,6 +12,5 @@ class EncryptCookies extends Middleware
* @var array
*/
protected $except = [
//
];
];
}

View file

@ -0,0 +1,46 @@
<?php
namespace App\Http\Middleware;
use App\Lib\ToolboxHelper;
use Illuminate\Http\Request;
class HtmlSanitizer
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param mixed ...$params
* @return mixed
*/
public function handle(Request $request, \Closure $next, ...$params)
{
$inputs = $request->all();
array_walk_recursive($inputs, function (&$input, $name) use ($params) {
if (!is_string($input)) {
return;
}
if (in_array($name, $params)) {
// ? Is a json input ?
if ($isJson = \json_decode($input, true) and is_array($isJson)) {
// ! Decode each json field recursive.
\array_walk_recursive($isJson, function (&$item) {
if (\is_string($item)) {
$item = clean($item);
$item = ToolboxHelper::stripCkEditorSchemesOnMediaInputs($item);
}
});
} else {
$input = clean($input);
$input = ToolboxHelper::stripCkEditorSchemesOnMediaInputs($input);
}
} else {
$input = strip_tags($input);
}
});
$request->merge($inputs);
return $next($request);
}
}

View file

@ -3,21 +3,25 @@
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\IpUtils;
class LDCNetwork
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param mixed $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
//IpUtils::checkIp();
// https://github.com/symfony/http-foundation/blob/master/IpUtils.php#L36
/**
* IpUtils::checkIp();
*/
// * https://github.com/symfony/http-foundation/blob/master/IpUtils.php#L36 .
/** @var \Illuminate\Http\Request $request */
return $next($request);
}
}

View file

@ -0,0 +1,15 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
class PreventRequestsDuringMaintenance extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array<int, string>
*/
protected $except = [];
}

View file

@ -5,7 +5,7 @@ namespace App\Http\Middleware;
use Aacotroneo\Saml2\Saml2Auth;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\URL;
class RedirectIfAuthenticated
@ -13,15 +13,15 @@ class RedirectIfAuthenticated
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
public function handle(Request $request, Closure $next)
{
if ($request->ajax()) {
return response('Unauthorized.', 401); // Or, return a response that causes client side js to redirect to '/routesPrefix/myIdp1/login'
// Or, return a response that causes client side js to redirect to '/routesPrefix/myIdp1/login' .
return response('Unauthorized.', 401);
} else {
$saml2Auth = new Saml2Auth(Saml2Auth::loadOneLoginAuthFromIpdConfig('ldc'));
session(['redirectURL' => URL::full()]);

View file

@ -0,0 +1,81 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\View;
class SecureHeaders
{
/**
* Enumerate headers which you do not want in your application's responses.
* Great starting point would be to go check out @Scott_Helme's:
* https://securityheaders.com/
*
* @var array
*/
private $unwantedHeaderList = [
'X-Powered-By',
'Server',
];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
View::share('nonce', $nonce = \uniqid());
// * For VueJS dev tool to execute
$cssDev = config('app.debug') ? "'unsafe-inline'" : "'nonce-$nonce'";
$jsDev = config('app.debug') ? "'unsafe-eval' 'unsafe-inline'" : "'nonce-$nonce'";
$reportUri = Route::has('cspReportUri') ?
\sprintf('report-uri %s', \parse_url(route('cspReportUri'), \PHP_URL_PATH)) : '';
$this->removeUnwantedHeaders($this->unwantedHeaderList);
$response = $next($request);
$response->headers->set('Referrer-Policy', 'no-referrer-when-downgrade');
$response->headers->set('X-Content-Type-Options', 'nosniff');
$response->headers->set('X-XSS-Protection', '1; mode=block');
$response->headers->set('X-Frame-Options', 'SAMEORIGIN');
$response->headers->set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains;');
$cspPolicies = [
"default-src 'none';",
// * CKEDITOR Specific https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/csp.html
"connect-src 'self' blob:;",
"img-src * data: blob:;",
"frame-src https://www.youtube.com;",
"font-src 'self' data: https://fonts.gstatic.com;",
// ! Using CKEditor wiill must have unsafe-inline style
// phpcs:ignore Generic.Files.LineLength.TooLong
// "style-src 'self' 'unsafe-inline';",
// ! If you dont use ckeditor use this
"style-src 'self' $cssDev https://fonts.googleapis.com;",
// phpcs:ignore Generic.Files.LineLength.TooLong
"script-src 'self' $jsDev;"
];
$response->headers->set(
'Content-Security-Policy',
implode(' ', $cspPolicies) . $reportUri
);
$response->headers->set('Feature-Policy', 'fullscreen \'self\';');
return $response;
}
/**
* Remove unwanted headers
*
* @param array $headerList
* @return void
*/
private function removeUnwantedHeaders(array $headerList)
{
foreach ($headerList as $header) {
header_remove($header);
}
}
}

View file

@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array<int, string|null>
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View file

@ -17,7 +17,7 @@ class TrustProxies extends Middleware
/**
* The headers that should be used to detect proxies.
*
* @var int
* @var integer
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View file

@ -9,7 +9,7 @@ class VerifyCsrfToken extends Middleware
/**
* Indicates whether the XSRF-TOKEN cookie should be set on the response.
*
* @var bool
* @var boolean
*/
protected $addHttpCookie = true;

View file

@ -0,0 +1,51 @@
<?php
namespace App\Http\Requests\Api;
use Illuminate\Foundation\Http\FormRequest;
class UpdateProjectStatusRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return $this->token === \config('api.key');
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$data = \json_decode($this->datas, true);
$this->merge([
'project_uuid' => collect($data)->get('uuid'),
'sitemap' => collect($data)->get('sitemap') === 'true' ? true : false,
'robots' => collect($data)->get('robots') === 'true' ? true : false,
'code' => collect($data)->get('code'),
'logs' => collect($data)->get('logs')
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'project_uuid' => 'required|exists:projects,uuid',
'sitemap' => 'required|boolean',
'robots' => 'required|boolean',
'code' => 'required|array',
'logs' => 'required|numeric',
];
}
}

View file

@ -1,20 +1,20 @@
<?php
namespace App\Http\Requests\Projects;
namespace App\Http\Requests\DatastorePccs;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class StoreProjects extends FormRequest
class StoreDatastorePccRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
* @return boolean
*/
public function authorize()
{
return Auth::checK();
return Auth::check();
}
/**
@ -25,9 +25,8 @@ class StoreProjects extends FormRequest
public function rules()
{
return [
// TODO : compléter les rules
'prod_smtp_config' => 'integer|required',
'prod_smtp_key' => 'required_if:prod_smtp_config,3'
'title' => 'required|min:2|max:50',
'comment' => 'required|min:2|max:50'
];
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace App\Http\Requests\DatastorePccs;
class UpdateDatastorePccRequest extends StoreDatastorePccRequest
{
}

View file

@ -0,0 +1,50 @@
<?php
namespace App\Http\Requests\DomainNames;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class StoreDomainNameRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return Auth::check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
'renew' => $this->renew ? true : false
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'ascii_name' => 'required|min:2|max:255',
'utf8_name' => 'required|min:2|max:255',
'expiration_date' => 'required|date',
'renew' => 'required|boolean',
'related_brand' => 'nullable|min:2|max:255',
'redirect_dns' => 'nullable|min:2|max:255',
'certificats' => 'nullable|min:2|max:255',
'comment' => 'nullable|min:2|max:255'
];
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace App\Http\Requests\DomainNames;
class UpdateDomainNameRequest extends StoreDomainNameRequest
{
}

View file

@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests\EmailAddresses;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class StoreEmailAddressRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return Auth::check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'account' => 'required|min:2|max:255',
'password' => 'required|max:255',
'domain_name_id' => 'required|exists:domain_names,id'
];
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace App\Http\Requests\EmailAddresses;
class UpdateEmailAddressRequest extends StoreEmailAddressRequest
{
}

View file

@ -1,17 +1,17 @@
<?php
namespace App\Http\Requests;
namespace App\Http\Requests\GitRepos;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
class GitReposStoreRequest extends FormRequest
class StoreGitRepoRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
* @return boolean
*/
public function authorize()
{

View file

@ -1,17 +1,17 @@
<?php
namespace App\Http\Requests;
namespace App\Http\Requests\GitRepos;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
class GitReposUpdateRequest extends FormRequest
class UpdateGitRepoRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
* @return boolean
*/
public function authorize()
{

View file

@ -0,0 +1,64 @@
<?php
namespace App\Http\Requests\LDCNetworks;
use App\Rules\CidrRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;
class StoreLDCNetwork extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return Auth::check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge($this->cidrToRange());
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'cidr' => ['required', new CidrRule()],
'first_ip' => 'required|ipv4',
'last_ip' => 'required|ipv4'
];
}
/**
* cidr To Ranges
*
* @return array ['first_ip', 'last_ip']
*/
private function cidrToRange(): array
{
$first_ip = '';
$last_ip = '';
$cidr = collect(explode('/', \strval($this->cidr)));
try {
$first_ip = long2ip(intval(ip2long($cidr->get(0))) & ((-1 << (32 - intval($cidr->get(1))))));
$last_ip = long2ip(intval(ip2long(\strval($first_ip))) + pow(2, (32 - intval($cidr->get(1)))) - 1);
} catch (\Error $e) {
Session::flash('warning', trans('Le CIDR est mal formé'));
}
return \compact('first_ip', 'last_ip');
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace App\Http\Requests\LDCNetworks;
class UpdateLDCNetwork extends StoreLDCNetwork
{
}

View file

@ -0,0 +1,112 @@
<?php
namespace App\Http\Requests\Projects;
use App\Enums\PhpVersion;
use App\Enums\ProjectType;
use App\Enums\SmtpEnum;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
class StoreProjectRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return Auth::check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
'https' => $this->https ? true : false
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [];
if (Auth::user()->equipe_web_member) {
$rules = [
'prod_login' => 'required|json',
'dev_login' => 'required|json',
'prod_bo_url' => 'required|url',
'dev_bo_url' => 'required|url',
];
}
return \array_merge($rules, [
'name' => 'required|string|min:2|max:255',
'display_name' => 'required|string|min:2|max:255',
'php' => ['required', new EnumIsValidRule(PhpVersion::class)],
'type' => ['required', new EnumIsValidRule(ProjectType::class)],
'https' => 'required|boolean',
'prod_haproxy_id' => 'nullable|regex:/^p?\d{3}$/',
'dev_haproxy_id' => 'nullable|regex:/^p?\d{3}$/',
'prod_url' => 'nullable|url|max:255',
'dev_url' => 'nullable|url|max:255',
'prod_document_root' => 'nullable|regex:/^(\w+/){1,2}\w+\.\w+$/|max:255',
'dev_document_root' => 'nullable|regex:/^(\w+/){1,2}\w+\.\w+$/|max:255',
'prod_unix_user' => 'nullable|string|max:255',
'prod_unix_pwd' => 'nullable|string|max:255',
'dev_unix_user' => 'nullable|string|max:255',
'dev_unix_pwd' => 'nullable|string|max:255',
'prod_db_user' => 'nullable|string|max:255',
'prod_db_pwd' => 'nullable|string|max:255',
'dev_db_user' => 'nullable|string|max:255',
'dev_db_pwd' => 'nullable|string|max:255',
'prod_db_schema' => 'nullable|string|max:255',
'dev_db_schema' => 'nullable|string|max:255',
'prod_db_server_id' => 'sometimes|exists:servers,id',
'dev_db_server_id' => 'sometimes|exists:servers,id',
'prod_web_server_id' => 'sometimes|exists:servers,id',
'dev_web_server_id' => 'sometimes|exists:servers,id',
'prod_comment' => 'nullable|string|max:255',
'dev_comment' => 'nullable|string|max:255',
'prod_eai' => 'nullable|stringmax:255',
'dev_eai' => 'nullable|stringmax:255',
'prod_whitelist_fw' => 'nullable|string|max:255',
'dev_whitelist_fw' => 'nullable|string|max:255',
'dev_htaccess_user' => 'required|string|min:2|max:255',
'dev_htaccess_pwd' => 'required|string|min:2|max:255',
'prod_ga_id' => 'nullable|string|max:50',
// phpcs:ignore Generic.Files.LineLength.TooLong
'prod_laravel_app_key' => 'nullable|regex:/^base64:(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/|max:255',
// phpcs:ignore Generic.Files.LineLength.TooLong
'dev_laravel_app_key' => 'nullable|regex:/^base64:(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$/|max:255',
'prod_smtp_config' => [
'required', new EnumIsValidRule(SmtpEnum::class)
],
'prod_smtp_key' => 'required_if:prod_smtp_config,3|max:255|max:255',
]);
}
}

View file

@ -2,21 +2,8 @@
namespace App\Http\Requests\Projects;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class UpdateProjects extends FormRequest
class UpdateProjectRequest extends StoreProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return Auth::checK();
}
/**
* Get the validation rules that apply to the request.
*
@ -24,12 +11,12 @@ class UpdateProjects extends FormRequest
*/
public function rules()
{
return [
// TODO : compléter les rules
return \array_merge(parent::rules(), [
// TODO : compléter les rules .
'prod_laravel_app_key' => 'required_if:type,3',
'dev_laravel_app_key' => 'required_if:type,3',
'prod_smtp_config' => 'integer|required',
'prod_smtp_key' => 'required_if:prod_smtp_config,3'
];
]);
}
}

View file

@ -0,0 +1,47 @@
<?php
namespace App\Http\Requests\Servers;
use App\Enums\Environment;
use App\Enums\ServerType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
class StoreServerRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return Auth::check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'env' => [
'required', new EnumIsValidRule(Environment::class)
],
'virtual_ip' => 'required|ipV4',
'ssh' => 'required',
'infraweb_ip' => 'required|ipV4',
'title' => 'required|min:2|max:50',
'name' => 'required|min:2|max:50',
'function' => 'required|min:2|max:50',
'datastore_pcc_id' => 'required|exists:datastore_pccs,id',
'comment' => 'nullable|string',
'type' => [
'required', new EnumIsValidRule(ServerType::class)
],
];
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace App\Http\Requests\Servers;
class UpdateServerRequest extends StoreServerRequest
{
}

View file

@ -0,0 +1,51 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Carbon;
use lfkeitel\phptotp\Base32;
use lfkeitel\phptotp\Totp;
class ValidateOtpRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
if (!session()->get('tmpUserOTP')) {
return false;
}
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'otp' => [
'string',
'required',
function ($attribute, $value, $fail) {
$user = session()->get('tmpUserOTP');
$lastCode = (new Totp())->GenerateToken(
Base32::decode($user->totp_secret),
Carbon::now()->subSeconds(30)->timestamp
);
$code = (new Totp())->GenerateToken(Base32::decode($user->totp_secret));
if (!($value === $code || $value === $lastCode)) {
$fail("Code de vérification $attribute invalide.");
}
}
]
];
}
}

View file

@ -9,11 +9,12 @@ class GitlabRequest extends FormRequest
/**
* Determine if the user is authorized to make this request.
*
* @return bool
* @return boolean
*/
public function authorize()
{
return $this->header('X-Gitlab-Token') !== null && $this->header('X-Gitlab-Token') === config('webhooks.gitlab.token');
return $this->header('X-Gitlab-Token') !== null &&
$this->header('X-Gitlab-Token') === config('webhooks.gitlab.token');
}
/**

View file

@ -0,0 +1,31 @@
<?php
namespace App\Http\Resources\Api;
use App\Models\LDCNetwork;
use Illuminate\Http\Resources\Json\ResourceCollection as JsonResourceCollection;
class LDCNetworkResource extends JsonResourceCollection
{
/**
* Transform the resource into an array.
*
* @param mixed $request
* @return array
*/
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass, Squiz.Commenting.FunctionComment.Missing
public function toArray($request)
{
return $this->collection->map(function (LDCNetwork $network) {
$infos = collect(explode('.', strval($network->first_ip)));
$min = intval($infos->get(3));
$max = collect(explode('.', strval($network->last_ip)))->get(3);
for ($i = $min; $i <= $max; $i++) {
$ips[] = $infos->get(0) . '.' .
$infos->get(1) . '.' .
$infos->get(2) . ".$i";
}
return $ips;
});
}
}

View file

@ -4,29 +4,44 @@ namespace App\Lib\LDC;
use GuzzleHttp\Client;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Support\Facades\Log;
use Psr\Http\Message\ResponseInterface;
class MailjetSms
{
/** @var Application $app */
protected $app;
/** @var array $config */
protected $config = [];
/**
* MailjetSms
*
* @param \Illuminate\Contracts\Foundation\Application $app
*/
public function __construct(Application $app)
{
$this->app = $app;
$this->loadDefaultOptions();
}
protected function loadDefaultOptions(): MailjetSms
/**
* loadDefaultOptions
*
* @return \App\Lib\LDC\MailjetSms
*/
protected function loadDefaultOptions(): \App\Lib\LDC\MailjetSms
{
$this->config = $this->app['config']->get('services.mailjet');
return $this;
}
protected function buildHttpClient(): Client
/**
* buildHttpClient
*
* @return \GuzzleHttp\Client
*/
protected function buildHttpClient(): \GuzzleHttp\Client
{
return new Client([
'allow_redirects' => false,
@ -42,9 +57,18 @@ class MailjetSms
]);
}
public function send(string $message, string $to, $from = null): ResponseInterface
/**
* send sms
*
* @param string $message
* @param string $to
* @param string|null $from
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\RequestException If Mailsms send service call failed.
*/
public function send(string $message, string $to, ?string $from = null): ResponseInterface
{
$from = $from ?? $this->config['sms_from'];
$from = $from ?? $this->config['sms_from'];
$client = $this->buildHttpClient();
try {
@ -55,16 +79,11 @@ class MailjetSms
'To' => $to,
]
]);
} catch (\GuzzleHttp\Exception\RequestException $ex) {
Log::debug('error ' . $ex->getMessage());
if (!is_null($ex->getResponse())){
Log::debug((string) $ex->getResponse()->getBody());
}
throw $ex;
} catch (\GuzzleHttp\Exception\RequestException $e) {
report($e);
throw $e;
}
return $response;
}
}

228
app/Lib/ToolboxHelper.php Normal file
View file

@ -0,0 +1,228 @@
<?php
namespace App\Lib;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class ToolboxHelper
{
/**
* Strip scheme (https) on oembed urls
* Only embed allowed are for MP4 self hosted videos right now
*
* https is force by ckeditor MediaElements which natively supports
* only cloud hosted medias (youtube, spotify etc..)
*
* @param string $input
* @return string
*/
public static function stripCkEditorSchemesOnMediaInputs(string $input): string
{
$input = \preg_replace('/(?<=<oembed url=")(https:\/\/)(?=.*?">)/m', '', $input);
return $input;
}
/**
* Assert That no Back Office url is present on txt
*
* @param string $field
* @param string $text
* @return string
* @throws \Illuminate\Validation\ValidationException If url is a bo url.
*/
public static function assertNoInternalBoUrls(string $field, string $text): string
{
$routes = Route::getRoutes();
// * Url replace and email replace.
$text = preg_replace_callback(
// phpcs:ignore Generic.Files.LineLength.TooLong
'/(?P<url>(?:http[s]?:\/\/.)?(?:www\.)?[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))/',
function ($matches) use ($routes, $field) {
$match = collect($matches)->first() ?? '';
$url = $match;
try {
$request = Request::create($url);
// If a route is match then it do not throws exception.
if (
\parse_url(config('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST) &&
trim($routes->match($request)->getPrefix() ?? '', '/') === 'bo'
) {
// Removes the matched url.
throw ValidationException::withMessages([
$field => sprintf(
'%s : Il est interdit de coller une url du back office dans ce champ',
trans($field)
)
]);
}
return $match;
} catch (NotFoundHttpException $e) {
return $match;
}
},
$text
);
return $text;
}
/**
* Assert That only external url is present on txt
*
* @param string $field
* @param string $text
* @return string
* @throws \Illuminate\Validation\ValidationException If url is a bo url.
*/
public static function assertNoInternalUrls(string $field, string $text): string
{
self::assertNoInternalBoUrls($field, $text);
$routes = Route::getRoutes();
// * Url replace and email replace.
$text = preg_replace_callback(
// phpcs:ignore Generic.Files.LineLength.TooLong
'/(?P<url>(?:http[s]?:\/\/.)?(?:www\.)?[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))/',
function ($matches) use ($routes, $field) {
$match = collect($matches)->first() ?? '';
$url = $match;
try {
$request = Request::create($url);
// If a route is match then it do not throws exception.
if (
\parse_url(config('app.url'), \PHP_URL_HOST) === \parse_url($url, \PHP_URL_HOST) &&
$routes->match($request)
) {
// Removes the matched url.
throw ValidationException::withMessages([
$field => sprintf(
'%s : Il est interdit de coller une url de %s dans ce champ',
trans($field),
config('app.name')
)
]);
}
return $match;
} catch (NotFoundHttpException $e) {
return $match;
}
},
$text
);
return $text;
}
/**
* Generates an array from a dot separated string
*
* @param string $path
* @param mixed $value
* @param string $separator
* @return array
*/
public static function dotStringToNestedArray(string $path, $value, string $separator = '.'): array
{
$arr = $value;
$keys = array_reverse(explode($separator, $path));
foreach ($keys as $key) {
$arr = [$key => $arr];
}
return $arr;
}
/**
* Destroy image
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $attribute
* @return void
*/
public static function removeImage(Model $model, string $attribute)
{
$path = ltrim($model->{$attribute}, '/');
if (File::exists($path) and \strpos($path, 'storage') === 0) {
File::delete($path);
}
}
/**
* Destroy image
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $attribute
* @return void
*/
public static function removeOldImage(Model $model, string $attribute)
{
$originalPath = ltrim($model->getOriginal($attribute), '/');
if (File::exists($originalPath) and \strpos($originalPath, 'storage') === 0) {
File::delete($originalPath);
}
}
/**
* Store an image of different types
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Http\UploadedFile|\SplFileInfo|string $image
* @return string
* @throws \ErrorException If file copy fails.
*/
public static function storeImage(Model $model, $image): string
{
$table = $model->getTable();
if (\is_object($image) and $image instanceof \Illuminate\Http\UploadedFile) {
/** @var \Illuminate\Http\UploadedFile $image */
$newPath = self::prepareMoveFile($table, \filter_var(
\strip_tags(\urldecode($image->getClientOriginalName())),
\FILTER_SANITIZE_STRING
));
$newPath = str_replace(storage_path('app'), '', $newPath);
$image->storePubliclyAs(
pathinfo($newPath, \PATHINFO_DIRNAME),
pathinfo($newPath, \PATHINFO_BASENAME)
);
return 'storage' . str_replace('/public', '', $newPath);
}
if (\is_object($image) and $image instanceof \SplFileInfo) {
/** @var \SplFileInfo $image */
$newPath = self::prepareMoveFile($table, $image->getBaseName());
if (!File::copy($image->getRealPath(), $newPath)) {
throw new \ErrorException(sprintf(
'Failed to copy file %s to %s',
$image->getRealPath(),
$newPath
));
}
return \ltrim(str_replace(\storage_path('app/public'), '/storage', $newPath), '/');
}
return \ltrim(strval($image), '/');
}
/**
* Prepare storage path and return
* the image full path
*
* @param string $table Model table name.
* @param string $filename The basename for the file.
* @return string
*/
private static function prepareMoveFile(string $table, string $filename): string
{
$pathFolder = \storage_path(sprintf('app/public/images/%s', $table));
if (!File::exists($pathFolder)) {
File::makeDirectory($pathFolder, 0755, true);
}
$filename = sprintf('%s-%s', Str::uuid(), $filename);
$fullPath = sprintf('%s/%s', $pathFolder, $filename);
if (File::exists($fullPath)) {
File::delete($fullPath);
}
return $fullPath;
}
}

View file

@ -3,24 +3,29 @@
namespace App\Mail\Webhooks;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Gitlab extends Mailable
{
use Queueable, SerializesModels;
use Queueable;
use SerializesModels;
public $datas;
/**
* Mail data
*
* @var array
*/
public $data;
/**
* Create a new message instance.
*
* @return void
* @param array $data
*/
public function __construct(array $datas)
public function __construct(array $data)
{
$this->datas = $datas;
$this->data = $data;
}
/**

View file

@ -6,5 +6,12 @@ use Illuminate\Database\Eloquent\Model;
class DatastorePcc extends Model
{
protected $table = 'datastore_pcc';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'title', 'comment'
];
}

19
app/Models/DomainName.php Normal file
View file

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DomainName extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'ascii_name', 'utf8_name', 'expiration_date',
'renew', 'related_brand', 'redirect_dns',
'certificats', 'comment'
];
}

View file

@ -1,10 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class DomainNames extends Model
{
//
}

View file

@ -0,0 +1,43 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class EmailAddress extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'account', 'password',
'domain_name_id'
];
// * METHODS
/**
* domain_name getter
*
* @return mixed
*/
public function getDomainNameAttribute()
{
$dn = DomainName::findOrFail($this->domain_name_id);
return $dn->utf8_name;
}
// * RELATIONSHIPS
/**
* BelongsTo domain name relation
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function domainName()
{
return $this->belongsTo(DomainName::class);
}
}

View file

@ -1,13 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class EmailAddresses extends Model
{
public function getDomainNameAttribute() {
$dn = DomainNames::findOrFail($this->domain_name_id);
return $dn->utf8_name;
}
}

18
app/Models/GitRepo.php Normal file
View file

@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class GitRepo extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'login',
'password'
];
}

View file

@ -1,10 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class GitRepos extends Model
{
protected $fillable = ['name', 'login', 'password'];
}

24
app/Models/LDCNetwork.php Normal file
View file

@ -0,0 +1,24 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class LDCNetwork extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'ldc_networks';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'cidr', 'first_ip', 'last_ip'
];
}

View file

@ -1,10 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class LDCNetworks extends Model
{
protected $table = 'ldc_networks';
}

233
app/Models/Project.php Normal file
View file

@ -0,0 +1,233 @@
<?php
namespace App\Models;
use App\Enums\PhpVersion;
use App\Enums\ProjectType;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Kwaadpepper\Enum\Traits\CastsEnums;
class Project extends Model
{
use CastsEnums;
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'dev_login' => 'array',
'prod_login' => 'array',
'https' => 'boolean'
];
/**
* Map attribute names to enum classes.
*
* @var array
*/
protected $enumCasts = [
'php' => PhpVersion::class,
'type' => ProjectType::class,
'smtp' => SmtpEnum::class
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'display_name', 'php', 'type', 'https', 'prod_haproxy_id',
'dev_haproxy_id', 'prod_url', 'dev_url', 'prod_document_root',
'dev_document_root', 'prod_unix_user', 'dev_unix_user',
'prod_unix_pwd', 'dev_unix_pwd', 'prod_db_user', 'dev_db_user',
'prod_db_pwd', 'dev_db_pwd', 'prod_db_schema', 'dev_db_schema',
'prod_db_server_id', 'dev_db_server_id', 'prod_web_server_id',
'dev_web_server_id', 'prod_comment', 'dev_comment', 'prod_eai',
'dev_eai', 'prod_whitelist_fw', 'dev_whitelist_fw',
'dev_htaccess_user', 'dev_htaccess_pwd', 'prod_ga_id',
'prod_laravel_app_key', 'dev_laravel_app_key',
'prod_smtp_config', 'prod_smtp_key',
];
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName(): string
{
return 'uuid';
}
// * METHODS
/**
* get dev_web_ip attribute
*
* @return mixed
*/
public function getDevWebIpAttribute()
{
$value = Server::find($this->dev_web_server_id);
if ($value) {
$value = $value->ssh;
}
return $value;
}
/**
* get dev_db_ip attribute
*
* @return mixed
*/
public function getDevDbIpAttribute()
{
$value = Server::find($this->dev_db_server_id);
if ($value) {
$value = $value->ssh;
}
return $value;
}
/**
* get prod_web_ip attribute
*
* @return mixed
*/
public function getProdWebIpAttribute()
{
$value = Server::find($this->prod_web_server_id);
if ($value) {
$value = $value->ssh;
}
return $value;
}
/**
* get prod_db_ip attribute
*
* @return mixed
*/
public function getProdDbIpAttribute()
{
$value = Server::find($this->prod_db_server_id);
if ($value) {
$value = $value->ssh;
}
return $value;
}
/**
* get checked attribute
*
* @return mixed
*/
public function getCheckedAttribute()
{
$value = ProjectsStatusChecker::select('updated_at')->where('project_uuid', '=', $this->uuid)->first();
if (!$value) {
$value = 'missing';
} else {
$value = $value->updated_at;
$dt = Carbon::now();
if ($dt->diffInMinutes($value) > 30) {
$value = 'false';
} else {
$value = 'true';
}
}
return $value;
}
/**
* get sitemap_checked attribute
*
* @return mixed
*/
public function getSitemapCheckedAttribute()
{
$value = ProjectsStatusChecker::select('sitemap')->where('project_uuid', '=', $this->uuid)->first();
if (!$value) {
$value = 'missing';
} else {
$value = $value->sitemap;
}
return $value;
}
/**
* get robots_checked attribute
*
* @return mixed
*/
public function getRobotsCheckedAttribute()
{
$value = ProjectsStatusChecker::select('robots')->where('project_uuid', '=', $this->uuid)->first();
if (!$value) {
$value = 'missing';
} else {
$value = $value->robots;
}
return $value;
}
/**
* get logs_checked attribute
*
* @return mixed
*/
public function getLogsCheckedAttribute()
{
$value = ProjectsStatusChecker::select('logs')->where('project_uuid', '=', $this->uuid)->first();
if (!$value) {
$value = 'missing';
} else {
$value = $value->logs;
}
return $value;
}
/**
* get code attribute
*
* @return mixed
*/
public function getCodeAttribute()
{
$value = ProjectsStatusChecker::select('code')->where('project_uuid', '=', $this->uuid)->first();
if (!$value) {
$value = 'missing';
} else {
$value = $value->code;
}
return $value;
}
/**
* get logs_hr attribute
*
* @return string
*/
public function getLogsHrAttribute(): string
{
$value = ProjectsStatusChecker::select('logs')->where('project_uuid', '=', $this->uuid)->first();
return $this->humanFilesize($value->logs);
}
/**
* Human readable file size
*
* @param float $size
* @return string
*/
private function humanFilesize(float $size): string
{
$i = \floatval(floor(log($size, 1024)));
return round($size / pow(1024, $i), [0,0,2,2,3][$i]) . [' O',' Ko',' Mo',' Go',' To'][$i];
}
}

View file

@ -1,102 +0,0 @@
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class Projects extends Model
{
public function getDevWebIpAttribute() {
$value = Servers::find($this->dev_web_server_id);
if ($value)
$value = $value->ssh;
return $value;
}
public function getDevDbIpAttribute() {
$value = Servers::find($this->dev_db_server_id);
if ($value)
$value = $value->ssh;
return $value;
}
public function getProdWebIpAttribute() {
$value = Servers::find($this->prod_web_server_id);
if ($value)
$value = $value->ssh;
return $value;
}
public function getProdDbIpAttribute() {
$value = Servers::find($this->prod_db_server_id);
if ($value)
$value = $value->ssh;
return $value;
}
public function getCheckedAttribute() {
$value = ProjectsStatusChecker::select('updated_at')->where('project_uuid', '=', $this->uuid)->first();
if (!$value) {
$value = 'missing';
} else {
$value = $value->updated_at;
$dt = Carbon::now();
if ($dt->diffInMinutes($value) > 30) {
$value = 'false';
} else {
$value = 'true';
}
}
return $value;
}
public function getSitemapCheckedAttribute() {
$value = ProjectsStatusChecker::select('sitemap')->where('project_uuid', '=', $this->uuid)->first();
if(!$value) {
$value = 'missing';
} else {
$value = $value->sitemap;
}
return $value;
}
public function getRobotsCheckedAttribute() {
$value = ProjectsStatusChecker::select('robots')->where('project_uuid', '=', $this->uuid)->first();
if(!$value) {
$value = 'missing';
} else {
$value = $value->robots;
}
return $value;
}
public function getLogsCheckedAttribute() {
$value = ProjectsStatusChecker::select('logs')->where('project_uuid', '=', $this->uuid)->first();
if(!$value) {
$value = 'missing';
} else {
$value = $value->logs;
}
return $value;
}
public function getCodeAttribute() {
$value = ProjectsStatusChecker::select('code')->where('project_uuid', '=', $this->uuid)->first();
if(!$value) {
$value = 'missing';
} else {
$value = $value->code;
}
return $value;
}
public function getLogsHrAttribute() {
$value = ProjectsStatusChecker::select('logs')->where('project_uuid', '=', $this->uuid)->first();
return $this->human_filesize($value->logs);
}
private function human_filesize($size, $precision = 2) {
$i = floor(log($size, 1024));
return round($size / pow(1024, $i), [0,0,2,2,3][$i]).[' O',' Ko',' Mo',' Go',' To'][$i];
}
}

View file

@ -6,5 +6,23 @@ use Illuminate\Database\Eloquent\Model;
class ProjectsStatusChecker extends Model
{
protected $table = 'projects_status_checker';
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'code' => 'array',
'sitemap' => 'boolean',
'robots' => 'boolean'
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'project_uuid', 'code', 'sitemap', 'robots'
];
}

36
app/Models/Server.php Normal file
View file

@ -0,0 +1,36 @@
<?php
namespace App\Models;
use App\Enums\Environment;
use App\Enums\ServerType;
use Illuminate\Database\Eloquent\Model;
use Kwaadpepper\Enum\Traits\CastsEnums;
class Server extends Model
{
use CastsEnums;
/**
* Map attribute names to enum classes.
*
* @var array
*/
protected $enumCasts = [
'env' => Environment::class,
'type' => ServerType::class
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'env', 'virtual_ip',
'ssh', 'infraweb_ip',
'title', 'name', 'function',
'datastore_pcc_id', 'comment',
'type'
];
}

View file

@ -1,10 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Servers extends Model
{
//
}

View file

@ -1,8 +1,7 @@
<?php
namespace App;
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
@ -16,7 +15,12 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'phone', 'password',
'firstname',
'lastname',
'email',
'phone',
'password',
'equipe_web_member'
];
/**
@ -34,6 +38,7 @@ class User extends Authenticatable
* @var array
*/
protected $casts = [
'equipe_web_member' => 'boolean',
'email_verified_at' => 'datetime',
];
}

View file

@ -2,21 +2,13 @@
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
@ -25,5 +17,33 @@ class AppServiceProvider extends ServiceProvider
public function boot()
{
URL::forceScheme('https');
// * LOCAL FORCE eg: for Carbon
// * Remove numeric to prevent float seperator to breaking numeric transactions
\collect([\LC_TIME, \LC_MESSAGES, \LC_COLLATE, \LC_CTYPE, \LC_MONETARY])
->map(function ($contant) {
setlocale(
$contant,
\sprintf(
'%s_%s.UTF-8',
config('app.locale'),
\strtoupper(config('app.locale'))
)
);
});
Carbon::setLocale(config('app.locale'));
// * Force bootstrap paginator
Paginator::useBootstrap();
// * HA PROXY FIX
app()->singleton('clientIp', function () {
if (
config('app.env') === 'local'
) {
return request()->getClientIp();
}
return request()->server('HTTP_X_FORWARDED_FOR') ?? request()->getClientIp();
});
}
}

View file

@ -3,18 +3,15 @@
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
* @var array<class-string, class-string>
*/
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy',
];
protected $policies = [];
/**
* Register any authentication / authorization services.
@ -24,7 +21,5 @@ class AuthServiceProvider extends ServiceProvider
public function boot()
{
$this->registerPolicies();
//
}
}

View file

@ -1,21 +0,0 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Broadcast::routes();
require base_path('routes/channels.php');
}
}

View file

@ -3,9 +3,8 @@
namespace App\Providers;
use Aacotroneo\Saml2\Events\Saml2LoginEvent;
use App\User;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
@ -20,7 +19,6 @@ class EventServiceProvider extends ServiceProvider
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
@ -34,21 +32,57 @@ class EventServiceProvider extends ServiceProvider
parent::boot();
Event::listen('Aacotroneo\Saml2\Events\Saml2LoginEvent', function (Saml2LoginEvent $event) {
$messageId = $event->getSaml2Auth()->getLastMessageId();
// TODO : Add your own code preventing reuse of a $messageId to stop replay attacks
$user = $event->getSaml2User();
$messageId = $event->getSaml2Auth()->getLastMessageId();
if (class_exists('Memcached')) {
$cache = new \Memcached();
$cache->addServer(
config('cache.stores.memcached.servers.0.host'),
config('cache.stores.memcached.servers.0.port')
);
$fromCache = $cache->get(config('cache.prefix') . "_saml_message_id_" . $messageId);
if (!in_array($cache->getResultCode(), [\Memcached::RES_SUCCESS, \Memcached::RES_NOTFOUND])) {
throw new \Exception('SAML MESSAGE ID HANDLER - Memcached Error : ' . $cache->getResultCode() . " - https://www.php.net/manual/en/memcached.getresultcode.php");
}
if ($fromCache) {
logger()->error(
'SAML MESSAGE ID HANDLER',
[
'error' => 'Message ID : ' . $messageId . " replayed !"
]
);
abort(403);
} else {
// Cache for 8h.
$cache->set(config('cache.prefix') . "_saml_message_id_" . $messageId, $messageId, 28800);
if ($cache->getResultCode() === \Memcached::RES_NOTSTORED) {
throw new \Exception('SAML MESSAGE ID HANDLER - Memcached Error : NOT STORED');
}
}
} else {
throw new \Exception("SAML MESSAGE ID HANDLER - Memcached is missing");
} //end if
$user = $event->getSaml2User();
$email = $user->getNameId();
$lUser = User::where('email', '=', $email)->first();
if (!$lUser) {
abort(redirect()->route('unauthorized'));
}
session(['sessionIndex' => $user->getSessionIndex()]);
session(['nameId' => $email]);
session(['tmpUserOTP' => $lUser]);
abort(redirect()->route('auth.verify'));
});
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
Event::listen('Aacotroneo\Saml2\Events\Saml2LogoutEvent', function ($event) {
Auth::logout();
Session::save();

View file

@ -2,7 +2,6 @@
namespace App\Providers;
use Illuminate\Support\Facades\App;
use Illuminate\Support\ServiceProvider;
use App\Lib\LDC\MailjetSms;
@ -15,7 +14,6 @@ class MailjetSmsServiceProvider extends ServiceProvider
*/
public function register()
{
//
}
/**
@ -25,7 +23,7 @@ class MailjetSmsServiceProvider extends ServiceProvider
*/
public function boot()
{
App::singleton('MailjetSms', function ($app) {
$this->app->singleton('MailjetSms', function ($app) {
return new MailjetSms($app);
});
}

View file

@ -2,23 +2,19 @@
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/';
@ -30,51 +26,35 @@ class RouteServiceProvider extends ServiceProvider
*/
public function boot()
{
//
$this->configureRateLimiting();
parent::boot();
$this->routes(function () {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web-bo.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web-fo.php'));
Route::middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
});
}
/**
* Define the routes for the application.
* Configure the rate limiters for the application.
*
* @return void
*/
public function map()
protected function configureRateLimiting()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
RateLimiter::for('web', function (Request $request) {
return Limit::perMinute(150)->by(optional($request->user())->id ?: app('clientIp'));
});
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(150)->by(optional($request->user())->id ?: app('clientIp'));
});
}
}

View file

@ -0,0 +1,77 @@
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\ServiceProvider;
class TranslationServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
foreach ($this->collectLocalesStrings() as $locale) {
// * Suported locales
Cache::rememberForever(sprintf('translations.%s', $locale), function () use ($locale) {
$translations = [
'php' => $this->phpTranslations($locale),
'json' => $this->jsonTranslations($locale),
];
return $translations;
});
}
}
/**
* Gather provided langs checking from files
*
* @return Collection
*/
private function collectLocalesStrings(): Collection
{
return collect(File::allFiles(resource_path('lang/')))->flatMap(function ($file) {
if ($file->getRelativePath()) {
return [$file->getRelativePath() => ''];
}
})->keys();
}
/**
* Gather all php translations
*
* @param string $locale
* @return array
*/
private function phpTranslations(string $locale): array
{
$path = resource_path("lang/$locale");
return collect(File::allFiles($path))->flatMap(function ($file) use ($locale) {
$translation = $file->getBasename('.php');
return [$translation => trans($translation, [], $locale)];
})->all();
}
/**
* Gather json translations
*
* @param string $locale
* @return array
*/
private function jsonTranslations(string $locale): array
{
$path = resource_path("lang/$locale.json");
if (is_string($path) && is_readable($path)) {
return json_decode(file_get_contents($path), true) ?? [];
}
return [];
}
}

57
app/Rules/CidrRule.php Normal file
View file

@ -0,0 +1,57 @@
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class CidrRule implements Rule
{
/**
* Determine if the validation rule passes.
*
* @param mixed $attribute
* @param mixed $value
* @return boolean
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
*/
public function passes($attribute, $value)
{
// phpcs:enable
$m = true;
if (strpos($value, ":") !== false) {
// * ipv6
if (strpos($value, "/") !== false) {
list($value, $mask) = explode("/", $value);
$m = filter_var(
$mask,
\FILTER_VALIDATE_INT,
["options" => ["min_range" => 0, "max_range" => 128]]
);
}
return $m && filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6);
} else {
// * ipv4
if (strpos($value, "/") !== false) {
list($value, $mask) = explode("/", $value);
$m = filter_var(
$mask,
\FILTER_VALIDATE_INT,
["options" => ["min_range" => 0, "max_range" => 32]]
);
}
return $m && filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4);
} //end if
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return "The :attribute must be a valid IP address or CIDR range.";
}
}

View file

@ -8,25 +8,31 @@
],
"license": "MIT",
"require": {
"php": "^7.2",
"php": "^7.3",
"aacotroneo/laravel-saml2": "^2.1",
"fideloper/proxy": "^4.0",
"fruitcake/laravel-cors": "^2.2",
"guzzlehttp/guzzle": "^7.0.1",
"kwaadpepper/enum": "^2.1",
"kwaadpepper/exception-handler": "^0.0.6",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.0",
"kwaadpepper/exception-handler": "^0.0.8",
"laravel/framework": "^8.75",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.0",
"lfkeitel/phptotp": " 1.0",
"mews/purifier": "^3.3",
"propaganistas/laravel-phone": "^4.3",
"simplesoftwareio/simple-qrcode": "^4.2",
"slevomat/coding-standard": "^7.0"
},
"require-dev": {
"facade/ignition": "^2.3.6",
"fzaninotto/faker": "^1.9.1",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.0"
"doctrine/dbal": "^3.3",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"phpunit/phpunit": "^9.5.10",
"slevomat/coding-standard": "^7.2"
},
"config": {
"optimize-autoloader": true,

2079
composer.lock generated

File diff suppressed because it is too large Load diff

5
config/api.php Normal file
View file

@ -0,0 +1,5 @@
<?php
return [
'key' => 'CE8S52Qq7stf5k8frF4T'
];

View file

@ -3,53 +3,53 @@
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application. This value is used when the
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
'debug' => (bool)env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| your application so that it is used when running Artisan tasks.
|
*/
'url' => env('APP_URL', 'http://localhost'),
@ -57,66 +57,66 @@ return [
'asset_url' => env('ASSET_URL', null),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => 'Europe/Paris',
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by the translation service provider. You are free to set this value
| to any of the locales which will be supported by the application.
|
*/
'locale' => 'fr',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'en',
/*
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
|--------------------------------------------------------------------------
| Faker Locale
|--------------------------------------------------------------------------
|
| This locale will be used by the Faker PHP library when generating fake
| data for your database seeds. For example, this will be used to get
| localized telephone numbers, street address information and more.
|
*/
'faker_locale' => 'en_US',
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is used by the Illuminate encrypter service and should be set
| to a random, 32 character string, otherwise these encrypted strings
| will not be safe. Please do this before deploying an application!
|
*/
'key' => env('APP_KEY'),
@ -124,14 +124,14 @@ return [
'cipher' => 'AES-256-CBC',
/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
|--------------------------------------------------------------------------
| Autoloaded Service Providers
|--------------------------------------------------------------------------
|
| The service providers listed here will be automatically loaded on the
| request to your application. Feel free to add your own services to
| this array to grant expanded functionality to your applications.
|
*/
'providers' => [
@ -139,6 +139,7 @@ return [
/*
* Laravel Framework Service Providers...
*/
Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
@ -169,24 +170,25 @@ return [
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\TranslationServiceProvider::class,
App\Providers\MailjetSmsServiceProvider::class,
],
/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/
'aliases' => [
@ -227,8 +229,6 @@ return [
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'SmtpEnum' => App\Enums\Smtp::class,
'ProjectTypesEnum' => App\Enums\ProjectTypes::class,
],
];

View file

@ -3,14 +3,14 @@
return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
|--------------------------------------------------------------------------
| Authentication Defaults
|--------------------------------------------------------------------------
|
| This option controls the default authentication "guard" and password
| reset options for your application. You may change these defaults
| as required, but they're a perfect start for most applications.
|
*/
'defaults' => [
@ -19,20 +19,20 @@ return [
],
/*
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
|--------------------------------------------------------------------------
| Authentication Guards
|--------------------------------------------------------------------------
|
| Next, you may define every authentication guard for your application.
| Of course, a great default configuration has been defined for you
| here which uses session storage and the Eloquent user provider.
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| Supported: "session", "token"
|
*/
'guards' => [
@ -49,47 +49,47 @@ return [
],
/*
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
|--------------------------------------------------------------------------
| User Providers
|--------------------------------------------------------------------------
|
| All authentication drivers have a user provider. This defines how the
| users are actually retrieved out of your database or other storage
| mechanisms used by this application to persist your user's data.
|
| If you have multiple user tables or models you may configure multiple
| sources which represent each model / table. These sources may then
| be assigned to any extra authentication guards you have defined.
|
| Supported: "database", "eloquent"
|
*/
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// 'driver' => 'database',
// 'table' => 'users',
// ],
],
/*
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
|--------------------------------------------------------------------------
| Resetting Passwords
|--------------------------------------------------------------------------
|
| You may specify multiple password reset configurations if you have more
| than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types.
|
| The expire time is the number of minutes that the reset token should be
| considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed.
|
*/
'passwords' => [
@ -102,14 +102,14 @@ return [
],
/*
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
|--------------------------------------------------------------------------
| Password Confirmation Timeout
|--------------------------------------------------------------------------
|
| Here you may define the amount of seconds before a password confirmation
| times out and the user is prompted to re-enter their password via the
| confirmation screen. By default, the timeout lasts for three hours.
|
*/
'password_timeout' => 10800,

View file

@ -3,29 +3,29 @@
return [
/*
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
|
|--------------------------------------------------------------------------
| Default Broadcaster
|--------------------------------------------------------------------------
|
| This option controls the default broadcaster that will be used by the
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
|
*/
'default' => env('BROADCAST_DRIVER', 'null'),
/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/
'connections' => [

View file

@ -5,30 +5,30 @@ use Illuminate\Support\Str;
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
|
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
@ -59,9 +59,7 @@ return [
env('MEMCACHED_USERNAME'),
env('MEMCACHED_PASSWORD'),
],
'options' => [
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
],
'options' => [],
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
@ -88,16 +86,16 @@ return [
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
];

View file

@ -1,36 +1,44 @@
<?php
use Illuminate\Database\DBAL\TimestampType;
use Illuminate\Support\Str;
return [
// * https://github.com/laravel/docs/blob/master/migrations.md#prerequisites .
'dbal' => [
'types' => [
'timestamp' => TimestampType::class,
],
],
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once using the Database library.
|
*/
'default' => env('DB_CONNECTION', 'mysql'),
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
| Here are each of the database connections setup for your application.
| Of course, examples of configuring each database platform that is
| supported by Laravel is shown below to make development simple.
|
|
| All database work in Laravel is done through the PHP PDO facilities
| so make sure you have the driver for your particular database of
| choice installed on your machine before you begin development.
|
*/
'connections' => [
@ -94,27 +102,27 @@ return [
],
/*
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
|--------------------------------------------------------------------------
| Migration Repository Table
|--------------------------------------------------------------------------
|
| This table keeps track of all the migrations that have already run for
| your application. Using this information, we can determine which of
| the migrations on disk haven't actually been run in the database.
|
*/
'migrations' => 'migrations',
/*
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
|--------------------------------------------------------------------------
| Redis Databases
|--------------------------------------------------------------------------
|
| Redis is an open source, fast, and advanced key-value store that also
| provides a richer body of commands than a typical key-value system
| such as APC or Memcached. Laravel makes it easy to dig right in.
|
*/
'redis' => [
@ -123,7 +131,7 @@ return [
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
],
'default' => [

View file

@ -3,42 +3,42 @@
return [
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
|--------------------------------------------------------------------------
| Default Filesystem Disk
|--------------------------------------------------------------------------
|
| Here you may specify the default filesystem disk that should be used
| by the framework. The "local" disk, as well as a variety of cloud
| based disks are available to your application. Just store away!
|
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
|--------------------------------------------------------------------------
| Filesystem Disks
|--------------------------------------------------------------------------
|
| Here you may configure as many filesystem "disks" as you wish, and you
| may even configure multiple disks of the same driver. Defaults have
| been setup for each driver as an example of the required options.
|
| Supported Drivers: "local", "ftp", "sftp", "s3"
|
*/
'disks' => [

View file

@ -3,29 +3,29 @@
return [
/*
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
|--------------------------------------------------------------------------
| Default Hash Driver
|--------------------------------------------------------------------------
|
| This option controls the default hash driver that will be used to hash
| passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish.
|
| Supported: "bcrypt", "argon", "argon2id"
|
*/
'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
@ -33,14 +33,14 @@ return [
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [

View file

@ -7,31 +7,31 @@ use Monolog\Handler\SyslogUdpHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [

Some files were not shown because too many files have changed in this diff Show more