Home → Admin Manual → Authentication → Black Box Portal Authentication (customer portal login)
3.8. Black Box Portal Authentication (customer portal login)
Updated: Jan 23 2025, 03:46 PM
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/BlackBoxPortal-base.php to authenticate the username and password passed to it against your own authentication system.
- Rename BlackBoxPortal-base.php to BlackBoxPortal.php
- Enable Black Box authentication in Admin->Settings->Portal->Request History Login Type
Customizing the BlackBox function
In the root of your installation there's a folder called /custom_code. Within that folder is the BlackBoxPortal-base.php file. This file contains the empty BlackBox function:
function BlackBoxPortal($username, $password){
/*
DO YOUR AUTHENTICATION HERE
Here's an example of how to return a valid user:
return "john.smith@company.com";
*/
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 BlackBoxPortal($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 email FROM users WHERE users = '$username' AND pass = '$password'", $dblink);
$num_rows = mysql_num_rows($result);
if(mysql_num_rows($result) == 1){
$row = mysql_fetch_assoc($result);
//An email must be returned
return $row['email'];
}else{
return false;
}
}
Returning an email will authenticate the user and show them any requests for that email, while false denies access.