HomeAdmin ManualAuthenticationBlack Box Portal Authentication (customer portal login)

3.7. Black Box Portal Authentication (customer portal 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

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.

 

Knowledge Tags

Downloads

This page was: Helpful | Not Helpful