whmcs-oidc_admin_login/oidc_admin_login.php
Kumi 83e171bc5d
feat: Enhanced OIDC Admin Login module
Refactored the OIDC Admin Login for WHMCS to improve usability and configuration management. The module now supports dynamic configuration via the WHMCS admin interface, removing the need for manual edits to a config file. This change facilitates easier module activation, configuration, and management directly from the WHCMS admin panel.

Key changes include:
- Transitioned the installation path to the more appropriate `/modules/addons` directory.
- Eliminated the `config.dist.php` file in favor of storing configuration details in the database, which are set through the WHMCS admin UI.
- Added admin UI components for module activation and configuration, including fields for OIDC provider URL, client ID, client secret, OIDC claim, and OIDC scopes.
- Introduced a login handler script that dynamically fetches configuration from the database, authenticates users via their OIDC provider, and handles session setup within WHMCS based on the `preferred_username` claim.
- Implemented instructional comments and setup guidelines in README to guide users through the new installation and configuration process.

This upgrade streamlines the setup process for administrators and strengthens the module's integration with WHMCS, making it more accessible and easier to manage.
2024-04-27 15:17:12 +02:00

64 lines
2.3 KiB
PHP

<?php
function oidc_admin_login_config()
{
// Plugin details displayed by WHMCS
return [
'name' => 'OIDC Admin Login',
'description' => 'This module provides an OpenID Connect based single sign-on (SSO) solution for WHMCS admin users.',
'version' => '0.1',
'author' => 'Kumi Systems e.U.',
'fields' => [
// Configuration fields for the module
// Displayed in WHMCS admin area under Addon Modules and used to store OIDC provider details
'oidcProviderUrl' => [
'FriendlyName' => 'OIDC Provider URL',
'Type' => 'text',
'Size' => '25',
'Default' => '',
'Description' => 'Enter the URL of your OIDC provider.',
],
'clientId' => [
'FriendlyName' => 'Client ID',
'Type' => 'text',
'Size' => '25',
'Default' => '',
'Description' => 'Enter the client ID provided by your OIDC provider.',
],
'clientSecret' => [
'FriendlyName' => 'Client Secret',
'Type' => 'password',
'Size' => '25',
'Default' => '',
'Description' => 'Enter the client secret provided by your OIDC provider.',
],
'oidcClaim' => [
'FriendlyName' => 'OIDC Claim',
'Type' => 'text',
'Size' => '25',
'Default' => 'preferred_username',
'Description' => 'Enter the OIDC claim to use as the WHMCS username.',
],
'oidcScopes' => [
'FriendlyName' => 'OIDC Scopes',
'Type' => 'text',
'Size' => '25',
'Default' => 'openid,email,profile',
'Description' => 'Enter the OIDC scopes to request from the provider, separated by commas.',
],
],
];
}
function oidc_admin_login_activate()
{
// Code to execute when the module is activated
return ['status' => 'success', 'description' => 'OIDC Admin Login activated successfully'];
}
function oidc_admin_login_deactivate()
{
// Code to execute when the module is deactivated
return ['status' => 'success', 'description' => 'OIDC Admin Login deactivated successfully'];
}