2021-07-25 21:54:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Facades\Options;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
class SecuritySettingsService
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves the app security settings.
|
|
|
|
*
|
|
|
|
* @param $policy
|
|
|
|
* @param array $options
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function save($policy, $options = []) {
|
|
|
|
|
|
|
|
$validPolicies = [
|
|
|
|
'off',
|
|
|
|
'low',
|
|
|
|
'medium',
|
|
|
|
'high'
|
|
|
|
];
|
|
|
|
|
|
|
|
if (in_array($policy, $validPolicies))
|
|
|
|
{
|
|
|
|
Options::changeOption('pw_security_policy', $policy);
|
|
|
|
|
|
|
|
Log::debug('[Options] Changing option pw_security_policy', [
|
|
|
|
'new_value' => $policy
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Log::debug('[WARN] Ignoring bogus policy', [
|
|
|
|
'avaliable' => $validPolicies,
|
|
|
|
'given' => $policy
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
Options::changeOption('graceperiod', $options['graceperiod']);
|
2021-09-03 23:44:54 +00:00
|
|
|
Options::changeOption('password_expiry', $options['pwExpiry']);
|
2021-07-25 21:54:15 +00:00
|
|
|
Options::changeOption('force2fa', $options['enforce2fa']);
|
|
|
|
Options::changeOption('requireGameLicense', $options['requirePMC']);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|