Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion i18n
Submodule i18n updated 88 files
+ af_ZA/LC_MESSAGES/gibbon.mo
+0 −25,562 af_ZA/LC_MESSAGES/gibbon.po
+ am_ET/LC_MESSAGES/gibbon.mo
+138,534 −2,869 am_ET/LC_MESSAGES/gibbon.po
+ ar_SA/LC_MESSAGES/gibbon.mo
+138,834 −3,400 ar_SA/LC_MESSAGES/gibbon.po
+ bg_BG/LC_MESSAGES/gibbon.mo
+138,683 −3,052 bg_BG/LC_MESSAGES/gibbon.po
+137,001 −2,708 bn_BD/LC_MESSAGES/gibbon.po
+ da_DK/LC_MESSAGES/gibbon.mo
+138,535 −2,870 da_DK/LC_MESSAGES/gibbon.po
+99 −198 dbStringsForTranslation.php
+2 −2 dbTranslationPrep.php
+ de_DE/LC_MESSAGES/gibbon.mo
+138,592 −2,942 de_DE/LC_MESSAGES/gibbon.po
+138,535 −2,869 el_GR/LC_MESSAGES/gibbon.po
+ en_GB/LC_MESSAGES/gibbon.mo
+138,536 −2,857 en_GB/LC_MESSAGES/gibbon.po
+ en_US/LC_MESSAGES/gibbon.mo
+138,567 −2,968 en_US/LC_MESSAGES/gibbon.po
+ es_DO/LC_MESSAGES/gibbon.mo
+0 −25,573 es_DO/LC_MESSAGES/gibbon.po
+ es_ES/LC_MESSAGES/gibbon.mo
+139,092 −3,965 es_ES/LC_MESSAGES/gibbon.po
+ es_MX/LC_MESSAGES/gibbon.mo
+138,520 −2,861 es_MX/LC_MESSAGES/gibbon.po
+138,535 −2,869 et_EE/LC_MESSAGES/gibbon.po
+ fa_IR/LC_MESSAGES/gibbon.mo
+138,720 −3,058 fa_IR/LC_MESSAGES/gibbon.po
+ fi_FI/LC_MESSAGES/gibbon.mo
+138,522 −2,859 fi_FI/LC_MESSAGES/gibbon.po
+ fr_FR/LC_MESSAGES/gibbon.mo
+139,365 −4,410 fr_FR/LC_MESSAGES/gibbon.po
+ he_IL/LC_MESSAGES/gibbon.mo
+138,441 −2,845 he_IL/LC_MESSAGES/gibbon.po
+ hr_HR/LC_MESSAGES/gibbon.mo
+138,499 −2,849 hr_HR/LC_MESSAGES/gibbon.po
+ hu_HU/LC_MESSAGES/gibbon.mo
+138,626 −2,970 hu_HU/LC_MESSAGES/gibbon.po
+ id_ID/LC_MESSAGES/gibbon.mo
+138,833 −3,408 id_ID/LC_MESSAGES/gibbon.po
+ in_OR/LC_MESSAGES/gibbon.mo
+138,534 −2,869 in_OR/LC_MESSAGES/gibbon.po
+ it_IT/LC_MESSAGES/gibbon.mo
+138,705 −3,047 it_IT/LC_MESSAGES/gibbon.po
+ ja_JP/LC_MESSAGES/gibbon.mo
+143,453 −9,385 ja_JP/LC_MESSAGES/gibbon.po
+138,533 −2,870 ka_GE/LC_MESSAGES/gibbon.po
+ ko_KP/LC_MESSAGES/gibbon.mo
+138,447 −2,838 ko_KP/LC_MESSAGES/gibbon.po
+138,533 −2,870 my_MM/LC_MESSAGES/gibbon.po
+ nl_NL/LC_MESSAGES/gibbon.mo
+144,472 −9,933 nl_NL/LC_MESSAGES/gibbon.po
+ no_NO/LC_MESSAGES/gibbon.mo
+138,503 −2,848 no_NO/LC_MESSAGES/gibbon.po
+ om_ET/LC_MESSAGES/gibbon.mo
+138,515 −2,856 om_ET/LC_MESSAGES/gibbon.po
+ pl_PL/LC_MESSAGES/gibbon.mo
+138,807 −3,254 pl_PL/LC_MESSAGES/gibbon.po
+ pt_BR/LC_MESSAGES/gibbon.mo
+138,866 −3,581 pt_BR/LC_MESSAGES/gibbon.po
+ pt_PT/LC_MESSAGES/gibbon.mo
+138,581 −2,938 pt_PT/LC_MESSAGES/gibbon.po
+ ro_RO/LC_MESSAGES/gibbon.mo
+138,477 −2,824 ro_RO/LC_MESSAGES/gibbon.po
+ ru_RU/LC_MESSAGES/gibbon.mo
+138,516 −2,855 ru_RU/LC_MESSAGES/gibbon.po
+ sq_AL/LC_MESSAGES/gibbon.mo
+138,482 −2,841 sq_AL/LC_MESSAGES/gibbon.po
+ sw_KE/LC_MESSAGES/gibbon.mo
+138,535 −2,872 sw_KE/LC_MESSAGES/gibbon.po
+ th_TH/LC_MESSAGES/gibbon.mo
+138,607 −3,080 th_TH/LC_MESSAGES/gibbon.po
+ tr_TR/LC_MESSAGES/gibbon.mo
+141,257 −5,925 tr_TR/LC_MESSAGES/gibbon.po
+ uk_UA/LC_MESSAGES/gibbon.mo
+138,492 −2,858 uk_UA/LC_MESSAGES/gibbon.po
+ ur_IN/LC_MESSAGES/gibbon.mo
+121,989 −8,945 ur_IN/LC_MESSAGES/gibbon.po
+ ur_PK/LC_MESSAGES/gibbon.mo
+138,461 −2,840 ur_PK/LC_MESSAGES/gibbon.po
+ vi_VN/LC_MESSAGES/gibbon.mo
+138,575 −2,997 vi_VN/LC_MESSAGES/gibbon.po
+0 −4 xgettextGenerationCommands.sh
+ zh_CN/LC_MESSAGES/gibbon.mo
+138,838 −3,276 zh_CN/LC_MESSAGES/gibbon.po
+ zh_HK/LC_MESSAGES/gibbon.mo
+138,508 −2,909 zh_HK/LC_MESSAGES/gibbon.po
8 changes: 8 additions & 0 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Gibbon\Auth\Adapter\OAuthGoogleAdapter;
use Gibbon\Auth\Adapter\OAuthMicrosoftAdapter;
use Gibbon\Auth\Adapter\OAuthGenericAdapter;
use Gibbon\Auth\Adapter\LDAPAdapter;
use Gibbon\Domain\System\LogGateway;
use League\Container\Exception\NotFoundException;

Expand Down Expand Up @@ -73,6 +74,9 @@
case 'mfa':
$authAdapter = $container->get(MFAAdapter::class);
break;
case 'ldap':
$authAdapter = $container->get(LDAPAdapter::class);
break;
default:
$authAdapter = $container->get(DefaultAdapter::class);
}
Expand Down Expand Up @@ -104,6 +108,7 @@
// Handle login
try {
$loginService = $authFactory->newLoginService($authAdapter);

$loginService->login($auth, [
'username' => $_POST['username'] ?? '',
'password' => $_POST['password'] ?? '',
Expand Down Expand Up @@ -179,6 +184,9 @@
} catch (Exception\MFATokenInvalid $e) {
header("Location: {$URL->withQueryParam('loginReturn', 'fail11')}");
exit;
} catch (Exception\LDAPBindFailed $e) {
header("Location: {$URL->withQueryParam('loginReturn', 'fail12')}");
exit;
} catch (Exception\MFATokenRequired $e) {
header("Location: {$URL->withQueryParam('method', 'mfa')}");
exit;
Expand Down
8 changes: 8 additions & 0 deletions modules/System Admin/thirdPartySettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
$settingGateway = $container->get(SettingGateway::class);
$ssoGoogle = json_decode($settingGateway->getSettingByScope('System Admin', 'ssoGoogle'), true);
$ssoMicrosoft = json_decode($settingGateway->getSettingByScope('System Admin', 'ssoMicrosoft'), true);
$ssoLDAP = json_decode($settingGateway->getSettingByScope('System Admin', 'ssoLDAP'), true);
$ssoOther = json_decode($settingGateway->getSettingByScope('System Admin', 'ssoOther'), true);

$ssoList = [
Expand All @@ -77,6 +78,13 @@
'url' => 'https://portal.azure.com',
'enabled' => $ssoMicrosoft['enabled'] ?? 'N',
],
[
'sso' => 'LDAP',
'name' => __('LDAP'),
'service' => __('Generic LDAP Connections'),
'url' => '',
'enabled' => $ssoLDAP['enabled'] ?? 'N',
],
[
'sso' => 'Other',
'name' => !empty($ssoOther['clientName']) ? $ssoOther['clientName'] : __('Other'),
Expand Down
16 changes: 16 additions & 0 deletions modules/System Admin/thirdPartySettings_ssoEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,22 @@
$row->addLabel('enabled', __('API Enabled'))->description(__('Enable Gibbon-wide integration with the Microsoft APIs?'));
$row->addYesNo('enabled')->required();

} else if ($sso == 'LDAP') {
// LDAP
$form->addRow()->addHeading('LDAP Integration', __('LDAP Integration'))->append(sprintf(__('todo: this')));

$row = $form->addRow();
$row->addLabel('enabled', __('API Enabled'))->description(__('Enable Gibbon-wide login integration with LDAP?'));
$row->addYesNo('enabled')->required();

$row = $form->addRow()->addClass('settingActive');
$row->addLabel('ldapServer', __('LDAP Server'));
$row->addTextField('ldapServer')->required();

$row = $form->addRow()->addClass('settingActive');
$row->addLabel('ldapDN', __('LDAP Distinguished Name (DN)'));
$row->addTextField('ldapDN')->required();

} else if ($sso == 'Other') {
$form->addRow()->addHeading('Generic OAuth2 Provider', __('Generic OAuth2 Provider'))->append(__('This setting offers a generic implementation of industry-standard OAuth2 protocols. It uses standard Client ID and Client Secret parameters to connect to an OAuth2 API server. You will need to specify the API endpoints of your chosen service, which can often be found in that service\'s documentation. If your OAuth2 service requires specific API parameters, this feature is unlikely to work.'));

Expand Down
4 changes: 3 additions & 1 deletion modules/System Admin/thirdPartySettings_ssoEditProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@
'authorizeEndpoint' => $_POST['authorizeEndpoint'] ?? '',
'tokenEndpoint' => $_POST['tokenEndpoint'] ?? '',
'userEndpoint' => $_POST['userEndpoint'] ?? '',
'ldapServer' => $_POST['ldapServer'] ?? '',
'ldapDN' => $_POST['ldapDN'] ?? ''
];

$calendarFeed = $_POST['calendarFeed'] ?? '';

if ($data['enabled'] == 'Y' && (empty($data['clientID']) || empty($data['clientSecret']))) {
if ($data['enabled'] == 'Y' && ((empty($data['clientID']) || empty($data['clientSecret'])) && ((empty($data['ldapServer']) || empty($data['ldapDN']))))) {
$URL .= '&return=error1';
header("Location: {$URL}");
exit;
Expand Down
94 changes: 94 additions & 0 deletions src/Auth/Adapter/LDAPAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Gibbon\Auth\Adapter;

use Gibbon\Http\Url;
use Gibbon\Auth\Exception;
use Gibbon\Auth\Adapter\AuthenticationAdapter;
use Gibbon\Contracts\Services\Session;
use Aura\Auth\Exception as AuraException;
use Gibbon\Domain\User\UserGateway;
use Aura\Auth\AuthFactory;

/**
* Generic OAuth2 adapter for Aura/Auth
*
* @version v23
* @since v23
*/
class LDAPAdapter extends AuthenticationAdapter
{
/**
* Constructor
*
*
*/
public function __construct()
{

}

/**
* Attempts to connect to the LDAP server using the provided credentials. Exceptions are thrown
* if any credentials are not valid.
*
* @param array $input Credential input.
*
* @return array An array of login data on success.
*
*
*
*
*/
public function login(array $input)
{
$this->userGateway = $this->getContainer()->get(UserGateway::class);

// Validate that the username and password are both present

$authFactory = $this->getAuthFactory();
$auth = $authFactory->newInstance();
$ldapAdapter = $authFactory->newLdapAdapter(
'ip address', //TODO: GET THESE FROM SETTINGS
'%s@'.'bind domain', //TODO: GET THESE FROM SETTINGS
[LDAP_OPT_PROTOCOL_VERSION => 3]
);
$loginService = $authFactory->newLoginService($ldapAdapter);
try {
$loginService->login($auth, array(
'username' => $input['username'],
'password' => $input['password']
));
} catch (AuraException\BindFailed $e) {
throw new Exception\LDAPBindFailed;
}

// Get basic user data needed to verify login access
$userData = $this->getUserData($input);
return parent::verifyLogin($userData);
}



private function getAuthFactory()
{
return $this->getContainer()->get(AuthFactory::class);
}
}
24 changes: 24 additions & 0 deletions src/Auth/Exception/LDAPBindFailed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/*
Gibbon, Flexible & Open School System
Copyright (C) 2010, Ross Parker

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

namespace Gibbon\Auth\Exception;

use Exception;

class LDAPBindFailed extends Exception {}