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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d16b75ad8f27578fba8cc25c342681163da49534
4
- data.tar.gz: dd3ef834bac941b64f07972fd1d6274148c0c34c
3
+ metadata.gz: 8de315c678f7820e8cb6191fa6879d8039d6b98f
4
+ data.tar.gz: 217e82c55ddb9258aefaa348bf25995bfd568b5c
5
5
  SHA512:
6
- metadata.gz: c2a78bfb9991255166a18eab8465ea4b17bc89c26da99168d2fd9db009688e4ce2ef0c9302c7e246c9e55dfd258a9c29b6d30af417ec2fb8b9d2721c3f6361ad
7
- data.tar.gz: 4ebc568d36255aae75194f565a40937fb62bafdce19d4a586721c11519cc118d80bc8eb2e3b117f291f328561c6a9bfdb1552ef7485567b636d7ffe2789cfaf9
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
- Username should take the form of the samaccount name, ie `jdoe`
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
@@ -1,7 +1,7 @@
1
1
  module Utils
2
2
  # piggy back on cratus for ldap work
3
3
  module Cratususer
4
- def user_query(username)
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'
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-activedirectory'
3
- spec.version = '0.1.3'
3
+ spec.version = '0.2.3'
4
4
  spec.authors = ['Daniel Schaaff']
5
5
  spec.email = ['dschaaff@knuedge.com']
6
6
  spec.description = 'ldap/active directory instructions for Lita'
@@ -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.1.3
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-10 00:00:00.000000000 Z
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.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