summaryrefslogtreecommitdiffstats
path: root/endpoints/lib/authinterface.php
blob: 2b42f9a94e2c642c0d696c2171fbc2e79ea0a315 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
 * Interface for phpVirtualBox authentication modules
 *
 * @author Ian Moore (imoore76 at yahoo dot com)
 * @copyright Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
 * @version $Id: authinterface.php 595 2015-04-17 09:50:36Z imoore76 $
 * @package phpVirtualBox
 * 
 * A class wishing to implement this interface must also contain
 * a list of capabilities describing its capabilities in a public
 * object member array called capabilities.
 * 
 * boolean canChangePassword - Users can change passwords
 * boolean canModifyUsers - Users can be modified
 * boolean canLogout - Users can log out
 * 	
 * E.g.
 * var $capabilities = array(
 *		'canChangePassword' => true,
 *		'canModifyUsers' => true,
 *		'canLogout' => true
 *	);
 *
 * The implementing class may also define a public autoLoginHook
 * method that auto-populates $_SESSION. This would automatically
 * log the user in, bypassing the login() function.
 * 
 * E.g.
 * 
 * 	function autoLoginHook()
 *	{
 *		global $_SESSION;
 *
 *		// HTTP Authentication passthrough
 *		if ( isset($_SERVER['HTTP_X_WEBAUTH_USER']) )
 *		{
 *			$_SESSION['valid'] = true;
 *			$_SESSION['user'] = $_SERVER['HTTP_X_WEBAUTH_USER']];
 *			$_SESSION['admin'] = ($_SESSION['user'] === 'bob');
 *			$_SESSION['authCheckHeartbeat'] = time();
 *		}
 *	}
 *
 * Implementing classes should be prefixed with phpvbAuth. E.g.
 * phpvbAuthMySiteAuth. authLib in config.php would then be set
 * to 'MySiteAuth'
 */
interface phpvbAuth {

	/**
	*
	* Log in function. Populates $_SESSION
	* @param string $username user name
	* @param string $password password
	*/
	function login($username, $password);
	
	/**
	*
	* Change password function.
	* @param string $old old password
	* @param string $new new password
	* @return boolean true on success
	*/
	function changePassword($old, $new);
	
	/**
	*
	* Revalidate login info and set authCheckHeartbeat session variable.
	* @param vboxconnector $vbox vboxconnector object instance
	*/
	function heartbeat($vbox);
	
	/**
	*
	* Log out user present in $_SESSION
	* @param array $response response passed byref by API and populated within function
	*/
	function logout(&$response);
	
	/**
	*
	* Return a list of users
	* @return array list of users
	*/
	function listUsers();
	
	/**
	*
	* Update user information such as password and admin status
	* @param array $vboxRequest request passed from API representing the ajax request. Contains user, password and administration level.
	* @param boolean $skipExistCheck Do not check that the user exists first. Essentially, if this is set and the user does not exist, it is added.
	*/
	function updateUser($vboxRequest, $skipExistCheck);
	
	
	/**
	*
	* Remove the user $user
	* @param string $user Username to remove
	*/
	function deleteUser($user);
	
	
	
}