whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] 01/02: authgroup support
Date Tue, 02 Aug 2016 15:05:49 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

commit 2770988abeb66b458c7b49bc000d4f56c3891d36
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Tue Aug 2 11:00:36 2016 -0400

    authgroup support
---
 lib/whimsy/asf/ldap.rb | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/lib/whimsy/asf/ldap.rb b/lib/whimsy/asf/ldap.rb
index 909eaf2..fc48b00 100644
--- a/lib/whimsy/asf/ldap.rb
+++ b/lib/whimsy/asf/ldap.rb
@@ -840,6 +840,41 @@ module ASF
     end
   end
 
+  class AuthGroup < Service
+    @base = 'ou=auth,ou=groups,dc=apache,dc=org'
+
+    def dn
+      return @dn if @dn
+      dns = ASF.search_subtree(self.class.base, "cn=#{name}", 'dn')
+      @dn = dns.first.first unless dns.empty?
+      @dn
+    end
+
+    def base
+      if dn
+        dn.sub(/^cn=.*?,/, '')
+      else
+        super
+      end
+    end
+
+    def self.list(filter='cn=*')
+      ASF.search_subtree(base, filter, 'cn').flatten
+    end
+
+    def self.preload
+      Hash[ASF.search_subtree(base, "cn=*", %w(dn member modifyTimestamp createTimestamp)).map
do |results|
+        cn = results['dn'].first[/^cn=(.*?),/, 1]
+        service = self.find(cn)
+        service.modifyTimestamp = results['modifyTimestamp'].first # it is returned as an
array of 1 entry
+        service.createTimestamp = results['createTimestamp'].first # it is returned as an
array of 1 entry
+        members = results['member'] || []
+        service.members = members
+        [service, members]
+      end]
+    end
+  end
+
 end
 
 if __FILE__ == $0

-- 
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <commits@whimsical.apache.org>.

Mime
View raw message