예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function authenticate(User $user, $password = null)
 {
     if (isset($_SERVER['REMOTE_USER'])) {
         $username = $_SERVER['REMOTE_USER'];
         $user->setExternalUserInformation($username, 'REMOTE_USER');
         if ($this->stripUsernameRegexp) {
             $stripped = preg_replace($this->stripUsernameRegexp, '', $username);
             if ($stripped !== false) {
                 // TODO(el): PHP issues a warning when PHP cannot compile the regular expression. Should we log an
                 // additional message in that case?
                 $username = $stripped;
             }
         }
         $user->setUsername($username);
         return true;
     }
     return false;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function authenticate(User $user, $password = null)
 {
     if (!empty($_SERVER['HTTP_FROM'])) {
         $email = $_SERVER['HTTP_FROM'];
         $user->setUsername($email);
         $user->setEmail($email);
         $user->setExternalUserInformation($email, 'HTTP_FROM');
         if (!empty($_SERVER['HTTP_X_GIVEN_NAME'])) {
             $user->setFirstname($_SERVER['HTTP_X_GIVEN_NAME']);
         }
         if (!empty($_SERVER['HTTP_X_GROUPS'])) {
             $user->setGroups(explode(',', $_SERVER['HTTP_X_GROUPS']));
         }
         if (!empty($_SERVER['HTTP_X_FAMILY_NAME'])) {
             $user->setLastname($_SERVER['HTTP_X_FAMILY_NAME']);
         }
         return true;
     }
     return false;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function authenticate(User $user, $password = null)
 {
     list($username, $field) = static::getRemoteUserInformation();
     if ($username !== null) {
         $user->setExternalUserInformation($username, $field);
         if ($this->stripUsernameRegexp) {
             $stripped = @preg_replace($this->stripUsernameRegexp, '', $username);
             if ($stripped === false) {
                 Logger::error('Failed to strip external username. The configured regular expression is invalid.');
                 return false;
             }
             $username = $stripped;
         }
         $user->setUsername($username);
         return true;
     }
     return false;
 }