active_directory_login 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_directory_login/client.rb +13 -12
- data/lib/active_directory_login/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35dbce9c799a3b240d53d37db932486d6b13b138
|
4
|
+
data.tar.gz: 897280b514e3103f8be0fbf6ea37f2482064458a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a59a6f2317c42c66fbf0773a435a64ec474c3bca2a7ff64bb0d6c4ef9e9f03e72a576e565cd879d25bb995b642ac75a0c8ff07ad51f41507d3545719becf9187
|
7
|
+
data.tar.gz: e628d1e43fe5e7d8ea607a66cf43de44810377cacc1d35fd333cd5dd4bee9bfd49c19dfad41e3dc2297c5adb4a0241e7cebaad42958355cfb1171517e58dd550
|
@@ -62,10 +62,9 @@ module ActiveDirectoryLogin
|
|
62
62
|
|
63
63
|
def with_user(username_or_email, password, &block)
|
64
64
|
raise Error, "block required" if block.nil?
|
65
|
-
|
66
65
|
@ad_user = find_user(username_or_email)
|
67
66
|
@ad_user_password = password
|
68
|
-
@query = query
|
67
|
+
@query = query
|
69
68
|
@app_user = @query.first
|
70
69
|
|
71
70
|
value = block.call
|
@@ -93,10 +92,9 @@ module ActiveDirectoryLogin
|
|
93
92
|
@ad_user.try(:authenticate, @ad_user_password)
|
94
93
|
end
|
95
94
|
|
96
|
-
def query
|
97
|
-
|
98
|
-
|
99
|
-
User.where { (provider == User::LDAP) & (username =~ username_or_email) }
|
95
|
+
def query
|
96
|
+
ad_email = @ad_user.mail.downcase
|
97
|
+
@query = User.where { (provider == User::LDAP) & (email =~ ad_email) }
|
100
98
|
end
|
101
99
|
|
102
100
|
def create_or_update_user
|
@@ -105,7 +103,7 @@ module ActiveDirectoryLogin
|
|
105
103
|
name: "#{@ad_user.givenname} #{@ad_user.sn}",
|
106
104
|
email: @ad_user.mail.downcase,
|
107
105
|
username: @ad_user[:sAMAccountName]
|
108
|
-
|
106
|
+
)
|
109
107
|
|
110
108
|
# Update the user's password and permissions (can't use update_attributes as it might not be saved yet)
|
111
109
|
user.password = @ad_user_password
|
@@ -127,6 +125,10 @@ module ActiveDirectoryLogin
|
|
127
125
|
|
128
126
|
ad_key = (username_or_email =~ /@/) ? :mail : :sAMAccountName
|
129
127
|
ad_user = ActiveDirectory::User.find(:first, ad_key => username_or_email)
|
128
|
+
if ad_user.nil? # User hasnt used their primary email so try the secondary
|
129
|
+
ad_user = ActiveDirectory::User.find(:first, "msrtcsip-primaryuseraddress" => "sip:#{username_or_email}")
|
130
|
+
end
|
131
|
+
ad_user
|
130
132
|
end
|
131
133
|
|
132
134
|
|
@@ -183,7 +185,7 @@ module ActiveDirectoryLogin
|
|
183
185
|
staff_unchanged_emails = staff_unchanged.collect(&:email)
|
184
186
|
|
185
187
|
# create any new staff
|
186
|
-
pending = Array(staff_member_emails - staff_allowed_emails -
|
188
|
+
pending = Array(staff_member_emails - staff_allowed_emails - staff_unchanged_emails)
|
187
189
|
pending.each do |pending_email|
|
188
190
|
with_user(pending_email, SecureRandom.hex){ create_or_update_user }
|
189
191
|
end
|
@@ -207,8 +209,8 @@ module ActiveDirectoryLogin
|
|
207
209
|
superuser_unchanged_emails = superuser_unchanged.collect(&:email)
|
208
210
|
|
209
211
|
# create any new superuser
|
210
|
-
pending = Array(superuser_member_emails - superuser_allowed_emails -
|
211
|
-
|
212
|
+
pending = Array(superuser_member_emails - superuser_allowed_emails - superuser_unchanged_emails)
|
213
|
+
pending.each do |pending_email|
|
212
214
|
with_user(pending_email, SecureRandom.hex){ create_or_update_user }
|
213
215
|
end
|
214
216
|
superuser_created_emails = pending
|
@@ -218,7 +220,6 @@ module ActiveDirectoryLogin
|
|
218
220
|
|
219
221
|
## update users
|
220
222
|
user_group = find_group(user_dn)
|
221
|
-
|
222
223
|
member_emails = user_group.member.collect(&:mail).map(&:downcase)
|
223
224
|
member_emails = member_emails - superuser_member_emails - staff_member_emails
|
224
225
|
|
@@ -234,7 +235,7 @@ module ActiveDirectoryLogin
|
|
234
235
|
user_unchanged_emails = user_unchanged.collect(&:email)
|
235
236
|
|
236
237
|
#create any new user
|
237
|
-
pending = Array(
|
238
|
+
pending = Array(member_emails - user_allowed_emails - user_unchanged_emails)
|
238
239
|
pending.each do |pending_email|
|
239
240
|
with_user(pending_email, SecureRandom.hex){ create_or_update_user }
|
240
241
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_directory_login
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Murray
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|