lita-activedirectory 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ce437457c2882810acd169b99bb195dde2d35c8
4
- data.tar.gz: eac98aa01643476a4672188daa9f1aab97f82ab1
3
+ metadata.gz: 86094298072af8b91beafaa430db13755886f5f2
4
+ data.tar.gz: d6df668086f28b1fde14ab616403d70b9d69aa67
5
5
  SHA512:
6
- metadata.gz: b644855aafbad936291b951d24bec49d7ba302def912cd53a311e2528bc9ae0818abeec02e090f79e871b1b7e11030a21e31d0536ec7aaf9b16069bc1e59f40e
7
- data.tar.gz: eed6404dee9c744edc8a7b6ed680e0476648e57aeb98e7ad68d51ec6dc88edb35a3453e05af95a4cf95bdaf85a48408cdcc91ef569d0f06504aaa04fdae3e00d
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 <user> locked?`
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
- case user_query(user)
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: 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: 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: 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
@@ -12,8 +12,17 @@ module Utils
12
12
  }
13
13
  Cratus.config.merge(options)
14
14
  Cratus::LDAP.connect
15
- user = Cratus::User.new(username.to_s)
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-activedirectory'
3
- spec.version = '0.0.7'
3
+ spec.version = '0.0.8'
4
4
  spec.authors = ['Daniel Schaaff']
5
5
  spec.email = ['dschaaff@knuedge.com']
6
6
  spec.description = 'ldap/active directory instructions for Lita'
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.7
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-09 00:00:00.000000000 Z
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.8
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