Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow token authorization instead of basic (requires WHM access) #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ronindesign
Copy link

@ronindesign ronindesign commented Dec 22, 2017

Authenticate and call install_ssl via WHM API instead of cPanel UAPI.
Requires WHM access, common for reseller accounts (not shared hosting)
Using a token is safer than basic authentication, allows access control, and revoke.
Ref: https://documentation.cpanel.net/display/SDK/Use+WHM+API+to+Call+cPanel+API+and+UAPI

@ronindesign ronindesign force-pushed the whm-token-authentication branch from 77f9dc8 to 50328d9 Compare December 22, 2017 12:51
@ronindesign ronindesign force-pushed the whm-token-authentication branch from 50328d9 to d95eb26 Compare December 22, 2017 13:02
@neurobin
Copy link
Owner

I think there's a problem here:

elseif (!$GLOBALS['token'] && !$response->status ) {
    $msg = json_encode($response);
    err("The CURL call returned valid JSON, but reported errors: $msg");
} elseif ( !$response->result->status ) {
    $msg = json_encode($response);
    err("The CURL call returned valid JSON, but reported errors: $msg");
}

when response is good, and the token method is not used, elseif ( !$response->result->status ) checks a condition on an invalid variable $response->result->status.

A solution may be this:

elseif (!$GLOBALS['token']){
    if(!$response->status ) {
        $msg = json_encode($response);
        err("The CURL call returned valid JSON, but reported errors: $msg");
    }
} elseif ( !$response->result->status ) {
    $msg = json_encode($response);
    err("The CURL call returned valid JSON, but reported errors: $msg");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants