. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
| Server IP : 94.23.64.18 / Your IP :
216.73.216.185 [
Web Server : Apache System : Linux webm005.cluster107.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : villadal ( 6036) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/villadal/www/old/booked/plugins/Authentication/Shibboleth/ |
Upload File : |
<?php
/**
* @file Shibboleth.php
*/
require_once ROOT_DIR . 'lib/Application/Authentication/namespace.php';
require_once ROOT_DIR . 'plugins/Authentication/Shibboleth/namespace.php';
/**
* Shibboleth implementation of Booked Scheduler's authentication interface.
* Supports auto-account provisioning on first-time login.
*
* @see IAuthorization
* @see Authentication
*/
class Shibboleth extends Authentication {
/**
* @var IAuthentication
*/
protected $authToDecorate;
/**
* @var Registration
*/
protected $_registration;
/**
* @var ShibbolethUser
*/
protected $_user;
/**
* @var ShibbolethOptions
*/
protected $_config;
/**
* Constructor.
*
* @param IAuthentication $authentication Authentication class to decorate.
*/
public function __construct(IAuthentication $authentication) {
$this->authToDecorate = $authentication;
}
/*
* @overrides Authentication::Validate()
*/
public function Validate($username, $password) {
$user = $this->GetShibbolethUser();
$uid = $user->GetUsername();
if (! empty($uid)) {
return true;
}
return false;
}
/*
* @overrides Authentication::Login()
*/
public function Login($username, $loginContext) {
$user = $this->GetShibbolethUser();
$registration = $this->GetRegistration();
// auto-provision new user accounts
// or update existing user accounts with the attributes passed in from shibboleth
$registration->Synchronize(
new AuthenticatedUser(
$user->GetUsername(),
$user->GetEmailAddress(),
$user->GetFirstName(),
$user->GetLastName(),
null,
Configuration::Instance()->GetKey(ConfigKeys::LANGUAGE),
Configuration::Instance()->GetDefaultTimezone(),
$user->GetPhone(), null, null
)
);
return $this->authToDecorate->Login($user->GetUsername(), $loginContext);
}
/*
* @overrides Authentication::Logout()
*/
public function Logout (UserSession $user) {
$this->authToDecorate->Logout($user);
}
/*
* @override Authentication::Logout()
*/
public function AreCredentialsKnown () {
return false;
}
/*
* @overrides Authentication::ShowUsernamePrompt()
*/
public function ShowUsernamePrompt () {
return false;
}
/*
* @overrides Authentication::ShowPasswordPrompt()
*/
public function ShowPasswordPrompt () {
return false;
}
/*
* @overrides Authentication::ShowPersistLoginPrompt
*/
public function ShowPersistLoginPrompt () {
return false;
}
/*
* @return Authentication::ShowForgotPasswordPrompt
*/
public function ShowForgotPasswordPrompt () {
return false;
}
/*
* @overrides Authentication::HandleLoginFailure
*/
public function HandleLoginFailure (IAuthenticationPage $loginPage) {
// not implemented
}
/**
* Retrieves the registration instance.
*
* @return Registration
*/
protected function GetRegistration () {
if (! isset($this->_registration)) {
$this->_registration = new Registration();
}
return $this->_registration;
}
/**
* Retrieves the plugin runtime configuration.
*
* @return ShibbolethOptions
*/
protected function GetConfiguration () {
if (! isset($this->_config)) {
$this->_config = new ShibbolethOptions();
}
return $this->_config;
}
/**
* Retrieves the external user representation.
*
* @return ShibbolethUser
*/
protected function GetShibbolethUser () {
if (! isset($this->_user)) {
// user attributes are passed in the global $_SERVER array, get them from there.
$config = $this->GetConfiguration();
$this->_user = new ShibbolethUser($_SERVER, $config);
}
return $this->_user;
}
}