You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/06/11 18:30:53 UTC

[airavata-php-gateway] branch develop updated (0988d03 -> 1cd8859)

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-php-gateway.git.


    from 0988d03  Merge branch 'handle-deleted-files' into develop
     new 59910b6  Regenerate Thrift stubs
     new 619dade  Check if user is enabled first before verifying/resending verification email
     new 1cd8859  Merge branch 'check-if-user-enabled' into develop

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 app/controllers/AccountController.php              |  41 +--
 .../Iam/Admin/Services/CPI/IamAdminServices.php    | 294 +++++++++++++++++++++
 app/libraries/IamAdminServicesUtilities.php        |   5 +
 3 files changed, 322 insertions(+), 18 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

[airavata-php-gateway] 01/03: Regenerate Thrift stubs

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-php-gateway.git

commit 59910b6aefe6825967016211f9d1b96c37979ece
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Mon Jun 11 14:23:07 2018 -0400

    Regenerate Thrift stubs
---
 .../Iam/Admin/Services/CPI/IamAdminServices.php    | 294 +++++++++++++++++++++
 1 file changed, 294 insertions(+)

diff --git a/app/libraries/Airavata/Service/Iam/Admin/Services/CPI/IamAdminServices.php b/app/libraries/Airavata/Service/Iam/Admin/Services/CPI/IamAdminServices.php
index 963fc80..0393df3 100644
--- a/app/libraries/Airavata/Service/Iam/Admin/Services/CPI/IamAdminServices.php
+++ b/app/libraries/Airavata/Service/Iam/Admin/Services/CPI/IamAdminServices.php
@@ -55,6 +55,14 @@ interface IamAdminServicesIf {
   /**
    * @param \Airavata\Model\Security\AuthzToken $authzToken
    * @param string $username
+   * @return bool
+   * @throws \Airavata\Service\Iam\Admin\Services\CPI\Error\IamAdminServicesException
+   * @throws \Airavata\API\Error\AuthorizationException
+   */
+  public function isUserEnabled(\Airavata\Model\Security\AuthzToken $authzToken, $username);
+  /**
+   * @param \Airavata\Model\Security\AuthzToken $authzToken
+   * @param string $username
    * @param string $newPassword
    * @return bool
    * @throws \Airavata\Service\Iam\Admin\Services\CPI\Error\IamAdminServicesException
@@ -351,6 +359,64 @@ class IamAdminServicesClient implements \Airavata\Service\Iam\Admin\Services\CPI
     throw new \Exception("enableUser failed: unknown result");
   }
 
+  public function isUserEnabled(\Airavata\Model\Security\AuthzToken $authzToken, $username)
+  {
+    $this->send_isUserEnabled($authzToken, $username);
+    return $this->recv_isUserEnabled();
+  }
+
+  public function send_isUserEnabled(\Airavata\Model\Security\AuthzToken $authzToken, $username)
+  {
+    $args = new \Airavata\Service\Iam\Admin\Services\CPI\IamAdminServices_isUserEnabled_args();
+    $args->authzToken = $authzToken;
+    $args->username = $username;
+    $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary');
+    if ($bin_accel)
+    {
+      thrift_protocol_write_binary($this->output_, 'isUserEnabled', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite());
+    }
+    else
+    {
+      $this->output_->writeMessageBegin('isUserEnabled', TMessageType::CALL, $this->seqid_);
+      $args->write($this->output_);
+      $this->output_->writeMessageEnd();
+      $this->output_->getTransport()->flush();
+    }
+  }
+
+  public function recv_isUserEnabled()
+  {
+    $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary');
+    if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Airavata\Service\Iam\Admin\Services\CPI\IamAdminServices_isUserEnabled_result', $this->input_->isStrictRead());
+    else
+    {
+      $rseqid = 0;
+      $fname = null;
+      $mtype = 0;
+
+      $this->input_->readMessageBegin($fname, $mtype, $rseqid);
+      if ($mtype == TMessageType::EXCEPTION) {
+        $x = new TApplicationException();
+        $x->read($this->input_);
+        $this->input_->readMessageEnd();
+        throw $x;
+      }
+      $result = new \Airavata\Service\Iam\Admin\Services\CPI\IamAdminServices_isUserEnabled_result();
+      $result->read($this->input_);
+      $this->input_->readMessageEnd();
+    }
+    if ($result->success !== null) {
+      return $result->success;
+    }
+    if ($result->Idse !== null) {
+      throw $result->Idse;
+    }
+    if ($result->ae !== null) {
+      throw $result->ae;
+    }
+    throw new \Exception("isUserEnabled failed: unknown result");
+  }
+
   public function resetUserPassword(\Airavata\Model\Security\AuthzToken $authzToken, $username, $newPassword)
   {
     $this->send_resetUserPassword($authzToken, $username, $newPassword);
@@ -1695,6 +1761,234 @@ class IamAdminServices_enableUser_result {
 
 }
 
+class IamAdminServices_isUserEnabled_args {
+  static $_TSPEC;
+
+  /**
+   * @var \Airavata\Model\Security\AuthzToken
+   */
+  public $authzToken = null;
+  /**
+   * @var string
+   */
+  public $username = null;
+
+  public function __construct($vals=null) {
+    if (!isset(self::$_TSPEC)) {
+      self::$_TSPEC = array(
+        1 => array(
+          'var' => 'authzToken',
+          'type' => TType::STRUCT,
+          'class' => '\Airavata\Model\Security\AuthzToken',
+          ),
+        2 => array(
+          'var' => 'username',
+          'type' => TType::STRING,
+          ),
+        );
+    }
+    if (is_array($vals)) {
+      if (isset($vals['authzToken'])) {
+        $this->authzToken = $vals['authzToken'];
+      }
+      if (isset($vals['username'])) {
+        $this->username = $vals['username'];
+      }
+    }
+  }
+
+  public function getName() {
+    return 'IamAdminServices_isUserEnabled_args';
+  }
+
+  public function read($input)
+  {
+    $xfer = 0;
+    $fname = null;
+    $ftype = 0;
+    $fid = 0;
+    $xfer += $input->readStructBegin($fname);
+    while (true)
+    {
+      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
+      if ($ftype == TType::STOP) {
+        break;
+      }
+      switch ($fid)
+      {
+        case 1:
+          if ($ftype == TType::STRUCT) {
+            $this->authzToken = new \Airavata\Model\Security\AuthzToken();
+            $xfer += $this->authzToken->read($input);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 2:
+          if ($ftype == TType::STRING) {
+            $xfer += $input->readString($this->username);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        default:
+          $xfer += $input->skip($ftype);
+          break;
+      }
+      $xfer += $input->readFieldEnd();
+    }
+    $xfer += $input->readStructEnd();
+    return $xfer;
+  }
+
+  public function write($output) {
+    $xfer = 0;
+    $xfer += $output->writeStructBegin('IamAdminServices_isUserEnabled_args');
+    if ($this->authzToken !== null) {
+      if (!is_object($this->authzToken)) {
+        throw new TProtocolException('Bad type in structure.', TProtocolException::INVALID_DATA);
+      }
+      $xfer += $output->writeFieldBegin('authzToken', TType::STRUCT, 1);
+      $xfer += $this->authzToken->write($output);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->username !== null) {
+      $xfer += $output->writeFieldBegin('username', TType::STRING, 2);
+      $xfer += $output->writeString($this->username);
+      $xfer += $output->writeFieldEnd();
+    }
+    $xfer += $output->writeFieldStop();
+    $xfer += $output->writeStructEnd();
+    return $xfer;
+  }
+
+}
+
+class IamAdminServices_isUserEnabled_result {
+  static $_TSPEC;
+
+  /**
+   * @var bool
+   */
+  public $success = null;
+  /**
+   * @var \Airavata\Service\Iam\Admin\Services\CPI\Error\IamAdminServicesException
+   */
+  public $Idse = null;
+  /**
+   * @var \Airavata\API\Error\AuthorizationException
+   */
+  public $ae = null;
+
+  public function __construct($vals=null) {
+    if (!isset(self::$_TSPEC)) {
+      self::$_TSPEC = array(
+        0 => array(
+          'var' => 'success',
+          'type' => TType::BOOL,
+          ),
+        1 => array(
+          'var' => 'Idse',
+          'type' => TType::STRUCT,
+          'class' => '\Airavata\Service\Iam\Admin\Services\CPI\Error\IamAdminServicesException',
+          ),
+        2 => array(
+          'var' => 'ae',
+          'type' => TType::STRUCT,
+          'class' => '\Airavata\API\Error\AuthorizationException',
+          ),
+        );
+    }
+    if (is_array($vals)) {
+      if (isset($vals['success'])) {
+        $this->success = $vals['success'];
+      }
+      if (isset($vals['Idse'])) {
+        $this->Idse = $vals['Idse'];
+      }
+      if (isset($vals['ae'])) {
+        $this->ae = $vals['ae'];
+      }
+    }
+  }
+
+  public function getName() {
+    return 'IamAdminServices_isUserEnabled_result';
+  }
+
+  public function read($input)
+  {
+    $xfer = 0;
+    $fname = null;
+    $ftype = 0;
+    $fid = 0;
+    $xfer += $input->readStructBegin($fname);
+    while (true)
+    {
+      $xfer += $input->readFieldBegin($fname, $ftype, $fid);
+      if ($ftype == TType::STOP) {
+        break;
+      }
+      switch ($fid)
+      {
+        case 0:
+          if ($ftype == TType::BOOL) {
+            $xfer += $input->readBool($this->success);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 1:
+          if ($ftype == TType::STRUCT) {
+            $this->Idse = new \Airavata\Service\Iam\Admin\Services\CPI\Error\IamAdminServicesException();
+            $xfer += $this->Idse->read($input);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        case 2:
+          if ($ftype == TType::STRUCT) {
+            $this->ae = new \Airavata\API\Error\AuthorizationException();
+            $xfer += $this->ae->read($input);
+          } else {
+            $xfer += $input->skip($ftype);
+          }
+          break;
+        default:
+          $xfer += $input->skip($ftype);
+          break;
+      }
+      $xfer += $input->readFieldEnd();
+    }
+    $xfer += $input->readStructEnd();
+    return $xfer;
+  }
+
+  public function write($output) {
+    $xfer = 0;
+    $xfer += $output->writeStructBegin('IamAdminServices_isUserEnabled_result');
+    if ($this->success !== null) {
+      $xfer += $output->writeFieldBegin('success', TType::BOOL, 0);
+      $xfer += $output->writeBool($this->success);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->Idse !== null) {
+      $xfer += $output->writeFieldBegin('Idse', TType::STRUCT, 1);
+      $xfer += $this->Idse->write($output);
+      $xfer += $output->writeFieldEnd();
+    }
+    if ($this->ae !== null) {
+      $xfer += $output->writeFieldBegin('ae', TType::STRUCT, 2);
+      $xfer += $this->ae->write($output);
+      $xfer += $output->writeFieldEnd();
+    }
+    $xfer += $output->writeFieldStop();
+    $xfer += $output->writeStructEnd();
+    return $xfer;
+  }
+
+}
+
 class IamAdminServices_resetUserPassword_args {
   static $_TSPEC;
 

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

[airavata-php-gateway] 02/03: Check if user is enabled first before verifying/resending verification email

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-php-gateway.git

commit 619dade6ea18ab3542a856caf4fba2cbe26178f4
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Mon Jun 11 14:29:55 2018 -0400

    Check if user is enabled first before verifying/resending verification email
---
 app/controllers/AccountController.php       | 41 ++++++++++++++++-------------
 app/libraries/IamAdminServicesUtilities.php |  5 ++++
 2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php
index 4f06c9a..f61486b 100644
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -381,24 +381,29 @@ class AccountController extends BaseController
             return View::make("home");
         }else{
             try{
-                $verified = EmailUtilities::verifyEmailVerification($username, $code);
-                if (!$verified){
-                    $user_profile = Keycloak::getUserProfile($username);
-                    EmailUtilities::sendVerifyEmailAccount($username,
-                        $user_profile["firstname"], $user_profile["lastname"], $user_profile["email"]);
-                    CommonUtilities::print_error_message("Account confirmation "
-                        . "failed! We're sending another confirmation email. "
-                        . "Please click the link in the confirmation email that "
-                        . "you should be receiving soon.");
-                    return View::make("home");
-                }
-                $result = IamAdminServicesUtilities::enableUser($username);
-                if($result){
-                    $this->sendAccountCreationNotification2Admin($username);
-                    return Redirect::to("login")->with("account-created-success", "Your account has been successfully created. Please log in now.");
-                }else{
-                    CommonUtilities::print_error_message("Account confirmation failed! Please contact the Gateway Admin");
-                    return View::make("home");
+                $enabled = IamAdminServicesUtilities::isUserEnabled($username);
+                if ($enabled) {
+                    return Redirect::to("login")->with("account-created-success", "Your account has already been successfully created. Please log in now.");
+                } else {
+                    $verified = EmailUtilities::verifyEmailVerification($username, $code);
+                    if (!$verified){
+                        $user_profile = Keycloak::getUserProfile($username);
+                        EmailUtilities::sendVerifyEmailAccount($username,
+                            $user_profile["firstname"], $user_profile["lastname"], $user_profile["email"]);
+                        CommonUtilities::print_error_message("Account confirmation "
+                            . "failed! We're sending another confirmation email. "
+                            . "Please click the link in the confirmation email that "
+                            . "you should be receiving soon.");
+                        return View::make("home");
+                    }
+                    $result = IamAdminServicesUtilities::enableUser($username);
+                    if($result){
+                        $this->sendAccountCreationNotification2Admin($username);
+                        return Redirect::to("login")->with("account-created-success", "Your account has been successfully created. Please log in now.");
+                    }else{
+                        CommonUtilities::print_error_message("Account confirmation failed! Please contact the Gateway Admin");
+                        return View::make("home");
+                    }
                 }
             }catch (Exception $e){
                 CommonUtilities::print_error_message("Account confirmation failed! Please contact the Gateway Admin");
diff --git a/app/libraries/IamAdminServicesUtilities.php b/app/libraries/IamAdminServicesUtilities.php
index b5623c5..086e6f1 100644
--- a/app/libraries/IamAdminServicesUtilities.php
+++ b/app/libraries/IamAdminServicesUtilities.php
@@ -22,6 +22,11 @@ class IamAdminServicesUtilities {
         return IamAdminServices::enableUser($admin_authz_token, $username);
     }
 
+    public static function isUserEnabled($username) {
+        $admin_authz_token = IamAdminServicesUtilities::getAdminAuthzToken();
+        return IamAdminServices::isUserEnabled($admin_authz_token, $username);
+    }
+
     public static function resetUserPassword($username, $new_password) {
 
         $admin_authz_token = IamAdminServicesUtilities::getAdminAuthzToken();

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

[airavata-php-gateway] 03/03: Merge branch 'check-if-user-enabled' into develop

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-php-gateway.git

commit 1cd88593937d51aaea59aee00e1fdcfd530434a7
Merge: 0988d03 619dade
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Mon Jun 11 14:30:34 2018 -0400

    Merge branch 'check-if-user-enabled' into develop

 app/controllers/AccountController.php              |  41 +--
 .../Iam/Admin/Services/CPI/IamAdminServices.php    | 294 +++++++++++++++++++++
 app/libraries/IamAdminServicesUtilities.php        |   5 +
 3 files changed, 322 insertions(+), 18 deletions(-)


-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.