89 lines
2.2 KiB
PHP
89 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KTXM\AuthenticationProviderOidc;
|
|
|
|
use KTXC\Resource\ProviderManager;
|
|
use DI\Attribute\Inject;
|
|
use KTXF\Module\ModuleInstanceAbstract;
|
|
|
|
/**
|
|
* OpenID Connect Identity Provider Module
|
|
* Provides SSO authentication via OIDC protocol
|
|
*/
|
|
class Module extends ModuleInstanceAbstract
|
|
{
|
|
public function __construct(
|
|
private readonly ProviderManager $providerManager,
|
|
#[Inject('rootDir')] private readonly string $rootDir,
|
|
) {}
|
|
public function handle(): string
|
|
{
|
|
return 'authentication_provider_oidc';
|
|
}
|
|
|
|
public function label(): string
|
|
{
|
|
return 'OpenID Connect Authentication Provider';
|
|
}
|
|
|
|
public function author(): string
|
|
{
|
|
return 'Ktrix';
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'OpenID Connect (OIDC) authentication provider - enables SSO authentication with Google, Azure AD, Okta, Keycloak, and other OIDC-compliant identity providers';
|
|
}
|
|
|
|
public function version(): string
|
|
{
|
|
return '1.0.0';
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
// Register the provider with the provider manager
|
|
$this->providerManager->register('authentication', 'oidc', Provider::class);
|
|
}
|
|
|
|
public function install(): void
|
|
{
|
|
// Create cache directory for OIDC state
|
|
$cacheDir = $this->rootDir . '/var/cache/oidc_state';
|
|
if (!is_dir($cacheDir)) {
|
|
mkdir($cacheDir, 0755, true);
|
|
}
|
|
}
|
|
|
|
public function uninstall(): void
|
|
{
|
|
// Optionally clean up cache
|
|
}
|
|
|
|
public function enable(): void
|
|
{
|
|
// Provider is registered on boot
|
|
}
|
|
|
|
public function disable(): void
|
|
{
|
|
// Nothing to do - provider not registered when module is disabled
|
|
}
|
|
|
|
public function bootUi(): array
|
|
{
|
|
return [
|
|
'handle' => $this->handle(),
|
|
'namespace' => 'AuthenticationProviderOidc',
|
|
'version' => $this->version(),
|
|
'label' => $this->label(),
|
|
'author' => $this->author(),
|
|
'description' => $this->description(),
|
|
'boot' => 'static/module.mjs',
|
|
];
|
|
}
|
|
}
|