- Introduced new components and services for OIDC app creation, enabling dynamic handling of app types, URIs, and user roles. - Added support for uploading and managing logos for connected apps. - Implemented `ClientCreationFactory` and related factories for modular OIDC client generation. - Updated UI to enhance app creation flow with post-creation credential display and improved validations. - Refactored backend with `OidcService` for streamlined OIDC app creation and management.
38 lines
1020 B
PHP
38 lines
1020 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\Applications\OIDC\Factory;
|
|
|
|
use App\Data\Application\{ClientCredentialsData, StoreOIDCAppData};
|
|
use App\Enums\ApplicationTypeEnum;
|
|
use Exception;
|
|
use Laravel\Passport\ClientRepository;
|
|
|
|
readonly class AuthorizationCodeClientFactory implements ClientCreationContract
|
|
{
|
|
public function __construct(
|
|
private ClientRepository $client,
|
|
) {}
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function create(
|
|
StoreOIDCAppData $data
|
|
): ClientCredentialsData {
|
|
$client = $this->client->createAuthorizationCodeGrantClient(
|
|
name: $data->name,
|
|
redirectUris: $data->signInUris,
|
|
confidential: ApplicationTypeEnum::Web === $data->type,
|
|
);
|
|
|
|
return new ClientCredentialsData(
|
|
clientId: $client->id,
|
|
grantType: 'authorization_code',
|
|
clientSecret: $client->plainSecret,
|
|
redirectUris: $client->getAttribute('redirect_uris'),
|
|
);
|
|
}
|
|
}
|