diff options
author | Tudor Holton <tudor@tudorholton.com> | 2018-07-13 17:44:24 +1000 |
---|---|---|
committer | Tudor Holton <tudor@tudorholton.com> | 2018-07-13 17:44:24 +1000 |
commit | 81e287733d904e8f8fce1c91e42cf2933007c9cc (patch) | |
tree | 01146078eecd1a0fc610ae225192debed7925999 /endpoints/lib/auth/OpenMediaVault.php | |
parent | f3e62d8bce52f392b4faed4792e6e112d1777757 (diff) | |
parent | 3c61d5eae51e27082945f629d0076edf0c309f96 (diff) | |
download | phpvirtualbox-81e287733d904e8f8fce1c91e42cf2933007c9cc.zip phpvirtualbox-81e287733d904e8f8fce1c91e42cf2933007c9cc.tar.gz phpvirtualbox-81e287733d904e8f8fce1c91e42cf2933007c9cc.tar.bz2 |
Ready for release 5.2-1
Diffstat (limited to 'endpoints/lib/auth/OpenMediaVault.php')
-rw-r--r-- | endpoints/lib/auth/OpenMediaVault.php | 230 |
1 files changed, 115 insertions, 115 deletions
diff --git a/endpoints/lib/auth/OpenMediaVault.php b/endpoints/lib/auth/OpenMediaVault.php index 71b3d02..991ca3f 100644 --- a/endpoints/lib/auth/OpenMediaVault.php +++ b/endpoints/lib/auth/OpenMediaVault.php @@ -1,115 +1,115 @@ -<?php
-/*
- * $Id: OpenMediaVault.php 470 2012-10-24 21:43:25Z imooreyahoo@gmail.com $
-*/
-
-/*
- * OMV Specific
-*/
-try {
-
- // Must be made global or OMV breaks
- global $xmlConfig, $OMV_DEFAULT_FILE;
-
- require_once("openmediavault/globals.inc");
- require_once("openmediavault/session.inc");
- require_once("rpc/authentication.inc");
-
-} catch(Exception $e) {
-
- header("Content-Type: text/html");
- die("Error #".$e->getCode().":<br/>". str_replace("\n", "<br/>",$e->__toString()));
-}
-
-class phpvbAuthOpenMediaVault implements phpvbAuth {
-
- static $session = null;
-
- var $capabilities = array(
- 'canChangePassword' => false,
- 'sessionStart' => 'sessionStart',
- 'canLogout' => true
- );
-
- var $config = array(
- 'allowNonAdmin' => false
- );
-
- function __construct($userConfig = null) {
- if($userConfig) $this->config = array_merge($this->config,$userConfig);
- }
-
- function login($username, $password)
- {
- # Try / catch so that we don't expose
- # usernames / passwords
- require_once("rpc/authentication.inc");
- $a = new AuthenticationRpc();
- try {
-
- $auth = $a->login(array('username'=>$username,'password'=>$password));
-
- self::$session = &OMVSession::getInstance();
-
- if(@$auth["authenticated"] &&
- (self::$session->getRole() !== OMV_ROLE_USER || $this->config['allowNonAdmin'])) {
- $_SESSION['admin'] = (self::$session->getRole() !== OMV_ROLE_USER);
- $_SESSION['user'] = $_SESSION['username'];
- $_SESSION['valid'] = ($_SESSION['admin'] || $this->config['allowNonAdmin']);
- $_SESSION['authCheckHeartbeat'] = time();
-
- }
-
- if(!@$_SESSION['valid']) {
- return false;
- }
- return true;
-
- } catch (Exception $e) {
- return false;
- }
- return false;
- }
-
- function sessionStart($keepopen) {
-
- self::$session = &OMVSession::getInstance();
- self::$session->start();
-
-
- if (self::$session->isAuthenticated() && !self::$session->isTimeout()) {
-
- self::$session->validate();
- self::$session->updateLastAccess();
-
- $_SESSION['admin'] = (self::$session->getRole() !== OMV_ROLE_USER);
- $_SESSION['user'] = $_SESSION['username'];
- $_SESSION['valid'] = (self::$session->getRole() !== OMV_ROLE_USER || $this->config['allowNonAdmin']);
-
- } else {
-
- $_SESSION['admin'] = $_SESSION['user'] = $_SESSION['valid'] = null;
-
- }
-
- if(!$keepopen)
- session_write_close();
-
- }
-
-
- function logout(&$response)
- {
- require_once("rpc/authentication.inc");
- $a = new AuthenticationRpc();
- $a->logout();
- $response['data']['result'] = 1;
- }
-
- /* Defined for compatibility with implemented interface */
- function heartbeat($vbox){}
- function changePassword($old, $new){}
- function listUsers(){}
- function updateUser($vboxRequest, $skipExistCheck){}
- function deleteUser($user){}
-}
+<?php +/* + * $Id: OpenMediaVault.php 470 2012-10-24 21:43:25Z imooreyahoo@gmail.com $ +*/ + +/* + * OMV Specific +*/ +try { + + // Must be made global or OMV breaks + global $xmlConfig, $OMV_DEFAULT_FILE; + + require_once("openmediavault/globals.inc"); + require_once("openmediavault/session.inc"); + require_once("rpc/authentication.inc"); + +} catch(Exception $e) { + + header("Content-Type: text/html"); + die("Error #".$e->getCode().":<br/>". str_replace("\n", "<br/>",$e->__toString())); +} + +class phpvbAuthOpenMediaVault implements phpvbAuth { + + static $session = null; + + var $capabilities = array( + 'canChangePassword' => false, + 'sessionStart' => 'sessionStart', + 'canLogout' => true + ); + + var $config = array( + 'allowNonAdmin' => false + ); + + function __construct($userConfig = null) { + if($userConfig) $this->config = array_merge($this->config,$userConfig); + } + + function login($username, $password) + { + # Try / catch so that we don't expose + # usernames / passwords + require_once("rpc/authentication.inc"); + $a = new AuthenticationRpc(); + try { + + $auth = $a->login(array('username'=>$username,'password'=>$password)); + + self::$session = &OMVSession::getInstance(); + + if(@$auth["authenticated"] && + (self::$session->getRole() !== OMV_ROLE_USER || $this->config['allowNonAdmin'])) { + $_SESSION['admin'] = (self::$session->getRole() !== OMV_ROLE_USER); + $_SESSION['user'] = $_SESSION['username']; + $_SESSION['valid'] = ($_SESSION['admin'] || $this->config['allowNonAdmin']); + $_SESSION['authCheckHeartbeat'] = time(); + + } + + if(!@$_SESSION['valid']) { + return false; + } + return true; + + } catch (Exception $e) { + return false; + } + return false; + } + + function sessionStart($keepopen) { + + self::$session = &OMVSession::getInstance(); + self::$session->start(); + + + if (self::$session->isAuthenticated() && !self::$session->isTimeout()) { + + self::$session->validate(); + self::$session->updateLastAccess(); + + $_SESSION['admin'] = (self::$session->getRole() !== OMV_ROLE_USER); + $_SESSION['user'] = $_SESSION['username']; + $_SESSION['valid'] = (self::$session->getRole() !== OMV_ROLE_USER || $this->config['allowNonAdmin']); + + } else { + + $_SESSION['admin'] = $_SESSION['user'] = $_SESSION['valid'] = null; + + } + + if(!$keepopen) + session_write_close(); + + } + + + function logout(&$response) + { + require_once("rpc/authentication.inc"); + $a = new AuthenticationRpc(); + $a->logout(); + $response['data']['result'] = 1; + } + + /* Defined for compatibility with implemented interface */ + function heartbeat($vbox){} + function changePassword($old, $new){} + function listUsers(){} + function updateUser($vboxRequest, $skipExistCheck){} + function deleteUser($user){} +} |