Single Sign-On

Single sign-on can occur for a service or server.
Whichever method being used, the return should be the same.
The return from either function should always be an array and contain two keys of a possible three.
  • status - This is a boolean value and should indicate success or failure
  • url - This should be a fully formatted URL return from your SSO request
  • message - Any appropriate error message to be displayed to whoever is making the request

Service Single Sign-On

Service single sign-on is to allow admin and client users to login to the control panel of the service automatically.
<?php
/**
 * Perform single sign-on for a given instance of a product/service.
 *
 * Called when single sign-on is requested for an instance of a product/service.
 *
 * When successful, returns an URL to which the user should be redirected.
 *
 * @param array $params common module parameters
 *
 * @see https://whasols.com/developers/guide/228-Module-Parameters
 *
 * @return array
 */
function yourmodule_ServiceSingleSignOn($params)
{
 try {    
      $server = $params['server'];
      $product = $params['product'];
      $username = $product['username'];
      $password = $product['password'];  
      //Your Code Perform Here
     return ["status"=>"success","message"=>"Your success message here","url"=>"Login URL Here"];
     or incase of error
     return ["status"=>"error","message"=>"Your error message here"];
  } catch (Exception $e) {
     return array('status'=>'error','message'=> $e->getMessage());
  }
    /**
     * Log any call to the server
     */
	logModule(
        'provisioningmodule',
        __FUNCTION__,
        $params,
        $response,
        $formattedResponse,
        array('username', 'password')
    );
}
In order to call your _ServiceSingleSignOn function from the Client Area, create a button or link that uses the following URL format:
/client/my-service/{$myservice.id}/sso
Replace $myservice.id with the ID of the client’s service that you wish to perform the single sign-on with.
The most common methods of displaying the link are; in the sidebar, or a button in the client area output of the module. The following resources go into further detail on how to use the WHASOLS hooks system or client area output in a module:
https://whasols.com/developers/guide/234-Client-Area-Output

Server Single Sign-On

Server single sign-on allows for Admin users to login to the associated server management panel (like WHM for cPanel) automatically.
<?php
/**
 * Perform single sign-on for a server.
 *
 * Called when single sign-on is requested for a server assigned to the module.
 *
 * This differs from ServiceSingleSignOn in that it relates to a server
 * instance within the admin area, as opposed to a single client instance of a
 * product/service.
 *
 * When successful, returns an URL to which the user should be redirected to.
 *
 * @param array $params common module parameters
 *
 * @see https://whasols.com/developers/guide/228-Module-Parameters
 *
 * @return array
 */
function yourmodule_AdminSingleSignOn($params)
{
 try {    
      $server = $params['server'];
      $product = $params['product'];
      $username = $product['username'];
      $password = $product['password'];  
      //Your Code Perform Here
     return ["status"=>"success","message"=>"Your success message here","url"=>"Login URL Here"];
     or incase of error
     return ["status"=>"error","message"=>"Your error message here"];
  } catch (Exception $e) {
     return array('status'=>'error','message'=> $e->getMessage());
  }
    /**
     * Log any call to the server
     */
	logModule(
        'provisioningmodule',
        __FUNCTION__,
        $params,
        $response,
        $formattedResponse,
        array('username', 'password')
    );
}