singleloginsystem/app/Livewire/Forms/StoreConnectedAppFrom.php
= 4849736c60 Feat: add intials SAML SSO compatibility.
- SAML public certificate generation
- Authentication using SAML
2026-05-27 05:49:36 +00:00

69 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Livewire\Forms;
use App\Data\ConnectedApp\ConnectedAppData;
use App\Services\ConnectedAppService;
use Livewire\Form;
class StoreConnectedAppFrom extends Form
{
public string $name = '';
public int $providerId = 0;
public int $protocolId = 0;
public int $statusId = 0;
public string $samlEntityId = '';
public string $samlAcsUrl = '';
protected ConnectedAppService $service;
public function boot(ConnectedAppService $service): void
{
$this->service = $service;
}
/**
* Get the dynamic validation rules for the form.
*
* @return array<string, string>
*/
public function rules(): array
{
$rules = [
'name' => 'required|string|max:255|min:3',
'providerId' => 'required|numeric|min:1|exists:connection_providers,id',
'protocolId' => 'required|numeric|min:1|exists:connection_protocols,id',
'statusId' => 'required|numeric|min:1|exists:connection_statuses,id',
];
$protocol = \App\Models\ConnectionProtocol::find($this->protocolId);
if ($protocol && 'saml' === mb_strtolower($protocol->name)) {
$rules['samlEntityId'] = 'required|string|min:3';
$rules['samlAcsUrl'] = 'required|url';
}
return $rules;
}
/**
* This sets the form to edit mode, after fetching the connected app of
* the given id.
*/
public function set(ConnectedAppData $data): void
{
$this->name = $data->name;
$this->protocolId = $data->protocolId;
$this->providerId = $data->providerId;
$this->statusId = $data->statusId;
$this->samlEntityId = $data->settings['saml']['entity_id'] ?? '';
$this->samlAcsUrl = $data->settings['saml']['acs_url'] ?? '';
}
}