ffcrm_ldap 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/Gemfile.lock +201 -0
- data/LICENSE.txt +20 -0
- data/Rakefile +49 -0
- data/Readme.md +24 -0
- data/VERSION +1 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/models/users/authentication.rb +4 -0
- data/app/models/users/user.rb +32 -0
- data/config/initializers/ldap_attributes_map.rb +2 -0
- data/ffcrm_ldap.gemspec +72 -0
- data/lib/ffcrm_ldap/engine.rb +9 -0
- data/lib/ffcrm_ldap/ldap_access.rb +63 -0
- data/lib/ffcrm_ldap.rb +1 -0
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/ffcrm_ldap/install_generator.rb +9 -0
- data/lib/generators/ffcrm_ldap/templates/config/ldap.yml.example +8 -0
- data/lib/generators/ffcrm_ldap/templates/config/ldap_attributes_map.yml.example +5 -0
- data/spec/spec_helper.rb +12 -0
- metadata +164 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.2.5)
|
5
|
+
actionpack (= 3.2.5)
|
6
|
+
mail (~> 2.4.4)
|
7
|
+
actionpack (3.2.5)
|
8
|
+
activemodel (= 3.2.5)
|
9
|
+
activesupport (= 3.2.5)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.1)
|
13
|
+
rack (~> 1.4.0)
|
14
|
+
rack-cache (~> 1.2)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.1.3)
|
17
|
+
activemodel (3.2.5)
|
18
|
+
activesupport (= 3.2.5)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.5)
|
21
|
+
activemodel (= 3.2.5)
|
22
|
+
activesupport (= 3.2.5)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.5)
|
26
|
+
activemodel (= 3.2.5)
|
27
|
+
activesupport (= 3.2.5)
|
28
|
+
activesupport (3.2.5)
|
29
|
+
i18n (~> 0.6)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
acts-as-taggable-on (2.2.2)
|
32
|
+
rails (~> 3.0)
|
33
|
+
acts_as_commentable (3.0.1)
|
34
|
+
acts_as_list (0.1.6)
|
35
|
+
addressable (2.2.8)
|
36
|
+
ajax-chosen-rails (0.2.0)
|
37
|
+
chosen-rails_ffcrm
|
38
|
+
railties (~> 3.0)
|
39
|
+
thor (~> 0.14)
|
40
|
+
arel (3.0.2)
|
41
|
+
authlogic (3.1.2)
|
42
|
+
activerecord (>= 3.0.0)
|
43
|
+
activerecord (>= 3.0.7)
|
44
|
+
activesupport (>= 3.0.0)
|
45
|
+
activesupport (>= 3.0.7)
|
46
|
+
builder (3.0.0)
|
47
|
+
cancan (1.6.7)
|
48
|
+
chosen-rails_ffcrm (0.9.5)
|
49
|
+
railties (~> 3.0)
|
50
|
+
thor (~> 0.14)
|
51
|
+
chronic (0.6.7)
|
52
|
+
cocaine (0.2.1)
|
53
|
+
columnize (0.3.6)
|
54
|
+
css_parser (1.2.6)
|
55
|
+
addressable
|
56
|
+
rdoc
|
57
|
+
debugger (1.1.3)
|
58
|
+
columnize (>= 0.3.1)
|
59
|
+
debugger-linecache (~> 1.1.1)
|
60
|
+
debugger-ruby_core_source (~> 1.1.2)
|
61
|
+
debugger-linecache (1.1.1)
|
62
|
+
debugger-ruby_core_source (>= 1.1.1)
|
63
|
+
debugger-ruby_core_source (1.1.3)
|
64
|
+
diff-lcs (1.1.3)
|
65
|
+
dynamic_form (1.1.4)
|
66
|
+
email_reply_parser_ffcrm (0.5.0)
|
67
|
+
erubis (2.7.0)
|
68
|
+
fat_free_crm (0.11.3)
|
69
|
+
acts-as-taggable-on (~> 2.2.1)
|
70
|
+
acts_as_commentable (~> 3.0.1)
|
71
|
+
acts_as_list (~> 0.1.4)
|
72
|
+
ajax-chosen-rails (>= 0.2.0)
|
73
|
+
authlogic (~> 3.1.0)
|
74
|
+
cancan
|
75
|
+
chosen-rails_ffcrm
|
76
|
+
dynamic_form
|
77
|
+
email_reply_parser_ffcrm
|
78
|
+
ffaker (>= 1.12.0)
|
79
|
+
haml (~> 3.1.3)
|
80
|
+
jquery-rails
|
81
|
+
nokogiri
|
82
|
+
paper_trail
|
83
|
+
paperclip (~> 2.7.0)
|
84
|
+
premailer
|
85
|
+
prototype-rails
|
86
|
+
rails (~> 3.2.2)
|
87
|
+
ransack_ffcrm (~> 0.6.0)
|
88
|
+
responds_to_parent_ffcrm
|
89
|
+
sass (~> 3.1.10)
|
90
|
+
simple_form (~> 2.0.1)
|
91
|
+
squeel (~> 0.9.3)
|
92
|
+
will_paginate (~> 3.0.2)
|
93
|
+
ffaker (1.14.0)
|
94
|
+
git (1.2.5)
|
95
|
+
haml (3.1.6)
|
96
|
+
hike (1.2.1)
|
97
|
+
htmlentities (4.3.1)
|
98
|
+
i18n (0.6.0)
|
99
|
+
jeweler (1.8.3)
|
100
|
+
bundler (~> 1.0)
|
101
|
+
git (>= 1.2.5)
|
102
|
+
rake
|
103
|
+
rdoc
|
104
|
+
journey (1.0.3)
|
105
|
+
jquery-rails (2.0.2)
|
106
|
+
railties (>= 3.2.0, < 5.0)
|
107
|
+
thor (~> 0.14)
|
108
|
+
json (1.7.3)
|
109
|
+
mail (2.4.4)
|
110
|
+
i18n (>= 0.4.0)
|
111
|
+
mime-types (~> 1.16)
|
112
|
+
treetop (~> 1.4.8)
|
113
|
+
mime-types (1.18)
|
114
|
+
multi_json (1.3.6)
|
115
|
+
net-ldap (0.3.1)
|
116
|
+
nokogiri (1.5.3)
|
117
|
+
paper_trail (2.6.3)
|
118
|
+
activerecord (~> 3.0)
|
119
|
+
railties (~> 3.0)
|
120
|
+
paperclip (2.7.0)
|
121
|
+
activerecord (>= 2.3.0)
|
122
|
+
activesupport (>= 2.3.2)
|
123
|
+
cocaine (>= 0.0.2)
|
124
|
+
mime-types
|
125
|
+
polyamorous (0.5.0)
|
126
|
+
activerecord (~> 3.0)
|
127
|
+
polyglot (0.3.3)
|
128
|
+
premailer (1.7.3)
|
129
|
+
css_parser (>= 1.1.9)
|
130
|
+
htmlentities (>= 4.0.0)
|
131
|
+
prototype-rails (3.2.1)
|
132
|
+
rails (~> 3.2)
|
133
|
+
rack (1.4.1)
|
134
|
+
rack-cache (1.2)
|
135
|
+
rack (>= 0.4)
|
136
|
+
rack-ssl (1.3.2)
|
137
|
+
rack
|
138
|
+
rack-test (0.6.1)
|
139
|
+
rack (>= 1.0)
|
140
|
+
rails (3.2.5)
|
141
|
+
actionmailer (= 3.2.5)
|
142
|
+
actionpack (= 3.2.5)
|
143
|
+
activerecord (= 3.2.5)
|
144
|
+
activeresource (= 3.2.5)
|
145
|
+
activesupport (= 3.2.5)
|
146
|
+
bundler (~> 1.0)
|
147
|
+
railties (= 3.2.5)
|
148
|
+
railties (3.2.5)
|
149
|
+
actionpack (= 3.2.5)
|
150
|
+
activesupport (= 3.2.5)
|
151
|
+
rack-ssl (~> 1.3.2)
|
152
|
+
rake (>= 0.8.7)
|
153
|
+
rdoc (~> 3.4)
|
154
|
+
thor (>= 0.14.6, < 2.0)
|
155
|
+
rake (0.9.2.2)
|
156
|
+
ransack_ffcrm (0.6.0)
|
157
|
+
actionpack (~> 3.0)
|
158
|
+
activerecord (~> 3.0)
|
159
|
+
chronic (~> 0.6.7)
|
160
|
+
polyamorous (~> 0.5.0)
|
161
|
+
rdoc (3.12)
|
162
|
+
json (~> 1.4)
|
163
|
+
responds_to_parent_ffcrm (1.1.0)
|
164
|
+
rspec (2.8.0)
|
165
|
+
rspec-core (~> 2.8.0)
|
166
|
+
rspec-expectations (~> 2.8.0)
|
167
|
+
rspec-mocks (~> 2.8.0)
|
168
|
+
rspec-core (2.8.0)
|
169
|
+
rspec-expectations (2.8.0)
|
170
|
+
diff-lcs (~> 1.1.2)
|
171
|
+
rspec-mocks (2.8.0)
|
172
|
+
sass (3.1.19)
|
173
|
+
simple_form (2.0.2)
|
174
|
+
actionpack (~> 3.0)
|
175
|
+
activemodel (~> 3.0)
|
176
|
+
sprockets (2.1.3)
|
177
|
+
hike (~> 1.2)
|
178
|
+
rack (~> 1.0)
|
179
|
+
tilt (~> 1.1, != 1.3.0)
|
180
|
+
squeel (0.9.5)
|
181
|
+
activerecord (~> 3.0)
|
182
|
+
activesupport (~> 3.0)
|
183
|
+
polyamorous (~> 0.5.0)
|
184
|
+
thor (0.15.2)
|
185
|
+
tilt (1.3.3)
|
186
|
+
treetop (1.4.10)
|
187
|
+
polyglot
|
188
|
+
polyglot (>= 0.3.1)
|
189
|
+
tzinfo (0.3.33)
|
190
|
+
will_paginate (3.0.3)
|
191
|
+
|
192
|
+
PLATFORMS
|
193
|
+
ruby
|
194
|
+
|
195
|
+
DEPENDENCIES
|
196
|
+
debugger
|
197
|
+
fat_free_crm
|
198
|
+
jeweler (~> 1.8.3)
|
199
|
+
net-ldap
|
200
|
+
rdoc (~> 3.12)
|
201
|
+
rspec (~> 2.8.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Seb Jacobs
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "ffcrm_ldap"
|
18
|
+
gem.homepage = "http://github.com/sebjacobs/ffcrm_ldap"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{ldap plugin for ffcrm}
|
21
|
+
gem.description = %Q{ldap plugin for ffcrm}
|
22
|
+
gem.email = "me@sebjacobs.com"
|
23
|
+
gem.authors = ["Seb Jacobs"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "ffcrm_ldap #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/Readme.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# LDAP Plugin for Fat Free CRM
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
1. add gem 'ffcrm_ldap' to your Gemfile
|
6
|
+
2. run generator rails generate ffcrm_ldap:install
|
7
|
+
3. configure ldap.yml and ldap_attributes_map.yml
|
8
|
+
|
9
|
+
|
10
|
+
## Contributing to ffcrm_ldap
|
11
|
+
|
12
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
13
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
14
|
+
* Fork the project.
|
15
|
+
* Start a feature/bugfix branch.
|
16
|
+
* Commit and push until you are happy with your contribution.
|
17
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
18
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
19
|
+
|
20
|
+
|
21
|
+
## Copyright
|
22
|
+
|
23
|
+
Copyright (c) 2012 Seb Jacobs. See LICENSE.txt for
|
24
|
+
further details.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,32 @@
|
|
1
|
+
User.class_eval do
|
2
|
+
def self.update_or_create_from_ldap(username)
|
3
|
+
if u = find_by_username(username)
|
4
|
+
u.set_attributes_from_ldap
|
5
|
+
u.save
|
6
|
+
return u
|
7
|
+
elsif details = FfcrmLdap::LDAPAccess.get_user_details(username)
|
8
|
+
u = self.new(:username => username)
|
9
|
+
u.set_attributes_from_ldap( details )
|
10
|
+
u.admin = true if self.count == 0
|
11
|
+
u.save
|
12
|
+
return u
|
13
|
+
end
|
14
|
+
return nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_attributes_from_ldap( details = nil )
|
18
|
+
details ||= FfcrmLdap::LDAPAccess.get_user_details(username)
|
19
|
+
unless details.nil?
|
20
|
+
LDAP_ATTRIBUTES_MAP.each do |k,v|
|
21
|
+
write_attribute(k, details[v.to_sym])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def valid_ldap_credentials?(password)
|
30
|
+
FfcrmLdap::LDAPAccess.authenticate(self.username, password)
|
31
|
+
end
|
32
|
+
end
|
data/ffcrm_ldap.gemspec
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "ffcrm_ldap"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Seb Jacobs"]
|
12
|
+
s.date = "2012-06-19"
|
13
|
+
s.description = "ldap plugin for ffcrm"
|
14
|
+
s.email = "me@sebjacobs.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"Gemfile",
|
20
|
+
"Gemfile.lock",
|
21
|
+
"LICENSE.txt",
|
22
|
+
"Rakefile",
|
23
|
+
"Readme.md",
|
24
|
+
"VERSION",
|
25
|
+
"app/controllers/application_controller.rb",
|
26
|
+
"app/models/users/authentication.rb",
|
27
|
+
"app/models/users/user.rb",
|
28
|
+
"config/initializers/ldap_attributes_map.rb",
|
29
|
+
"ffcrm_ldap.gemspec",
|
30
|
+
"lib/ffcrm_ldap.rb",
|
31
|
+
"lib/ffcrm_ldap/engine.rb",
|
32
|
+
"lib/ffcrm_ldap/ldap_access.rb",
|
33
|
+
"lib/generators/.DS_Store",
|
34
|
+
"lib/generators/ffcrm_ldap/install_generator.rb",
|
35
|
+
"lib/generators/ffcrm_ldap/templates/config/ldap.yml.example",
|
36
|
+
"lib/generators/ffcrm_ldap/templates/config/ldap_attributes_map.yml.example",
|
37
|
+
"spec/spec_helper.rb"
|
38
|
+
]
|
39
|
+
s.homepage = "http://github.com/sebjacobs/ffcrm_ldap"
|
40
|
+
s.licenses = ["MIT"]
|
41
|
+
s.require_paths = ["lib"]
|
42
|
+
s.rubygems_version = "1.8.23"
|
43
|
+
s.summary = "ldap plugin for ffcrm"
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<fat_free_crm>, [">= 0"])
|
50
|
+
s.add_runtime_dependency(%q<net-ldap>, [">= 0"])
|
51
|
+
s.add_runtime_dependency(%q<debugger>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
53
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
54
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<fat_free_crm>, [">= 0"])
|
57
|
+
s.add_dependency(%q<net-ldap>, [">= 0"])
|
58
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
59
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
60
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
61
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
62
|
+
end
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<fat_free_crm>, [">= 0"])
|
65
|
+
s.add_dependency(%q<net-ldap>, [">= 0"])
|
66
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
67
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
68
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
69
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module FfcrmLdap
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
config.to_prepare do
|
4
|
+
require File.join(FfcrmLdap::Engine.root, 'app/models/users/authentication').to_s
|
5
|
+
require File.join(FfcrmLdap::Engine.root, 'app/models/users/user').to_s
|
6
|
+
require 'ffcrm_ldap/ldap_access'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'net/ldap'
|
2
|
+
module FfcrmLdap
|
3
|
+
class LDAPAccess
|
4
|
+
class << self
|
5
|
+
# Attempts to bind to LDAP using the given username and password
|
6
|
+
# returns true if successful, false otherwise.
|
7
|
+
def authenticate(uid, password)
|
8
|
+
ldap = connect()
|
9
|
+
result = ldap.bind_as(
|
10
|
+
:base => Config.search_base,
|
11
|
+
:filter => sprintf(Config.user_filter, uid),
|
12
|
+
:password => password)
|
13
|
+
return !!result
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_user_details(uid)
|
17
|
+
ldap = connect()
|
18
|
+
|
19
|
+
results = ldap.search(
|
20
|
+
:base => Config.search_base,
|
21
|
+
:filter => Config.user_filter % uid )
|
22
|
+
if results and results.size > 0
|
23
|
+
details = {}
|
24
|
+
results[0].each do |name, values|
|
25
|
+
details[name] = values[0].dup
|
26
|
+
end
|
27
|
+
details
|
28
|
+
else
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def connect()
|
36
|
+
return Net::LDAP.new(
|
37
|
+
:host => Config.host,
|
38
|
+
:port => Config.port,
|
39
|
+
:encryption => Config.ssl ? :simple_tls : nil,
|
40
|
+
:auth => {
|
41
|
+
:method => :simple,
|
42
|
+
:username => Config.bind_dn,
|
43
|
+
:password => Config.bind_passwd }
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class Config
|
49
|
+
def self.method_missing(name, *args)
|
50
|
+
if config.has_key?(name.to_s)
|
51
|
+
config[name.to_s]
|
52
|
+
else
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
@config = nil
|
58
|
+
def self.config
|
59
|
+
@config ||= YAML.load_file(File.join(Rails.root, %w(config ldap.yml)))[Rails.env]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/ffcrm_ldap.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ffcrm_ldap/engine'
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'ffcrm_ldap'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ffcrm_ldap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Seb Jacobs
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fat_free_crm
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: net-ldap
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: debugger
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.8.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.8.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rdoc
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '3.12'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3.12'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: jeweler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.8.3
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.8.3
|
110
|
+
description: ldap plugin for ffcrm
|
111
|
+
email: me@sebjacobs.com
|
112
|
+
executables: []
|
113
|
+
extensions: []
|
114
|
+
extra_rdoc_files:
|
115
|
+
- LICENSE.txt
|
116
|
+
files:
|
117
|
+
- Gemfile
|
118
|
+
- Gemfile.lock
|
119
|
+
- LICENSE.txt
|
120
|
+
- Rakefile
|
121
|
+
- Readme.md
|
122
|
+
- VERSION
|
123
|
+
- app/controllers/application_controller.rb
|
124
|
+
- app/models/users/authentication.rb
|
125
|
+
- app/models/users/user.rb
|
126
|
+
- config/initializers/ldap_attributes_map.rb
|
127
|
+
- ffcrm_ldap.gemspec
|
128
|
+
- lib/ffcrm_ldap.rb
|
129
|
+
- lib/ffcrm_ldap/engine.rb
|
130
|
+
- lib/ffcrm_ldap/ldap_access.rb
|
131
|
+
- lib/generators/.DS_Store
|
132
|
+
- lib/generators/ffcrm_ldap/install_generator.rb
|
133
|
+
- lib/generators/ffcrm_ldap/templates/config/ldap.yml.example
|
134
|
+
- lib/generators/ffcrm_ldap/templates/config/ldap_attributes_map.yml.example
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
homepage: http://github.com/sebjacobs/ffcrm_ldap
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
hash: -3933516940752226392
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.8.23
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: ldap plugin for ffcrm
|
164
|
+
test_files: []
|