]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add login_group configuration option so only members of a certain group can login
authorCraig Andrews <candrews@integralblue.com>
Wed, 18 Nov 2009 19:35:44 +0000 (14:35 -0500)
committerCraig Andrews <candrews@integralblue.com>
Wed, 18 Nov 2009 19:35:44 +0000 (14:35 -0500)
plugins/LdapAuthorization/LdapAuthorizationPlugin.php
plugins/LdapAuthorization/README

index 20bbd256257fb16af9437c602bfb38d47569b01a..5173781f9f4f63c739d9b59c2535d768962b452f 100644 (file)
@@ -49,6 +49,7 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
     public $provider_name = null;
     public $uniqueMember_attribute = null;
     public $roles_to_groups = null;
+    public $login_group = null;
 
     function onInitializePlugin(){
         parent::onInitializePlugin();
@@ -77,8 +78,23 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
         if($user_username->find() && $user_username->fetch()){
             $entry = $this->ldap_get_user($user_username->username);
             if($entry){
-                //if a user exists, we can assume he's allowed to login
-                return true;
+                if(isset($this->login_group)){
+                    if(is_array($this->login_group)){
+                        foreach($this->login_group as $group){
+                            if($this->isMemberOfGroup($entry->dn(),$group)){
+                                return true;
+                            }
+                        }
+                    }else{
+                        if($this->isMemberOfGroup($entry->dn(),login_group)){
+                            return true;
+                        }
+                    }
+                    return null;
+                }else{
+                    //if a user exists, we can assume he's allowed to login
+                    return true;
+                }
             }else{
                 return null;
             }
index 2ca33f653d5680a7d849bd4b41e8c7a1edf2b95e..2166b272660d56816196ac7bc18e70e87bf567da 100644 (file)
@@ -18,6 +18,8 @@ uniqueMember_attribute ('uniqueMember')*: the attribute of a group
     that lists the DNs of its members
 roles_to_groups*: array that maps StatusNet roles to LDAP groups
     some StatusNet roles are: moderator, administrator, sandboxed, silenced
+login_group: if this is set to a group DN, only members of that group will be
+    allowed to login
     
 The below settings must be exact copies of the settings used for the
     corresponding LDAP Authentication plugin.