Plugin Directory

Changeset 2052662


Ignore:
Timestamp:
03/18/2019 01:23:23 PM (7 years ago)
Author:
SecSign
Message:

version 1.7.16

Location:
secsign/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • secsign/trunk/jsApi/SecSignIDApi.js

    r1892046 r2052662  
    2020        referer : 'SecSignIDApi_JS',
    2121        pluginname : 'SecSignIDApi_JS',
    22         version : "1.37",
     22        version : "1.40",
    2323        optionalparams : null
    2424    };
  • secsign/trunk/jsApi/phpApi/SecSignIDApi.php

    r1892046 r2052662  
    11<?php
    2    
     2
    33//
    44// SecSign ID Api in php.
    55//
    6 // (c) 2014-2017 SecSign Technologies Inc.
     6// (c) 2014-2019 SecSign Technologies Inc.
    77//
    8    
    9 define("SCRIPT_VERSION", '1.46');
    10      
    11          
     8
     9define("SCRIPT_VERSION", '1.48');
     10
     11
    1212/*
    1313* PHP class to connect to a secsign id server. the class will check secsign id server certificate and request for authentication session generation for a given
     
    2424        private $secSignIDServer_fallback = NULL;
    2525        private $secSignIDServerPort_fallback = NULL;
    26        
     26
    2727        // numeric script version.
    2828        private $scriptVersion  = 0;
    2929        private $referer        = NULL;
    3030        private $logger = NULL;
    31        
     31
    3232        private $pluginName = NULL;
     33        private $showAccesspass = NULL;
    3334        private $lastResponse = NULL;
    34        
    35        
     35
     36
    3637        /*
    3738         * Constructor
     
    4445            $this->secSignIDServer_fallback = (string) "https://httpapi2.secsign.com";
    4546            $this->secSignIDServerPort_fallback = (int) 443;
    46            
     47
    4748            // script version from cvs revision string
    4849            $this->scriptVersion = SCRIPT_VERSION;
    49            
    50             // use a constant string rather than using the __CLASS__ definition 
     50
     51            // use a constant string rather than using the __CLASS__ definition
    5152            // because this could cause problems when the class is in a submodule
    5253            $this->referer = "SecSignIDApi_PHP";
    5354        }
    54        
     55
    5556        /*
    5657         * Destructor
     
    6364            $this->secSignIDServerPort_fallback   = NULL;
    6465            $this->pluginName   = NULL;
    65             $this->scriptVersion = NULL;           
     66            $this->showAccesspass = NULL;
     67            $this->scriptVersion = NULL;
    6668            $this->logger = NULL;
    6769        }
    68        
     70
    6971        /**
    7072         * Function to check whether curl is available
     
    7577                return false;
    7678            }
    77            
     79
    7880            if(! function_exists("curl_exec")){
    7981                return false;
    8082            }
    81            
     83
    8284            if(! is_callable("curl_init", true, $callable_name)){
    8385                return false;
    8486            }
    85            
     87
    8688            if(! is_callable("curl_exec", true, $callable_name)){
    8789                return false;
    8890            }
    89            
     91
    9092            return true;
    9193        }
    92        
     94
    9395        /*
    9496         * Sets a function which is used as a logger
     
    9698        function setLogger($logger)
    9799        {
    98             if($logger != NULL && isset($logger) && is_callable($logger) == TRUE){
     100            if($logger !== NULL && isset($logger) && is_callable($logger) === TRUE){
    99101                $this->logger = $logger;
    100102            }
    101103        }
    102        
     104
    103105        /*
    104106         * logs a message if logger instance is not NULL
     
    106108        private function log($message)
    107109        {
    108             if($this->logger != NULL){
     110            if($this->logger !== NULL){
    109111                $logMessage = __CLASS__ . " (v" . $this->scriptVersion . "): " . $message;
    110112                call_user_func($this->logger, $logMessage);
    111113            }
    112114        }
    113        
     115
    114116        /*
    115117         * Sets an optional plugin name
     
    119121            $this->pluginName = $pluginName;
    120122        }
    121        
     123
     124        /*
     125         * Sets an optional parameter to determine if the accesspass should be used
     126         */
     127        function setShowAccesspass($showAccesspass)
     128        {
     129            $this->showAccesspass = $showAccesspass;
     130        }
     131
    122132        /*
    123133         * Gets last response
     
    127137            return $this->lastResponse;
    128138        }
    129        
    130        
     139
     140
    131141        /*
    132142         * Send query to secsign id server to create an authentication session for a certain secsign id. This method returns the authentication session itself.
     
    135145        {
    136146            $this->log("Call of function 'requestAuthSession'.");
    137            
     147
    138148            if(empty($servicename)){
    139149                $this->log("Parameter \$servicename must not be null.");
    140150                throw new Exception("Parameter \$servicename must not be null.");
    141151            }
    142            
     152
    143153            if(empty($serviceadress)){
    144154                $this->log("Parameter \$serviceadress must not be null.");
    145155                throw new Exception("Parameter \$serviceadress must not be null.");
    146156            }
    147            
     157
    148158            if(empty($secsignid)){
    149159                $this->log("Parameter \$secsignid must not be null.");
     
    153163            // secsign id is always key insensitive. comvert to lower case and trim whitespace
    154164            $secsignid = trim(strtolower($secsignid));
    155            
     165
    156166            // check again. probably just spacess which will ne empty after trim()
    157167            if(empty($secsignid)){
     
    164174                                      'servicename' => $servicename,
    165175                                      'serviceaddress' => $serviceadress);
    166                                      
    167             if($this->pluginName != NULL){
     176
     177            if($this->pluginName !== NULL){
    168178                $requestParameter['pluginname'] = $this->pluginName;
    169179            }
    170                                      
     180
     181            if($this->showAccesspass !== NULL){
     182                $requestParameter['showaccesspass'] = $this->showAccesspass;
     183            }
     184
    171185            $response = $this->send($requestParameter, NULL);
    172            
     186
    173187            $authSession = new AuthSession();
    174188            $authSession->CreateAuthSessionFromArray($response);
    175            
     189
    176190            return $authSession;
    177191        }
    178        
    179        
     192
     193
    180194        /*
    181195         * Gets the authentication session state for a certain secsign id whether the authentication session is still pending or it was accepted or denied.
     
    184198        {
    185199            $this->log("Call of function 'getAuthSessionState'.");
    186            
    187             if($authSession == NULL || !($authSession instanceof AuthSession)){
     200
     201            if($authSession === NULL || !($authSession instanceof AuthSession)){
    188202                $message = "Parameter \$authSession is not an instance of AuthSession. get_class(\$authSession)=" . get_class($authSession);
    189203                $this->log($message);
    190204                throw new Exception($message);
    191205            }
    192            
     206
    193207            $requestParameter = array('request' => 'ReqGetAuthSessionState');
    194208            $response = $this->send($requestParameter, $authSession);
    195            
     209
    196210            return $response['authsessionstate'];
    197211        }
    198        
    199        
     212
     213
    200214        /*
    201215         * Cancel the given auth session.
     
    204218        {
    205219            $this->log("Call of function 'cancelAuthSession'.");
    206            
    207             if($authSession == NULL || !($authSession instanceof AuthSession)){
     220
     221            if($authSession === NULL || !($authSession instanceof AuthSession)){
    208222                $message = "Parameter \$authSession is not an instance of AuthSession. get_class(\$authSession)=" . get_class($authSession);
    209223                $this->log($message);
    210224                throw new Exception($message);
    211             }     
    212            
     225            }
     226
    213227            $requestParameter = array('request' => 'ReqCancelAuthSession');
    214228            $response = $this->send($requestParameter, $authSession);
    215            
     229
    216230            return $response['authsessionstate'];
    217231        }
    218        
     232
    219233        /*
    220234         * build an array with all parameters which has to be send to server
     
    224238            //$mandatoryParams = array('apimethod' => $this->referer, 'scriptversion' => $this->scriptVersion);
    225239            $mandatoryParams = array('apimethod' => $this->referer);
    226            
     240
    227241            if(isset($authSession))
    228242            {
     
    231245                                         'authsessionid'  => $authSession->getAuthSessionID(),
    232246                                         'requestid' => $authSession->getRequestID());
    233                
     247
    234248                $mandatoryParams = array_merge($mandatoryParams, $authSessionData);
    235249            }
    236250            return array_merge($mandatoryParams, $parameter);
    237251        }
    238        
    239        
     252
     253
    240254        /*
    241255         * sends given parameters to secsign id server and wait given amount
     
    243257         */
    244258        function send($parameter, $authSession)
    245         {       
     259        {
    246260            $requestQuery = http_build_query($this->buildParameterArray($parameter, $authSession), '', '&');
    247261            $timeout_in_seconds = 15;
    248            
     262
    249263            // create cURL resource
    250264            $ch = $this->getCURLHandle($this->secSignIDServer, $this->secSignIDServerPort, $requestQuery, $timeout_in_seconds);
    251265            $this->log("curl_init: " . $ch);
    252            
     266
    253267            // $output contains the output string
    254268            $this->log("cURL curl_exec sent params: " . $requestQuery);
    255269            $output = curl_exec($ch);
    256             if ($output === false) 
     270            if ($output === false)
    257271            {
    258272                $this->log("curl_error: " . curl_error($ch));
     
    262276            $this->log("curl_close: " . $ch);
    263277            curl_close($ch);
    264            
     278
    265279            // check if output is NULL. in that case the secsign id might not have been reached.
    266             if($output == NULL)
     280            if($output === NULL)
    267281            {
    268282                $this->log("curl: output is NULL. Server " . $this->secSignIDServer . ":" . $this->secSignIDServerPort . " has not been reached.");
    269                
    270                 if($this->secSignIDServer_fallback != NULL)
     283
     284                if($this->secSignIDServer_fallback !== NULL)
    271285                {
    272286                    $this->log("curl: get new handle from fallback server.");
    273287                    $ch = $this->getCURLHandle($this->secSignIDServer_fallback, $this->secSignIDServerPort_fallback, $requestQuery, $timeout_in_seconds);
    274288                    $this->log("curl_init: " . $ch . " connecting to " . curl_getinfo($ch, CURLINFO_EFFECTIVE_URL));
    275                    
     289
    276290                    // $output contains the output string
    277291                    $output = curl_exec($ch);
    278                     if($output == NULL)
     292                    if($output === NULL)
    279293                    {
    280294                        $this->log("output is NULL. Fallback server " . $this->secSignIDServer_fallback . ":" . $this->secSignIDServerPort_fallback . " has not been reached.");
     
    282296                        throw new Exception("curl_exec error: can't connect to Server - " . curl_error($ch));
    283297                    }
    284                    
     298
    285299                    // close curl resource to free up system resources
    286300                    $this->log("curl_close: " . $ch);
    287301                    curl_close($ch);
    288                    
    289                 } 
    290                 else 
     302
     303                }
     304                else
    291305                {
    292306                    $this->log("curl: no fallback server has been specified.");
    293307                }
    294308            }
    295             $this->log("curl_exec response: " . ($output == NULL ? "NULL" : $output));
     309            $this->log("curl_exec response: " . ($output === NULL ? "NULL" : $output));
    296310            $this->lastResponse = $output;
    297            
     311
    298312            return $this->checkResponse($output, TRUE); // will throw an exception in case of an error
    299313        }
    300        
    301        
     314
     315
    302316        /*
    303317         * checks the secsign id server response string
     
    313327                }
    314328            }
    315            
     329
    316330            $responseArray = array();
    317            
     331
    318332            // server send parameter strings like:
    319333            // var1=value1&var2=value2&var3=value3&...
     
    322336            {
    323337                $exploded = explode("=", $pair, 2);
    324                 if (count($exploded) == 2)
     338                if (count($exploded) === 2)
    325339                {
    326340                    list($key, $value) = $exploded;
     
    328342                }
    329343            }
    330            
     344
    331345            // check if server send a parameter named 'error'
    332346            if(isset($responseArray['error']))
     
    340354            return $responseArray;
    341355        }
    342        
    343        
     356
     357
    344358        /*
    345359         * Gets a cURL resource handle.
     
    349363            // create cURL resource
    350364            $ch = curl_init();
    351            
     365
    352366            // set url
    353367            curl_setopt($ch, CURLOPT_URL, $server);
     
    355369            curl_setopt($ch, CURLOPT_PORT, $port);
    356370            //curl_setopt($ch, CURLOPT_SSLVERSION, 3);
    357            
     371
    358372            //return the transfer as a string
    359373            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    360             curl_setopt($ch, CURLOPT_HEADER, 0); // value 0 will strip header information in response 
    361            
     374            curl_setopt($ch, CURLOPT_HEADER, 0); // value 0 will strip header information in response
     375
    362376            // set connection timeout
    363377            curl_setopt($ch, CURLOPT_TIMEOUT, $timeout_in_seconds);
    364378            curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
    365            
     379
    366380            // make sure the common name of the certificate's subject matches the server's host name
    367381            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    368            
     382
    369383            // validate the certificate chain of the server
    370384            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    371            
     385
    372386            //The CA certificates
    373387            curl_setopt($ch, CURLOPT_CAINFO, realpath(dirname(__FILE__)) .'/curl-ca-bundle.crt');
    374            
     388
    375389            // add referer
    376             curl_setopt($ch, CURLOPT_REFERER, $this->referer); 
    377            
     390            curl_setopt($ch, CURLOPT_REFERER, $this->referer);
     391
    378392            // add all parameter and change request mode to POST
    379393            curl_setopt($ch, CURLOPT_POST, 2);
    380394            curl_setopt($ch, CURLOPT_POSTFIELDS, $parameter);
    381            
     395
    382396            return $ch;
    383397        }
     
    394408{
    395409        /*
    396          * No State: Used when the session state is undefined. 
     410         * No State: Used when the session state is undefined.
    397411         */
    398412        const NOSTATE = 0;
    399        
     413
    400414        /*
    401415         * Pending: The session is still pending for authentication.
    402416         */
    403417        const PENDING = 1;
    404        
     418
    405419        /*
    406420         * Expired: The authentication timeout has been exceeded.
    407421         */
    408422        const EXPIRED = 2;
    409        
     423
    410424        /*
    411425         * Authenticated: The user was successfully authenticated.
    412426         */
    413427        const AUTHENTICATED = 3;
    414        
     428
    415429        /*
    416430         * Denied: The user denied this session.
    417431         */
    418432        const DENIED = 4;
    419        
     433
    420434        /*
    421435         * Suspended: The server suspended this session, because another authentication request was received while this session was still pending.
    422436         */
    423437        const SUSPENDED = 5;
    424        
     438
    425439        /*
    426440         * Canceled: The service has canceled this session.
    427441         */
    428442        const CANCELED = 6;
    429        
     443
    430444        /*
    431445         * Fetched: The device has already fetched the session, but the session hasn't been authenticated or denied yet.
    432446         */
    433447        const FETCHED = 7;
    434    
     448
    435449        /*
    436450         * Invalid: This session has become invalid.
    437451         */
    438452        const INVALID = 8;
    439        
    440        
    441         /* 
     453
     454
     455        /*
    442456         * the secsign id the authentication session has been craeted for
    443457         */
    444458        private $secSignID      = NULL;
    445        
     459
    446460        /*
    447461         * authentication session id
    448462         */
    449463        private $authSessionID   = NULL;
    450        
     464
    451465        /*
    452466         * the name of the requesting service. this will be shown at the smartphone
    453467         */
    454468        private $requestingServiceName = NULL;
    455        
     469
    456470        /*
    457471         * the address, a valid url, of the requesting service. this will be shown at the smartphone
    458472         */
    459473        private $requestingServiceAddress = NULL;
    460        
    461         /*
    462          * the request ID is similar to a server side session ID. 
     474
     475        /*
     476         * the request ID is similar to a server side session ID.
    463477         * it is generated after a authentication session has been created. all other request like dispose, withdraw or to get the auth session state
    464478         * will be rejected if a request id is not specified.
    465479         */
    466480        private $requestID        = NULL;
    467        
     481
    468482        /*
    469483         * icon data of the so called access pass. the image data needs to be displayed otherwise the user does not know which access apss he needs to choose in order to accept the authentication session.
    470484         */
    471485        private $authSessionIconData = NULL;
    472        
    473        
     486
     487
    474488        /*
    475489         * Getter for secsign id
     
    479493            return $this->secSignID;
    480494        }
    481        
     495
    482496        /*
    483497         * Getter for auth session id
     
    487501            return $this->authSessionID;
    488502        }
    489        
     503
    490504        /*
    491505         * Getter for auth session requesting service
     
    495509            return $this->requestingServiceName;
    496510        }
    497        
     511
    498512        /*
    499513         * Getter for auth session requesting service
     
    503517            return $this->requestingServiceAddress;
    504518        }
    505        
     519
    506520        /*
    507521         * Getter for request id
     
    511525            return $this->requestID;
    512526        }
    513        
     527
    514528        /*
    515529         * Getter for icon data which needs to be display
     
    519533            return $this->authSessionIconData;
    520534        }
    521        
     535
    522536        /*
    523537         * method to get string representation of this authentication session object
     
    527541            return $this->authSessionID . " (" . $this->secSignID . ", " . $this->requestingServiceAddress . ", icondata=" . $this->authSessionIconData . ")";
    528542        }
    529        
     543
    530544        /*
    531545         * builds an url parameter string like key1=value1&key2=value2&foo=bar
     
    540554                         'requestid'     => $this->requestID);
    541555        }
    542        
    543        
     556
     557
    544558        /*
    545559         * Creates/Fills the auth session obejct using the given array. The array must use secsignid, auth session id etc as keys.
     
    550564                throw new Exception("Parameter array is NULL.");
    551565            }
    552            
     566
    553567            if(! is_array($array)){
    554568                throw new Exception("Parameter array is not an array. (array=" . $array . ")");
     
    571585                throw new Exception("Parameter array does not contain a value 'requestid'.");
    572586            }
    573            
     587
    574588            $this->secSignID                = $array['secsignid'];
    575589            $this->authSessionID            = $array['authsessionid'];
     
    577591            $this->requestingServiceAddress = $array['serviceaddress'];
    578592            $this->requestID                = $array['requestid'];
    579            
     593
    580594            // everything else must exist
    581595            if(isset($array['authsessionicondata'])){
     
    584598        }
    585599}
    586    
     600
    587601?>
  • secsign/trunk/readme.txt

    r1981260 r2052662  
    33Tags: two-factor authentication, two-factor, authentication, 2 factor authentication, login, sign in, single sign-on, challenge response, rsa, password, mobile, iphone, android, security, authenticator, authenticate, two step authentication, 2fa, tfa
    44Requires at least: 3.0.1
    5 Tested up to: 4.9.8
     5Tested up to: 5.1.1
    66Stable tag: trunk
    77License: GPLv2 or later
     
    1441444. The SecSign ID WordPress Plugin is now deactivated. Click on "Plugins" in the main menu, look for "SecSign" and activate it.
    1451455. Adjust options in the SecSign ID settings.
     146
     147= I get the error: The authentication server sent no response or you are not connected to the internet.
     148
     149The plugin needs to make a connection to https://httpapi.secsign.com to work correctly. This error means it can't connect to our server. There are some possible reasons for this:
     150
     1511. Please check if you have a firewall or router that might block the connection to httpapi.secsign.com on port 443.
     1522. Please check that the curl packet (http://php.net/manual/de/book.curl.php) is installed in your PHP installation. If this is not the case you should see a curl error about this in your webserver logs.
     1533. Please check if you have another wordpress plugin which might block the connection to our server. There are several wordpress security plugins doing this.
     154
     155If you can't find the reason please contact our support at support@secsign.com
    146156
    147157== Screenshots ==
     
    160170== Changelog ==
    161171
     172= 1.7.16 =
     173* Added new PHP API
     174* Added new JS API
     175* Added new FAQ entry for connection problems
     176* Tested WP compatibility for Wordpress 5.1.1
     177
     178Note: Due to changes at the javascript files, please flush the page cache or any other cache you are using to have the updated files within the browser.
     179
    162180= 1.7.15 =
    163181* Removed WP_DEBUG Notices
  • secsign/trunk/secsignid_login.php

    r1981260 r2052662  
    33Plugin Name: SecSign
    44Plugin URI: https://www.secsign.com/wordpress-tutorial/
    5 Version: 1.7.15
     5Version: 1.7.16
    66Description: Two-factor authentication (2FA) with the SecSign ID. The SecSign plugin allows a user to login using his SecSign ID and his smartphone.
    77Author: SecSign Technologies Inc.
Note: See TracChangeset for help on using the changeset viewer.