Secure Remote Logins
In order to provide hosts with a simple way to allow users to remotely login to a cPanel machine, we've created a module to allow for remote logins. This module queries the cPanel server for a URL that allows access to cPanel, WHM or Webmail (depending on the request). This URL is good for a single use and the session is destroyed as soon as the URL is accessed.
Integrating cPanel Logins with other Software
You may wish to provide a unified experience for customers by having them sign into your customer area and then simply handing them off to other systems, such as their cPanel interface. To do so, you can pull their login information from your records and then use cPanel::LogMeIn::get_loggedin_url() to get a URL to hand off to their browser which will give them access to cPanel, WHM or Webmail.
#!/usr/bin/perl
use lib '/usr/local/cpanel';
use Cpanel::LogMeIn ();
my $user =
USERNAME; #cPanel, WHM, or Webmail username being pulled from a database
my $pass =
PASSWORD; #cPanel, WHM, or Webmail password being pulled from a database
my $host =
DOMAIN; #Domain name associated with the cPanel, WHM or webmail account being pulled from a database
my $service = 'cpanel'; #The service we want to login to (cpanel or whm or webmail)
my($login_ok,$login_message,$login_url) = Cpanel::LogMeIn::get_loggedin_url(
'user'=>$user,'pass'=>$pass,'hostname'=>$host,'service'=>$service,'goto_uri'=>'/'
);
if ($login_ok) {
print "Location: $login_url\r\n\r\n";
} else {
print "Content-type: text/plain\r\n\r\n";
print "LOGIN FAILED: $login_message\n";
}
exit (0);
After we retrieve their username, password and domain name for our database, we hand them off to Cpanel::LogMeIn::get_loggedin_url() which returns the URL that is good for a single use. then, we print that URL as the location in their browser which will take them to the URL.