lita-activedirectory 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/lita/handlers/activedirectory.rb +26 -4
- data/lib/utils/cratususer.rb +10 -1
- data/lita-activedirectory.gemspec +1 -1
- data/locales/en.yml +5 -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: 86094298072af8b91beafaa430db13755886f5f2
|
4
|
+
data.tar.gz: d6df668086f28b1fde14ab616403d70b9d69aa67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf8f884abb56144dc714976efa76b531e0ce7665f5c347feb49cb8d1ecc0e84164aab15a98a0a9877ba255c0b71c20b47eccfe34d6733121495d650dc00f0e03
|
7
|
+
data.tar.gz: f72967fd5e5c959723195a4dae01b0c05f294e359125b62d4dfc889e14d5554117d0d7de357d1b5e997d58103386fbedee059322434305d209c59f7e4149c4ed
|
data/README.md
CHANGED
@@ -16,10 +16,16 @@ gem "lita-activedirectory"
|
|
16
16
|
* `config.handlers.activedirectory.host` - LDAP host to query
|
17
17
|
* `config.handlers.activedirectory.port` - LDAP port used to connect to the host
|
18
18
|
* `config.handlers.activedirectory.basedn` - The basedn for the LDAP search
|
19
|
+
* `config.handlers.activedirectory.user_basedn` - the basedn for LDAP user searches
|
19
20
|
* `config.handlers.activedirectory.username` - User for connecting to LDAP
|
20
21
|
* `config.handlers.activedirectory.password` - Password for connecting to LDAP
|
21
22
|
|
22
23
|
## Usage
|
23
24
|
|
24
25
|
Check if a user account is locked out
|
25
|
-
`is <
|
26
|
+
`is <username> locked?`
|
27
|
+
|
28
|
+
Unlock a user account
|
29
|
+
`unlock <username>`
|
30
|
+
|
31
|
+
Username should take the form of the samaccount name, ie `jdoe`
|
@@ -16,27 +16,49 @@ module Lita
|
|
16
16
|
help: { t('help.user_locked?.syntax') => t('help.user_locked?.desc') }
|
17
17
|
)
|
18
18
|
|
19
|
+
route(
|
20
|
+
/(unlock)\s+(\S+)/i,
|
21
|
+
:unlock,
|
22
|
+
command: true,
|
23
|
+
help: { t('help.unlock.syntax') => t('help.unlock.desc') }
|
24
|
+
)
|
25
|
+
|
19
26
|
include ::Utils::Cratususer
|
20
27
|
|
21
28
|
def user_locked?(response)
|
22
29
|
user = response.matches[0][1]
|
23
30
|
response.reply_with_mention(t('replies.user_locked?.working'))
|
24
|
-
|
31
|
+
handle_user_query(user_query(user))
|
32
|
+
end
|
33
|
+
|
34
|
+
def handle_user_query(username)
|
35
|
+
case username
|
25
36
|
when true
|
26
37
|
response.reply_with_mention(
|
27
|
-
t('replies.user_locked?.locked', user:
|
38
|
+
t('replies.user_locked?.locked', user: username)
|
28
39
|
)
|
29
40
|
when false
|
30
41
|
response.reply_with_mention(
|
31
|
-
t('replies.user_locked?.notlocked', user:
|
42
|
+
t('replies.user_locked?.notlocked', user: username)
|
32
43
|
)
|
33
44
|
when nil
|
34
45
|
response.reply_with_mention(
|
35
|
-
t('replies.user_locked?.error', user:
|
46
|
+
t('replies.user_locked?.error', user: username)
|
36
47
|
)
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
51
|
+
def unlock
|
52
|
+
user = response.matches[0][1]
|
53
|
+
response.reply_with_mention(t('replies.unlock.working'))
|
54
|
+
user_result = user_query(user)
|
55
|
+
if user_result
|
56
|
+
unlock_user(user)
|
57
|
+
else
|
58
|
+
handle_user_query(user_result)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
40
62
|
Lita.register_handler(self)
|
41
63
|
end
|
42
64
|
end
|
data/lib/utils/cratususer.rb
CHANGED
@@ -12,8 +12,17 @@ module Utils
|
|
12
12
|
}
|
13
13
|
Cratus.config.merge(options)
|
14
14
|
Cratus::LDAP.connect
|
15
|
-
user =
|
15
|
+
user = begin
|
16
|
+
Cratus::User.new(username.to_s)
|
17
|
+
rescue
|
18
|
+
nil
|
19
|
+
end
|
16
20
|
user ? user.locked? : user
|
17
21
|
end
|
22
|
+
|
23
|
+
def unlock_user(username)
|
24
|
+
ldap = Cratus::LDAP.connection
|
25
|
+
ldap.replace_attribute username.dn, :lockedtime, '0'
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
data/locales/en.yml
CHANGED
@@ -6,9 +6,14 @@ en:
|
|
6
6
|
user_locked?:
|
7
7
|
syntax: is <username> locked?
|
8
8
|
desc: queries active directory to see if a user is locked
|
9
|
+
unlock:
|
10
|
+
syntax: unlock <username>
|
11
|
+
desc: unlocks an active directory user account
|
9
12
|
replies:
|
10
13
|
user_locked?:
|
11
14
|
working: let me check on that
|
12
15
|
locked: "looks like '%{user}' is locked"
|
13
16
|
notlocked: "'%{user}' is not locked"
|
14
17
|
error: "'%{user}' does not appear to be a valid user"
|
18
|
+
unlock:
|
19
|
+
working: lets see what we can do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-activedirectory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schaaff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
208
|
version: '0'
|
209
209
|
requirements: []
|
210
210
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.6.
|
211
|
+
rubygems_version: 2.6.6
|
212
212
|
signing_key:
|
213
213
|
specification_version: 4
|
214
214
|
summary: Allow Lita to interact with Active Directory
|