Beispiel #1
0
 /**
  * @return array
  */
 protected static function authenticate()
 {
     $principal = SecurityPrincipal::get();
     if ($principal->authenticate(static::request()->username, static::request()->password)) {
         Session::set('security.current_user', static::request()->username);
         Session::set('security.authenticated', true);
         $uri = Session::get('security.called_before_login');
         Session::set('security.called_before_login', null);
         return ['success' => true, 'controllerAction' => $uri];
     } else {
         return ['success' => false, 'controllerAction' => 'Security::login', 'params' => ['failure']];
     }
 }
Beispiel #2
0
 /**
  * @return array[]
  */
 public function getGroups()
 {
     if (!Session::get('security.ldap_groups')) {
         $security = Config::get()->security;
         $list = ldap_search($this->conn, $security->user_base_dn, 'objectclass=group');
         $entries = ldap_get_entries($this->conn, $list);
         unset($entries['count']);
         Session::set('security.ldap_groups', array());
         foreach ($entries as $entry) {
             if (isset($entry[$security->groupname_attribute])) {
                 $groupDn = $entry["distinguishedname"][0];
                 if ($groupDn) {
                     Session::set('security.ldap_groups.' . $groupDn, $this->getGroupUsers($groupDn));
                 }
             }
         }
     }
     return Session::get('security.ldap_groups');
 }
 public function currentUser()
 {
     return Session::get('security.current_user') ? $this->getUser(Session::get('security.current_user')) : new $this->userClass('anonymous', new \StdClass());
 }