You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2016/03/11 08:00:36 UTC

[20/21] airavata-php-gateway git commit: fixing captcha issues to work with IS 5.1.0

fixing captcha issues to work with IS 5.1.0


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/09a65f9c
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/09a65f9c
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/09a65f9c

Branch: refs/heads/master
Commit: 09a65f9c9f86e5e8c08951a5a3e5e21e73239779
Parents: f56256d
Author: scnakandala <su...@gmail.com>
Authored: Fri Mar 11 01:20:09 2016 -0500
Committer: scnakandala <su...@gmail.com>
Committed: Fri Mar 11 01:20:09 2016 -0500

----------------------------------------------------------------------
 app/config/pga_config.php.template              |  6 ++--
 app/controllers/AccountController.php           | 38 ++++----------------
 .../Stubs/UserInformationRecoveryManager.php    |  7 +++-
 app/libraries/Wsis/Wsis.php                     |  4 +--
 app/views/account/forgot-password.blade.php     | 16 +++++++--
 app/views/account/verify-human.blade.php        | 12 +++----
 6 files changed, 38 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/09a65f9c/app/config/pga_config.php.template
----------------------------------------------------------------------
diff --git a/app/config/pga_config.php.template b/app/config/pga_config.php.template
index 8a65ce5..411a6d7 100644
--- a/app/config/pga_config.php.template
+++ b/app/config/pga_config.php.template
@@ -41,12 +41,12 @@ return array(
         /**
          * OAuth client key
          */
-        'oauth-client-key' => 'iGEREhSBLuGapdcXwMU0b8jEpA4a',
+        'oauth-client-key' => '5_GFR88Nzd4XvGthSMF1fnOJPuMa',
 
         /**
          * OAuth client secret
          */
-        'oauth-client-secret' => 'g4Lgp05JIJcNQryJkNKjXJYi8A8a',
+        'oauth-client-secret' => 'KNTf_LPLuGBDbRVZwkrP_fF5z2Ea',
 
         /**
          * Identity server domain
@@ -56,7 +56,7 @@ return array(
         /**
          * Identity server url
          */
-        'service-url' => 'https://idp.scigap.org:7443/',
+        'service-url' => 'https://idp.scigap.org:9443/',
 
         /**
          * Enable HTTPS server verification

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/09a65f9c/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 0205d58..199c773 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -242,7 +242,9 @@ class AccountController extends BaseController
 
     public function forgotPassword()
     {
-        return View::make("account/forgot-password");
+        $capatcha = WSIS::getCapatcha()->return;
+        return View::make("account/forgot-password", array("imagePath"=>$capatcha->imagePath, "secretKey"=>$capatcha->secretKey,
+                "imageUrl"=> Config::get("pga_config.wsis")["service-url"] . $capatcha->imagePath));
     }
 
     public function forgotPasswordSubmit()
@@ -258,7 +260,7 @@ class AccountController extends BaseController
             else
                 $username = $username . "@" . $wsisConfig['tenant-domain'];
             try{
-                $key = WSIS::validateUser($username);
+                $key = WSIS::validateUser(Input::get("userAnswer"),Input::get("imagePath"),Input::get("secretKey"), $username);
                 if(!empty($key)){
                     $result = WSIS::sendPasswordResetNotification($username, $key);
                     if($result===true){
@@ -331,43 +333,17 @@ class AccountController extends BaseController
                     }
                 }else{
                     $capatcha = WSIS::getCapatcha()->return;
-                    //hack to work with wso2 IS 5.0.0
-                    if (is_array(getimagesize(Config::get('pga_config.wsis')['service-url'] . $capatcha->imagePath))){
-                        return View::make("account/verify-human", array("username"=>$username,"code"=>$confirmation,
-                            "imagePath"=>$capatcha->imagePath, "secretKey"=>$capatcha->secretKey,
-                            "imageUrl"=> Config::get("pga_config.wsis")["service-url"] . $capatcha->imagePath));
-                    }else{
-                        WSIS::confirmUserRegistration("123", $capatcha->imagePath,
-                            $capatcha->secretKey, $username, $confirmation, Config::get('pga_config.wsis')['tenant-domain']);
-                        return Redirect::to("login");
-                    }
+                    return View::make("account/verify-human", array("username"=>$username,"code"=>$confirmation,
+                        "imagePath"=>$capatcha->imagePath, "secretKey"=>$capatcha->secretKey,
+                        "imageUrl"=> Config::get("pga_config.wsis")["service-url"] . $capatcha->imagePath));
                 }
             }catch (Exception $e){
-                var_dump($e);exit;
                 CommonUtilities::print_error_message("Account confirmation failed!");
                 return View::make("home");
             }
         }
     }
 
-    private function checkRemoteFile($url)
-    {
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_URL,$url);
-        // don't download content
-        curl_setopt($ch, CURLOPT_NOBODY, 1);
-        curl_setopt($ch, CURLOPT_FAILONERROR, 1);
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-        if(curl_exec($ch)!==FALSE)
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-
     private function sendAccountCreationNotification2Admin($username){
 
         $mail = new PHPMailer;

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/09a65f9c/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php b/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php
index 49490aa..f5535e1 100755
--- a/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php
+++ b/app/libraries/Wsis/Stubs/UserInformationRecoveryManager.php
@@ -36,9 +36,14 @@ class UserInformationRecoveryManager {
      * Method to validate username and get key which is to be used for the next call
      * @param $username
      */
-    public function validateUsername($username){
+    public function validateUsername($userAnswer, $imagePath, $secretKey, $username){
         $verifyUser = new verifyUser();
         $verifyUser->username = $username;
+        $captcha = new CaptchaInfoBean();
+        $captcha->userAnswer = $userAnswer;
+        $captcha->imagePath = $imagePath;
+        $captcha->secretKey = $secretKey;
+        $verifyUser->captcha = $captcha;
         $result = $this->serviceStub->verifyUser($verifyUser);
         if($result->return->verified){
             return $result->return->key;

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/09a65f9c/app/libraries/Wsis/Wsis.php
----------------------------------------------------------------------
diff --git a/app/libraries/Wsis/Wsis.php b/app/libraries/Wsis/Wsis.php
index 0573dcd..faba4e1 100755
--- a/app/libraries/Wsis/Wsis.php
+++ b/app/libraries/Wsis/Wsis.php
@@ -462,8 +462,8 @@ class Wsis {
      * Method to validate username
      * @param $username
      */
-    public function validateUser($username){
-        return $this->userInfoRecoveryManager->validateUsername($username);
+    public function validateUser($userAnswer, $imagePath, $secretKey, $username){
+        return $this->userInfoRecoveryManager->validateUsername($userAnswer, $imagePath, $secretKey, $username);
     }
 
 

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/09a65f9c/app/views/account/forgot-password.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/forgot-password.blade.php b/app/views/account/forgot-password.blade.php
index 8935035..f0fbfc4 100644
--- a/app/views/account/forgot-password.blade.php
+++ b/app/views/account/forgot-password.blade.php
@@ -12,8 +12,20 @@
     <h4> Please enter your username, you registered with.</h4>
     <form role="form" method="POST" action="{{ URL::to('/') }}/forgot-password">
         <div class="form-group form-horizontal">
-            <div class="col-md-8"><input name="username" type="username" value="" class="form-control" placeholder="username" required/></div>
-            <div class="col-md-2"><input type="submit" class="form-control btn btn-primary" value="Submit"/></div>
+            <img src="{{$imageUrl}}"/>
+            <div>
+                <input name="imagePath" type="hidden" value="{{$imagePath}}" class="form-control"/>
+                <input name="secretKey" type="hidden" value="{{$secretKey}}" class="form-control"/>
+                <br/>
+                <input class="form-control" id="userAnswer" name="userAnswer" placeholder="captcha text" required="required"/>
+                <br/>
+                <input name="username" type="username" value="" class="form-control" placeholder="username" required/>
+            </div>
+        </div>
+        <div class="form-group btn-toolbar">
+            <div class="btn-group">
+                <input type="submit" class="form-control btn btn-primary" value="Submit"/>
+            </div>
         </div>
     </form>
     @stop
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/09a65f9c/app/views/account/verify-human.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/verify-human.blade.php b/app/views/account/verify-human.blade.php
index 7c9ce1f..0ddc92f 100644
--- a/app/views/account/verify-human.blade.php
+++ b/app/views/account/verify-human.blade.php
@@ -23,14 +23,14 @@
                 <input name="username" type="hidden" value="{{$username}}" class="form-control"/>
                 <input name="imagePath" type="hidden" value="{{$imagePath}}" class="form-control"/>
                 <input name="secretKey" type="hidden" value="{{$secretKey}}" class="form-control"/>
-                <input class="form-control" id="userAnswer" name="userAnswer" required="required"/></div>
+                <input class="form-control" id="userAnswer" name="userAnswer" required="required"/>
             </div>
-            <div class="form-group btn-toolbar">
-                <div class="btn-group">
-                    <input type="submit" class="form-control btn btn-primary" value="Submit"/>
-                </div>
+        </div>
+        <div class="form-group btn-toolbar">
+            <div class="btn-group">
+                <input type="submit" class="form-control btn btn-primary" value="Submit"/>
             </div>
-
         </div>
     </form>
+</div>
 @stop
\ No newline at end of file