lita-activedirectory 0.1.3 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -4
- data/lib/lita/handlers/activedirectory.rb +31 -0
- data/lib/utils/cratususer.rb +16 -1
- data/lita-activedirectory.gemspec +1 -1
- data/locales/en.yml +8 -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: 8de315c678f7820e8cb6191fa6879d8039d6b98f
|
4
|
+
data.tar.gz: 217e82c55ddb9258aefaa348bf25995bfd568b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 758c3742af13a513eb65d6e0a8f1f7f0e90c2bd187ad44e167a2968567b096131768bf43bd70be06a82b45adcb57b56ca4ff5044a1539d7e1c00ae521d13eee7
|
7
|
+
data.tar.gz: 53a6ad9ee77b474447769f2e163134e3c616bd721f1ff5eb354f70e95206f49a05a329d4783f2178f81cecd9841e4da2211096d906f1b355c19a64edf440668c
|
data/README.md
CHANGED
@@ -21,11 +21,16 @@ gem "lita-activedirectory"
|
|
21
21
|
* `config.handlers.activedirectory.password` - Password for connecting to LDAP
|
22
22
|
|
23
23
|
## Usage
|
24
|
-
|
25
|
-
Check if a user account is locked out
|
24
|
+
*username expects the samaccount name*
|
25
|
+
### Check if a user account is locked out
|
26
26
|
`is <username> locked?`
|
27
27
|
|
28
|
-
Unlock a user account
|
28
|
+
### Unlock a user account
|
29
29
|
`unlock <username>`
|
30
30
|
|
31
|
-
|
31
|
+
The user account specified in `config.handlers.activedirectory.username` must have permission to write the lockouttime attribute for unlocking to succeed. We leave it up to you to secure this account accordingly.
|
32
|
+
|
33
|
+
### List a User's Group Memberships
|
34
|
+
`<username> groups>`
|
35
|
+
|
36
|
+
|
@@ -23,6 +23,13 @@ module Lita
|
|
23
23
|
help: { t('help.unlock.syntax') => t('help.unlock.desc') }
|
24
24
|
)
|
25
25
|
|
26
|
+
route(
|
27
|
+
/^(\S+)\s+(groups)/i,
|
28
|
+
:user_groups,
|
29
|
+
command: true,
|
30
|
+
help: { t('help.user_groups.syntax') => t('help.user_groups.desc') }
|
31
|
+
)
|
32
|
+
|
26
33
|
include ::Utils::Cratususer
|
27
34
|
|
28
35
|
def user_locked?(response)
|
@@ -42,8 +49,32 @@ module Lita
|
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
52
|
+
def user_groups(response)
|
53
|
+
user = response.matches[0][0]
|
54
|
+
response.reply_with_mention(t('replies.user_groups.working'))
|
55
|
+
group_results = user_groups_query(user)
|
56
|
+
handle_user_group_query(response, user, group_results)
|
57
|
+
end
|
58
|
+
|
45
59
|
private
|
46
60
|
|
61
|
+
def handle_user_group_query(response, user, result)
|
62
|
+
case result
|
63
|
+
when true
|
64
|
+
response.reply(
|
65
|
+
t('replies.user_groups.success', user: user), result.join("\n")
|
66
|
+
)
|
67
|
+
when false
|
68
|
+
respone.reply_with_mention(
|
69
|
+
t('replies.user_groups.not_found', user: user)
|
70
|
+
)
|
71
|
+
when nil
|
72
|
+
response.reply_with_mention(
|
73
|
+
t('replies.user_groups.error', user: user)
|
74
|
+
)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
47
78
|
def handle_user_query(response, user, result)
|
48
79
|
case result
|
49
80
|
when true
|
data/lib/utils/cratususer.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Utils
|
2
2
|
# piggy back on cratus for ldap work
|
3
3
|
module Cratususer
|
4
|
-
def
|
4
|
+
def cratus_connect
|
5
5
|
options = {
|
6
6
|
host: config.host,
|
7
7
|
port: config.port,
|
@@ -12,6 +12,10 @@ module Utils
|
|
12
12
|
}
|
13
13
|
Cratus.config.merge(options)
|
14
14
|
Cratus::LDAP.connect
|
15
|
+
end
|
16
|
+
|
17
|
+
def user_query(username)
|
18
|
+
cratus_connect
|
15
19
|
user = begin
|
16
20
|
Cratus::User.new(username.to_s)
|
17
21
|
rescue
|
@@ -20,6 +24,17 @@ module Utils
|
|
20
24
|
user ? user.locked? : user
|
21
25
|
end
|
22
26
|
|
27
|
+
def user_groups_query(username)
|
28
|
+
cratus_connect
|
29
|
+
user = begin
|
30
|
+
Cratus::User.new(username.to_s)
|
31
|
+
rescue
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
groups = user.member_of
|
35
|
+
groups.each(&:name)
|
36
|
+
end
|
37
|
+
|
23
38
|
def unlock_user(username)
|
24
39
|
ldap = Cratus::LDAP.connection
|
25
40
|
ldap.replace_attribute Cratus::User.new(username.to_s).dn, :lockouttime, '0'
|
data/locales/en.yml
CHANGED
@@ -9,6 +9,9 @@ en:
|
|
9
9
|
unlock:
|
10
10
|
syntax: unlock <username>
|
11
11
|
desc: unlocks an active directory user account
|
12
|
+
user_groups:
|
13
|
+
syntax: <username> user_groups
|
14
|
+
desc: lists all group memberships for the given username
|
12
15
|
replies:
|
13
16
|
user_locked?:
|
14
17
|
working: let me check on that
|
@@ -19,3 +22,8 @@ en:
|
|
19
22
|
working: lets see what we can do
|
20
23
|
success: "'%{user}' has been unlocked"
|
21
24
|
fail: "could not unlock '%{user}', check active directory directly"
|
25
|
+
user_groups:
|
26
|
+
working: Give me a second to search
|
27
|
+
success: "'%{user}' is a member of"
|
28
|
+
not_found: "could not find any groups that '%{user}' is a member of"
|
29
|
+
error: "That did not work, double check the '%{user}' is a valid samAccountName"
|
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.
|
4
|
+
version: 0.2.3
|
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
|
+
date: 2016-12-13 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.8
|
212
212
|
signing_key:
|
213
213
|
specification_version: 4
|
214
214
|
summary: Allow Lita to interact with Active Directory
|