cpanel-UAPI-php-class icon indicating copy to clipboard operation
cpanel-UAPI-php-class copied to clipboard

Is it possible to use WHM API Token instead of cPanel password to authenticate?

Open medusared opened this issue 7 years ago • 4 comments

medusared avatar Feb 15 '18 15:02 medusared

@medusared It currently doesn't but it has been on my list to work something out. I expect i need to split authentication into its own class as i have some more 2FA stuff to do anyway. Could do with throwing something into Composer too i expect.

Reopened this to mark as an enhancement - will remind me to look at it as soon as i can.

N1ghteyes avatar Feb 18 '18 13:02 N1ghteyes

Hey,

Did you ever get a chance to look into this?

Laim avatar Dec 29 '19 03:12 Laim

@Laim Honestly, no. I've been so busy with other bits and pieces that its just not happened.

If its something you can do and you would like to, i'm happy to accept pull requests etc, otherwise it'll get done when i have time but god knows when that will be!

N1ghteyes avatar Jan 02 '20 13:01 N1ghteyes

I have added it to my classes (might not be the best way but it works, hope it helps you too):

  1. Added a class variable called usecpaneltoken
  2. changed the construct to include a parameter to use cpanel tokens (the password then becomes the token)
  3. changed code in curl_request

In the class declaration: protected $usecpaneltoken = FALSE;

changed __construct: function __construct($user, $pass, $server, $secret = FALSE, $usecpaneltoken = FALSE) { $this->usecpaneltoken = $usecpaneltoken;

in function curl_request if($this->usecpaneltoken) { $httpHeaders = array("Authorization: cpanel " . base64_decode($this->auth)); } else { $httpHeaders = array("Authorization: Basic " . $this->auth); }

ParkyZAF avatar Oct 31 '22 11:10 ParkyZAF