Adopt Laravel coding style

Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions.

You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started.

[1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer
[2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
This commit is contained in:
Laravel Shift
2021-06-10 20:15:52 +00:00
parent 54cb6c050a
commit 934afa036f
4549 changed files with 35238 additions and 38391 deletions
+31 -33
View File
@@ -2,10 +2,10 @@
namespace App\Http\Requests;
use App\Models\Setting;
use Illuminate\Foundation\Http\FormRequest;
use OneLogin\Saml2\IdPMetadataParser as OneLogin_Saml2_IdPMetadataParser;
use OneLogin\Saml2\Utils as OneLogin_Saml2_Utils;
use App\Models\Setting;
/**
* This handles validating and cleaning SAML settings provided by the user.
@@ -42,9 +42,8 @@ class SettingsSamlRequest extends FormRequest
{
$validator->after(function ($validator) {
if ($this->input('saml_enabled') == '1') {
$idpMetadata = $this->input('saml_idp_metadata');
if (!empty($idpMetadata)) {
if (! empty($idpMetadata)) {
try {
if (filter_var($idpMetadata, FILTER_VALIDATE_URL)) {
$metadataInfo = OneLogin_Saml2_IdPMetadataParser::parseRemoteXML($idpMetadata);
@@ -59,21 +58,21 @@ class SettingsSamlRequest extends FormRequest
$was_custom_x509cert = strpos(Setting::getSettings()->saml_custom_settings, 'sp_x509cert') !== false;
$custom_x509cert='';
$custom_privateKey='';
$custom_x509certNew='';
if (!empty($this->input('saml_custom_settings'))) {
$custom_x509cert = '';
$custom_privateKey = '';
$custom_x509certNew = '';
if (! empty($this->input('saml_custom_settings'))) {
$req_custom_settings = preg_split('/\r\n|\r|\n/', $this->input('saml_custom_settings'));
$custom_settings = [];
foreach ($req_custom_settings as $custom_setting) {
$split = explode('=', $custom_setting, 2);
if (count($split) == 2) {
$split[0] = trim($split[0]);
$split[1] = trim($split[1]);
if (!empty($split[0])) {
if (! empty($split[0])) {
$custom_settings[] = implode('=', $split);
}
if ($split[0] == 'sp_x509cert') {
@@ -86,37 +85,36 @@ class SettingsSamlRequest extends FormRequest
}
}
}
$this->merge(['saml_custom_settings' => implode(PHP_EOL, $custom_settings) . PHP_EOL]);
$this->merge(['saml_custom_settings' => implode(PHP_EOL, $custom_settings).PHP_EOL]);
}
$cert_updated=false;
if (!empty($custom_x509cert) && !empty($custom_privateKey)) {
$cert_updated = false;
if (! empty($custom_x509cert) && ! empty($custom_privateKey)) {
// custom certificate and private key are defined
$cert_updated=true;
$cert_updated = true;
$x509 = openssl_x509_read($custom_x509cert);
$pkey = openssl_pkey_get_private($custom_privateKey);
} elseif ($this->input('saml_sp_regenerate_keypair') == '1' || !$this->has('saml_sp_x509cert') || $was_custom_x509cert) {
} elseif ($this->input('saml_sp_regenerate_keypair') == '1' || ! $this->has('saml_sp_x509cert') || $was_custom_x509cert) {
// key regeneration requested, no certificate defined yet or previous custom certicate was removed
error_log("regen");
$cert_updated=true;
error_log('regen');
$cert_updated = true;
$dn = [
"countryName" => "US",
"stateOrProvinceName" => "N/A",
"localityName" => "N/A",
"organizationName" => "Snipe-IT",
"commonName" => "Snipe-IT",
'countryName' => 'US',
'stateOrProvinceName' => 'N/A',
'localityName' => 'N/A',
'organizationName' => 'Snipe-IT',
'commonName' => 'Snipe-IT',
];
$pkey = openssl_pkey_new([
"private_key_bits" => 2048,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
'private_key_bits' => 2048,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
]);
$csr = openssl_csr_new($dn, $pkey, ['digest_alg' => 'sha256']);
if ($csr) {
$x509 = openssl_csr_sign($csr, null, $pkey, 3650, ['digest_alg' => 'sha256']);
openssl_x509_export($x509, $x509cert);
@@ -126,8 +124,8 @@ error_log("regen");
while (($error = openssl_error_string() !== false)) {
$errors[] = $error;
}
if (!(empty($x509cert) && empty($privateKey))) {
if (! (empty($x509cert) && empty($privateKey))) {
$this->merge([
'saml_sp_x509cert' => $x509cert,
'saml_sp_privatekey' => $privateKey,
@@ -146,14 +144,14 @@ error_log("regen");
$errors[] = $error;
}
if (!empty($x509certNew)) {
if (! empty($x509certNew)) {
$this->merge([
'saml_sp_x509certNew' => $x509certNew
'saml_sp_x509certNew' => $x509certNew,
]);
}
} else {
$this->merge([
'saml_sp_x509certNew' => ""
'saml_sp_x509certNew' => '',
]);
}
});