lita-activedirectory 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/README.md +17 -3
- data/lib/lita/handlers/activedirectory.rb +44 -0
- data/lib/utils/cratususer.rb +18 -0
- data/lita-activedirectory.gemspec +1 -1
- data/locales/en.yml +14 -0
- data/spec/lita/handlers/activedirectory_spec.rb +35 -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: 46e9aa5d62f8db695f7b993ce7809a5893197786
|
4
|
+
data.tar.gz: 61e92a97b680089344b4e671dc67dd89041c74c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd17187c82e1e5f09f80ae101c249a01b43c95858c5b37dd0ac83cb1c85186195c322642ad29ec1c98f219c080c4c9753cd8fe9d756cf46e5c00d70ec514ad88
|
7
|
+
data.tar.gz: a4fd26f6d23164ac1b3cabc24cd691b9c6ba522f7141c84b9b60fd03ef753c1ff4b74eea8ec55e348590eedd6fc8de49e8bcc72315df932fc0e1696e2f9510ae
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -30,7 +30,7 @@ gem "lita-activedirectory"
|
|
30
30
|
|
31
31
|
Requires membership in `ad_admins` authorization group.
|
32
32
|
|
33
|
-
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.
|
33
|
+
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.
|
34
34
|
|
35
35
|
### List a User's Group Memberships
|
36
36
|
`<username> groups>`
|
@@ -43,11 +43,25 @@ The user account specified in `config.handlers.activedirectory.username` must ha
|
|
43
43
|
|
44
44
|
Requires membership in `ad_admins` authorization group.
|
45
45
|
|
46
|
-
The user account specified in `config.handlers.activedirectory.username` must have permission to write the member attribute on groups for the membership change to succeed. We leave it up to you to secure this account accordingly.
|
46
|
+
The user account specified in `config.handlers.activedirectory.username` must have permission to write the `member` attribute on groups for the membership change to succeed. We leave it up to you to secure this account accordingly.
|
47
47
|
|
48
48
|
### Remove a User from a Group
|
49
49
|
`remove <username> from <groupname>`
|
50
50
|
|
51
51
|
Requires membership in `ad_admins` authorization group.
|
52
52
|
|
53
|
-
The user account specified in `config.handlers.activedirectory.username` must have permission to write the member attribute on groups for the membership change to succeed. We leave it up to you to secure this account accordingly.
|
53
|
+
The user account specified in `config.handlers.activedirectory.username` must have permission to write the `member` attribute on groups for the membership change to succeed. We leave it up to you to secure this account accordingly.
|
54
|
+
|
55
|
+
### Disable a User
|
56
|
+
`disable user <username>`
|
57
|
+
|
58
|
+
Requires membership in `ad_admins` authorization group.
|
59
|
+
|
60
|
+
The user account specified in `config.handlers.activedirectory.username` must have permission to write the `userAccountControl` attribute on groups for the change to succeed. We leave it up to you to secure this account accordingly.
|
61
|
+
|
62
|
+
### Enable a User
|
63
|
+
`enable user <username>`
|
64
|
+
|
65
|
+
Requires membership in `ad_admins` authorization group.
|
66
|
+
|
67
|
+
The user account specified in `config.handlers.activedirectory.username` must have permission to write the `userAccountControl` attribute on groups for the change to succeed. We leave it up to you to secure this account accordingly.
|
@@ -55,6 +55,22 @@ module Lita
|
|
55
55
|
help: { t('help.add_member.syntax') => t('help.add_member.desc') }
|
56
56
|
)
|
57
57
|
|
58
|
+
route(
|
59
|
+
/^disable\s+user\s+(\S+)$/i,
|
60
|
+
:disable_user,
|
61
|
+
command: true,
|
62
|
+
restrict_to: :ad_admins,
|
63
|
+
help: { t('help.disable_user.syntax') => t('help.disable_user.desc') }
|
64
|
+
)
|
65
|
+
|
66
|
+
route(
|
67
|
+
/^enable\s+user\s+(\S+)$/i,
|
68
|
+
:enable_user,
|
69
|
+
command: true,
|
70
|
+
restrict_to: :ad_admins,
|
71
|
+
help: { t('help.enable_user.syntax') => t('help.enable_user.desc') }
|
72
|
+
)
|
73
|
+
|
58
74
|
include ::Utils::Cratususer
|
59
75
|
|
60
76
|
def user_locked?(response)
|
@@ -130,6 +146,34 @@ module Lita
|
|
130
146
|
)
|
131
147
|
end
|
132
148
|
|
149
|
+
def disable_user(response)
|
150
|
+
user = response.matches[0][0]
|
151
|
+
|
152
|
+
response.reply_with_mention(t('replies.disable_user.working'))
|
153
|
+
result = disable_ldap_user(user)
|
154
|
+
response.reply_with_mention(
|
155
|
+
if result.nil?
|
156
|
+
t('replies.disable_user.error', user: user)
|
157
|
+
else
|
158
|
+
t('replies.disable_user.success', user: user)
|
159
|
+
end
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
def enable_user(response)
|
164
|
+
user = response.matches[0][0]
|
165
|
+
|
166
|
+
response.reply_with_mention(t('replies.enable_user.working'))
|
167
|
+
result = enable_ldap_user(user)
|
168
|
+
response.reply_with_mention(
|
169
|
+
if result.nil?
|
170
|
+
t('replies.enable_user.error', user: user)
|
171
|
+
else
|
172
|
+
t('replies.enable_user.success', user: user)
|
173
|
+
end
|
174
|
+
)
|
175
|
+
end
|
176
|
+
|
133
177
|
private
|
134
178
|
|
135
179
|
def handle_user_query(response, user, result)
|
data/lib/utils/cratususer.rb
CHANGED
@@ -83,5 +83,23 @@ module Utils
|
|
83
83
|
nil
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
def disable_ldap_user(username)
|
88
|
+
cratus_connect
|
89
|
+
begin
|
90
|
+
Cratus::User.new(username.to_s).disable
|
91
|
+
rescue
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def enable_ldap_user(username)
|
97
|
+
cratus_connect
|
98
|
+
begin
|
99
|
+
Cratus::User.new(username.to_s).enable
|
100
|
+
rescue
|
101
|
+
nil
|
102
|
+
end
|
103
|
+
end
|
86
104
|
end
|
87
105
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-activedirectory'
|
3
|
-
spec.version = '1.
|
3
|
+
spec.version = '1.2.0'
|
4
4
|
spec.authors = ['Daniel Schaaff', 'Jonathan Gnagy']
|
5
5
|
spec.email = ['dschaaff@knuedge.com']
|
6
6
|
spec.description = 'ldap/active directory instructions for Lita'
|
data/locales/en.yml
CHANGED
@@ -21,6 +21,12 @@ en:
|
|
21
21
|
remove_member:
|
22
22
|
syntax: remove <username> from <groupname>
|
23
23
|
desc: remove a user from an LDAP group
|
24
|
+
disable_user:
|
25
|
+
syntax: disable user <username>
|
26
|
+
desc: disable an active directory user
|
27
|
+
enable_user:
|
28
|
+
syntax: enable user <username>
|
29
|
+
desc: enable an active directory user
|
24
30
|
replies:
|
25
31
|
user_locked?:
|
26
32
|
working: let me check on that
|
@@ -47,3 +53,11 @@ en:
|
|
47
53
|
working: Give me just a second to remove that user from the group
|
48
54
|
error: "That did not work, double check that '%{user}' and '%{group}' are valid"
|
49
55
|
success: "'%{user}' is no longer a member of '%{group}'"
|
56
|
+
disable_user:
|
57
|
+
working: Let's stop that user from logging in then
|
58
|
+
error: "That did not work, double check that '%{user}' is a valid user"
|
59
|
+
success: "'%{user}' is now disabled"
|
60
|
+
enable_user:
|
61
|
+
working: I'll allow this user to login again
|
62
|
+
error: "That did not work, double check that '%{user}' is a valid user"
|
63
|
+
success: "'%{user}' is now enabled"
|
@@ -22,6 +22,10 @@ describe Lita::Handlers::Activedirectory, lita_handler: true do
|
|
22
22
|
.with_authorization_for(:ad_admins).to(:add_group_member)
|
23
23
|
is_expected.to route_command('remove foo from bar')
|
24
24
|
.with_authorization_for(:ad_admins).to(:remove_group_member)
|
25
|
+
is_expected.to route_command('disable user foo')
|
26
|
+
.with_authorization_for(:ad_admins).to(:disable_user)
|
27
|
+
is_expected.to route_command('enable user foo')
|
28
|
+
.with_authorization_for(:ad_admins).to(:enable_user)
|
25
29
|
end
|
26
30
|
|
27
31
|
let(:fake_group1) do
|
@@ -49,7 +53,9 @@ describe Lita::Handlers::Activedirectory, lita_handler: true do
|
|
49
53
|
fullname: 'Foo Bar',
|
50
54
|
member_of: [],
|
51
55
|
lockouttime: '0',
|
52
|
-
locked?: false
|
56
|
+
locked?: false,
|
57
|
+
disable: true,
|
58
|
+
enable: true
|
53
59
|
)
|
54
60
|
end
|
55
61
|
|
@@ -154,6 +160,34 @@ describe Lita::Handlers::Activedirectory, lita_handler: true do
|
|
154
160
|
end
|
155
161
|
end
|
156
162
|
|
163
|
+
describe '#disable_user' do
|
164
|
+
before do
|
165
|
+
robot.auth.add_user_to_group!(lita_user, :ad_admins)
|
166
|
+
end
|
167
|
+
it 'disables a user' do
|
168
|
+
allow(Cratus::LDAP).to receive(:connect).and_return(true)
|
169
|
+
allow(Cratus::LDAP).to receive(:connection).and_return(true)
|
170
|
+
allow(Cratus::User).to receive(:new).and_return(fake_user)
|
171
|
+
send_command('disable user jdoe', as: lita_user)
|
172
|
+
expect(replies.first).to eq("Let's stop that user from logging in then")
|
173
|
+
expect(replies.last).to eq("'jdoe' is now disabled")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe '#enable_user' do
|
178
|
+
before do
|
179
|
+
robot.auth.add_user_to_group!(lita_user, :ad_admins)
|
180
|
+
end
|
181
|
+
it 'enables a user' do
|
182
|
+
allow(Cratus::LDAP).to receive(:connect).and_return(true)
|
183
|
+
allow(Cratus::LDAP).to receive(:connection).and_return(true)
|
184
|
+
allow(Cratus::User).to receive(:new).and_return(fake_user)
|
185
|
+
send_command('enable user jdoe', as: lita_user)
|
186
|
+
expect(replies.first).to eq("I'll allow this user to login again")
|
187
|
+
expect(replies.last).to eq("'jdoe' is now enabled")
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
157
191
|
describe '#user_groups' do
|
158
192
|
it 'should return proper error mesage' do
|
159
193
|
allow(Cratus::User).to receive(:new).and_return(false_user)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-activedirectory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Schaaff
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-04-
|
12
|
+
date: 2017-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: lita
|