TenantAtlas/apps/platform/app/Services/Auth/ManagedEnvironmentAccessDecision.php
Ahmed Darrazi ef02ff5a29
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 8m29s
feat: implement spec 285 workspace-first environment access
2026-05-09 14:36:12 +02:00

40 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Services\Auth;
final readonly class ManagedEnvironmentAccessDecision
{
public function __construct(
public int $workspaceId,
public int $managedEnvironmentId,
public int $userId,
public bool $workspaceMember,
public ?string $workspaceRole,
public bool $explicitScopeRowsPresent,
public bool $managedEnvironmentAllowed,
public ?string $failedBoundary = null,
public ?string $requiredCapability = null,
public bool $capabilityAllowed = true,
public ?int $denialHttpStatus = null,
) {}
public function allowed(): bool
{
return $this->workspaceMember
&& $this->managedEnvironmentAllowed
&& $this->capabilityAllowed;
}
public function shouldDenyAsNotFound(): bool
{
return $this->denialHttpStatus === 404;
}
public function shouldDenyAsForbidden(): bool
{
return $this->denialHttpStatus === 403;
}
}