Блокировка адресов, журнал подозрительной активности, срок жизни ключей API
This commit is contained in:
1 parent
3a04ee5bb3
commit
20f3d79552
20 files changed
+1042
-6
No files matched your search
@@ -5,7 +5,11 @@ declare(strict_types=1);
|
||||
namespace Rsgrinko\Proton\Queue;
|
||||
|
||||
use Rsgrinko\Proton\Backup\BackupJob;
|
||||
use Rsgrinko\Proton\Models\ApiToken;
|
||||
use Rsgrinko\Proton\Models\Setting;
|
||||
use Rsgrinko\Proton\Models\User;
|
||||
use Rsgrinko\Proton\Notifications\ApiKeyExpiringNotification;
|
||||
use Rsgrinko\Proton\Notifications\Notify;
|
||||
use Rsgrinko\Proton\Support\Config;
|
||||
use Rsgrinko\Proton\Support\Logger;
|
||||
use Rsgrinko\Proton\Support\Monitor;
|
||||
@@ -176,6 +180,22 @@ final class Scheduler
|
||||
});
|
||||
}
|
||||
|
||||
// Ключи API не продлеваются, поэтому владельцу нужно время выпустить
|
||||
// новый: напоминаем раз в сутки, пока срок не вышел
|
||||
self::dailyAt('09:00', 'keys:expiring', static function (): void {
|
||||
$days = max(1, (int) Config::get('security.key_expiry_notice_days', 7));
|
||||
|
||||
foreach (ApiToken::expiringWithin($days) as $token) {
|
||||
$owner = User::find((int) $token->raw('user_id'));
|
||||
|
||||
if ($owner === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Notify::send($owner, new ApiKeyExpiringNotification($token, $token->daysLeft()));
|
||||
}
|
||||
});
|
||||
|
||||
// Присмотр за порогами: о беде лучше узнать от приложения, чем от людей
|
||||
if ((bool) Config::get('monitor.enabled', true)) {
|
||||
self::every(
|
||||
|
||||
Reference in new issue
Block a user