feat(deploy): temporary SAAS_ADMIN_TEST_BYPASS flag for test server (off by default)

Allows SaaS-admin area in non-local/testing envs only when SAAS_ADMIN_TEST_BYPASS=true.
Default false -> production unaffected. Remove after Yandex 360 SSO (Б-1 + DO-4).
TDD: tests/Feature/Middleware/EnsureSaasAdminTest.php (2 passing).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Дмитрий
2026-05-21 11:00:16 +03:00
parent 1220bddf3e
commit e6752b5e4c
4 changed files with 41 additions and 6 deletions
+9 -3
View File
@@ -29,10 +29,16 @@ class EnsureSaasAdmin
{
public function handle(Request $request, Closure $next): Response
{
if (! app()->environment('local', 'testing')) {
abort(503, 'SaaS-admin авторизация не настроена (ожидает Б-1 + DO-4).');
if (app()->environment('local', 'testing')) {
return $next($request);
}
return $next($request);
// ВРЕМЕННО (тест-деплой): пропускаем при включённом флаге.
// TODO: убрать после внедрения Yandex 360 SSO (Б-1 + DO-4).
if (config('app.saas_admin_test_bypass') === true) {
return $next($request);
}
abort(503, 'SaaS-admin авторизация не настроена (ожидает Б-1 + DO-4).');
}
}
+7
View File
@@ -28,6 +28,13 @@ return [
'env' => env('APP_ENV', 'production'),
/*
| ВРЕМЕННО (тест-деплой): пропуск гейта SaaS-admin зоны вне local/testing.
| По умолчанию false прод не затронут. Включается только на тест-сервере
| (SAAS_ADMIN_TEST_BYPASS=true). Убрать после внедрения Yandex 360 SSO (Б-1 + DO-4).
*/
'saas_admin_test_bypass' => (bool) env('SAAS_ADMIN_TEST_BYPASS', false),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
use function Pest\Laravel\get;
// Гейт SaaS-admin зоны (middleware EnsureSaasAdmin). Вне local/testing зона
// закрыта (503), кроме случая включённого временного флага тест-деплоя.
it('blocks saas-admin area outside local/testing without bypass flag', function () {
app()->detectEnvironment(fn () => 'production');
config(['app.saas_admin_test_bypass' => false]);
get('/api/admin/tenants')->assertStatus(503);
});
it('allows saas-admin area when test bypass flag is enabled', function () {
app()->detectEnvironment(fn () => 'production');
config(['app.saas_admin_test_bypass' => true]);
expect(get('/api/admin/tenants')->status())->not->toBe(503);
});
+3 -3
View File
@@ -1,6 +1,6 @@
# Brain Status (auto-generated)
Last updated: 2026-05-21T01:53:48.034Z
Last updated: 2026-05-21T07:59:50.686Z
| Контролёр | Состояние | Детали |
|---|---|---|
@@ -8,12 +8,12 @@ Last updated: 2026-05-21T01:53:48.034Z
| C2 Cross-ref consistency | ✅ | [cross-ref-checker] OK — 0 drift in 4 files |
| C3 Observer-of-observer | ✅ | [observer-of-observer] OK — last read 0 week(s) ago |
| C4 Сигнальный статус | ✅ | This file (self-reference) |
| C5 Observer-coverage | ⚠️ | 16 episode(s) this month · .git/hooks/post-commit not installed (run: npx lefthook install --force) |
| C5 Observer-coverage | | 67 episode(s) this month · Stop-hook + post-commit OK |
| C6 Chain map sync | ✅ | [chain-map-checker] OK — 14 chains in sync |
## Метрики (информационные, не алерты)
- Observer evidence: 16 episodes this month, 0 observer_error markers, 0 PII matches before filter
- Observer evidence: 67 episodes this month, 0 observer_error markers, 48 PII matches before filter
- Legacy v1 episodes (not in factor analysis): 5
- Last /brain-retro: 2 day(s) ago
- Использование узлов: см. `/brain-retro` (раз в спринт). **Неиспользованные узлы — не проблема** (capability-readiness; см. memory `feedback_brain_unused_tools_not_problem` — outside-repo memory store).