Home → Admin Manual → Authentication → Black Box Authentication (agent login)
3.5. Black Box Authentication (agent login)
Black box authentication allows you to integrate your organizations authentication system with HelpSpot. Configuration requires only a few simple steps.
Summary: Steps to enable BlackBox Authentication
- Customize the BlackBox function in the file /custom_code/BlackBox-base.php to authenticate the username and password passed to it against your own authentication system.
- Rename BlackBox-base.php to BlackBox.php
- Confirm that your staff has the "Black Box Username" field set correctly in their accounts.
- Enable Black Box authentication in Admin->Settings
Customizing the BlackBox function
In the root of your installation there's a folder called /custom_code. Within that folder is the BlackBox-base.php file. This file contains the empty BlackBox function:
function BlackBox($username, $password){ /* DO YOUR AUTHENTICATION HERE */ return false; }
Customize this function to do authentication against your internal system by using the username and password provided. Here is an example of the function customized to authenticate against a MySQL database: (some security procedures left out for clarity)
function BlackBox($username, $password){ $dblink = mysql_connect('localhost', 'mysql_user', 'mysql_password'); mysql_select_db('database', $dblink); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $result = mysql_query("SELECT userid FROM users WHERE users = '$username' AND pass = '$password'", $dblink); $num_rows = mysql_num_rows($result); if($num_rows == 1){ return true; }else{ return false; } }
Returning true will authenticate the user, while false denies access. Note that even after you return true, HelpSpot looks up the username to make sure the username is that of a valid HelpSpot user. If you have not assigned the username to any of your staff then authentication will still fail.
Enabling Black Box Authentication
Before enabling check each account account that will be impacted by this authentication changes to make sure they have "black blox username" set. If they do not, they will not be able to login.
Enabling Black Box authentication is a two step process. First you must rename the BlackBox-base.php file to BlackBox.php. Second, you must change the authentication type to Black Box [Admin->Settings]. After changing the setting you will likely have to login again at which point the login box should say "username" instead of "email".
HelpSpot Password
HelpSpot still requires a password for all accounts even though it's not used for your custom authentication. This is because HelpSpot will attempt to login against it's own internal authentication when your custom authentication returns false. This allows users to get into HelpSpot even if the custom function is not working correctly using their HelpSpot email and password.