Integrating cPanel Login to external PHP System

Status
Not open for further replies.

gmorande

Registered
Jan 25, 2007
1
0
151
Hello,

We're working on a billing system on PHP that we want to integrate with Cpanel Login.
Common login forms using server:port/login/?user=USER&pass=PSWD are really not secure since all the login info stays on the cache.

I read that Cpanel release a perl module to work around: Logmein.pm but I don't know how to access it via a PHP file.

You'll need to download the module from the link above to /usr/local/cpanel/Cpanel/LogmeIn.pm

Then you can interact through the module with your login script. Something like this:

Code:
#!/usr/bin/perl

use lib '/usr/local/cpanel';
use Cpanel::LogMeIn ();

my $user = '__USERNAME__'; #or lookup from your records
my $pass = '__PASSWORD__'; #or lookup from your records
my $host = '__HOSTNAME__'; #or lookup from your records
my $service = 'cpanel'; #or whm or webmail to access those interfaces

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);




This script above will output a secure URL that can be used only once to login. If you're looking for a login form instead, you can use this example: SampleBrandedLogin < AllDocumentation < TWiki

Can someone help me out with this?
Maybe with a sample PHP script that invokes that pm?

Thanks a lot!
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,258
463
Status
Not open for further replies.