1 year ago

Authentication External API as a middleware

Posted 1 year ago by Ap3twe

Hey, I want to authenticate users with external API before allowing the request to go through the laravel auth. Users are stored in our CPM system and we want to limit other users from logging into our app. The API is written in WSDL. An example was provided with soap. How do I implement it laravel?

function _getCustomerInfo($user,$pass){
        /* Initialize webservice with your WSDL */
        $client = new SoapClient("https://bbcpfhs.example.com:099/Token.asmx?WSDL");
        $params = array(
            'APIUserID' => '{id}',
            'APIPassword' => '{password}',
            'webUsername' => $user,
            'webPassword' => $pass,
        try {
            $responsetest = $client->getCustomerInfo($params);
        } catch(SoapFault $fault) {
            return False;
         $_SESSION['customer_info'] = $responsetest;
        return True;

Please sign in or create an account to participate in this conversation.