whimsy-asf 0.0.43 → 0.0.44
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/asf.version +1 -1
- data/lib/whimsy/asf/ldap.rb +53 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a6eaa3a6a967e8b9b0dc268e4ec2bd4ff268ea0
|
4
|
+
data.tar.gz: b39573a643e6d010cff645ec29319b23097d22b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b120875f62fb4f48222adefc3125a847feda1750c72676eb5ff8798e0ea50c651ff358a9d870c031a0880dcdedcc46e486341a0610696eac737bc6f670c74cc
|
7
|
+
data.tar.gz: 9a0ea08eb4c7a7c23f436090294ed597945da108c31ae3c963f49b691c853b1fc820d040e38507096ead6de64d0b7d8f5cdf324873679072186a1653f0efdb86
|
data/asf.version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.44
|
data/lib/whimsy/asf/ldap.rb
CHANGED
@@ -29,6 +29,10 @@ module ASF
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.ldap
|
33
|
+
@ldap || self.init_ldap
|
34
|
+
end
|
35
|
+
|
32
36
|
# search with a scope of one
|
33
37
|
def self.search_one(base, filter, attrs=nil)
|
34
38
|
init_ldap unless defined? @ldap
|
@@ -198,6 +202,42 @@ module ASF
|
|
198
202
|
def groups
|
199
203
|
Group.list("memberUid=#{name}")
|
200
204
|
end
|
205
|
+
|
206
|
+
def dn
|
207
|
+
attrs['dn']
|
208
|
+
end
|
209
|
+
|
210
|
+
def method_missing(name, *args)
|
211
|
+
if name.to_s.end_with? '=' and args.length == 1
|
212
|
+
return modify(name.to_s[0..-2], args)
|
213
|
+
end
|
214
|
+
|
215
|
+
return super unless args.empty?
|
216
|
+
result = self.attrs[name.to_s]
|
217
|
+
return super unless result
|
218
|
+
|
219
|
+
if result.empty?
|
220
|
+
return nil
|
221
|
+
else
|
222
|
+
result.map! do |value|
|
223
|
+
value = value.dup.force_encoding('utf-8') if String === value
|
224
|
+
value
|
225
|
+
end
|
226
|
+
|
227
|
+
if result.length == 1
|
228
|
+
result.first
|
229
|
+
else
|
230
|
+
result
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def modify(attr, value)
|
236
|
+
value = Array(value) unless Hash === value
|
237
|
+
mod = ::LDAP::Mod.new(::LDAP::LDAP_MOD_REPLACE, attr.to_s, value)
|
238
|
+
ASF.ldap.modify(self.dn, [mod])
|
239
|
+
attrs[attr.to_s] = value
|
240
|
+
end
|
201
241
|
end
|
202
242
|
|
203
243
|
class Group < Base
|
@@ -233,6 +273,10 @@ module ASF
|
|
233
273
|
ASF.search_one(base, "cn=#{name}", 'member').flatten.
|
234
274
|
map {|uid| Person.find uid[/uid=(.*?),/,1]}
|
235
275
|
end
|
276
|
+
|
277
|
+
def dn
|
278
|
+
@dn ||= ASF.search_one(base, "cn=#{name}", 'dn').first.first
|
279
|
+
end
|
236
280
|
end
|
237
281
|
|
238
282
|
class Service < Base
|
@@ -249,6 +293,15 @@ module ASF
|
|
249
293
|
end
|
250
294
|
|
251
295
|
module LDAP
|
296
|
+
def self.bind(user, password, &block)
|
297
|
+
dn = ASF::Person.new(user).dn
|
298
|
+
if block
|
299
|
+
ASF.ldap.bind(dn, password, &block)
|
300
|
+
else
|
301
|
+
ASF.ldap.bind(dn, password)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
252
305
|
# select LDAP host
|
253
306
|
def self.host
|
254
307
|
# try whimsy config
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whimsy-asf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.44
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Ruby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
148
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.4.5
|
149
|
+
rubygems_version: 2.4.5.1
|
150
150
|
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Whimsy 'model' of the ASF
|