Secure Remote Logins

In order to provide hosts with a simple way to allow users to remotely log into a cPanel machine, we've created a module that will create a unique URL to allow users to log in remotely. 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

If you want to provide a unified experience to your customers, you can have them sign into your customer area and then access cPanel, WHM, or their webmail. To do so, you can pass their login information to cPanel::LogMeIn::get_loggedin_url(). This module will create a unique, single-use URL that will allow visitors to access their cPanel, WHM, or webmail interfaces.

The following is an example of how you can call cPanel::LogMeIn::get_loggedin_url():

#!/usr/bin/perl
use lib '/usr/local/cpanel';
use Cpanel::LogMeIn ();

my $user =
  USERNAME;    #cPanel, WHM, or Webmail username entered at login
my $pass =
  PASSWORD;    #cPanel, WHM, or Webmail password entered at login
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";
}

In the example above, the username, password, and domain are handed off to cPanel::LogMeIn::get_loggedin_url(). This module then returns the URL.

Topic revision: r5 - 03 Jan 2011 - 20:50:08 - Main.MelanieSeibert