lita-activedirectory 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b49fb95c1cea2ae0d635d7b482dfba6a8ebf97da
4
+ data.tar.gz: 392161a18eb17cca7073ca15ea69bb36f6fa3a83
5
+ SHA512:
6
+ metadata.gz: d7809248a6eb6522848bf9f46fb626e163b17dd52b5a8dd141ba232673c21b0ef7b3fa7f9f898463618459eaaabc305f455907ea0d17647dbad8d1b1927e1e58
7
+ data.tar.gz: aff9df53827ff6d687b1a15a01ce1191c1e9beeca3ec072aa636cda58186f8e44784ee4a4bc53d919bc2e38831356551721520f8819608d53cc769b69a2985fd
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ Documentation:
2
+ Exclude:
3
+ - lib/lita/handlers/activedirectory.rb
4
+
5
+ FileName:
6
+ Exclude:
7
+ - lib/lita-activedirectory.rb
8
+
9
+ Metrics/LineLength:
10
+ Max: 100
11
+
12
+ Metrics/AbcSize:
13
+ Max: 22
14
+
15
+ Metrics/MethodLength:
16
+ Max: 20
17
+
18
+ Metrics/ClassLength:
19
+ Max: 150
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ sudo: required
3
+ rvm:
4
+ - 2.2
5
+ - 2.3
6
+ script: bundle exec rake
7
+ before_install:
8
+ - gem update --system
9
+ services:
10
+ - redis-server
11
+ deploy:
12
+ provider: rubygems
13
+ api_key:
14
+ secure: E0wrzWtW2hG8d1l3+E48PHsY3MCHm8qDwoIjJKAcRD8xr1A5YmeDt1bpmEy/mVu3iz9LnwALGory/AoIjtIp/gpeSuS+tJw4+dOHuYvlJNrvxmnBgyA0VJJn+8ATIs243zLRZ1OxJFJ0iR8V1MbzCoBREq30h88yCHVt+BmDeYLuguqOG9TSGwGtBph54Cfj2fvVpu0sSqIgQrRU5qXYt7UPl0r5ktcWOiao8zdLE1vEw3kLsRsFYk8vlp04ui5qMkEvOX+P9sfSK6J//GxVeJL51LUraLA7jzhgvX6q6snyj3aYtBEaJuyGR0Dg+flDG6hyjF1BubbzRge/9KRSnWFTNkgVw2awAeX3hUuKp5Apm5pMYi739hpIZKPCnnSFd6jvlX7yMjhs/hpc37RaODA2wj6W8xH/HrXWHiOl+bBcPlc/oIPiVHTwYbiTQQsq/ajlz5zrQu3HS8PC5h0x3nwUIUuQf86wI5bNBa+xxwUdBKVeKoDhuXAgXgyqyn4ET13DE6v74I7LKwN13KGN9K6NQRebs+lEvL1UwKno0FYIp1uZ3XkZP3wrbqeBX35+8I6ruVc6RCysaHYNGZWm04kCsk2tceinVQLk+c15l0BSv4twXj8XXwVmaUtks349HQKmBWpp1GBu4uK5P/50Yi0rDaJZpjcAra2FwSTa/oo=
15
+ gem: lita-activedirectory
16
+ on:
17
+ tags: true
18
+ repo: knuedge/lita-activedirectory
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,16 @@
1
+ ## Welcome!
2
+
3
+ We're so glad you're thinking about contributing to a KnuEdge open source project! If you're unsure about anything, just ask -- or submit the issue or pull request anyway. The worst that can happen is you'll be politely asked to change something. We love all friendly contributions.
4
+
5
+ We want to ensure a welcoming environment for all of our projects. Our IT staff encourage ethical contribution to our open source projects and all contributors should do the same.
6
+
7
+ We encourage you to read this project's CONTRIBUTING policy (you are here), its [LICENSE](LICENSE), and its [README](README.md).
8
+
9
+ If you have any questions just [shoot us an email](mailto:opensource@knuedge.com).
10
+
11
+ ## Licensing
12
+
13
+ This project and all code contained within it are released under the [MIT License](https://opensource.org/licenses/MIT).
14
+
15
+ All contributions to this project will be released under the [MIT License](https://opensource.org/licenses/MIT). By submitting a pull request, you are agreeing to comply
16
+ with this license and for any contributions to be released under it.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 KnuEdge
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # lita-activedirectory
2
+
3
+
4
+ A [Lita](https://www.lita.io/) handler plugin for basic interactions with Active Directory.
5
+
6
+ ## Installation
7
+
8
+ Add lita-activedirectory to your Lita instance's Gemfile:
9
+
10
+ ``` ruby
11
+ gem "lita-activedirectory"
12
+ ```
13
+
14
+ ## Configuration
15
+
16
+ * `config.handlers.activedirectory.host` - LDAP host to query
17
+ * `config.handlers.activedirectory.port` - LDAP port used to connect to the host
18
+ * `config.handlers.activedirectory.basedn` - The basedn for the LDAP search
19
+ * `config.handlers.activedirectory.username` - User for connecting to LDAP
20
+ * `config.handlers.activedirectory.password` - Password for connecting to LDAP
21
+
22
+ ## Usage
23
+
24
+ Check if a user account is locked out
25
+ `is <user> locked?`
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new(:rubocop)
7
+
8
+ task default: [:spec, :rubocop]
@@ -0,0 +1,42 @@
1
+ module Lita
2
+ module Handlers
3
+ class Activedirectory < Handler
4
+ namespace 'Activedirectory'
5
+ config :host, required: true, type: String
6
+ config :port, required: true, type: String, default: '389'
7
+ config :basedn, required: true, type: String
8
+ config :username, required: true, type: String
9
+ config :password, required: true, type: String
10
+
11
+ route(
12
+ /(is)\s+(\S+)\s+(locked(\?)?)/i,
13
+ :user_locked?,
14
+ command: true,
15
+ help: { t('help.user_locked?.syntax') => t('help.user_locked?.desc') }
16
+ )
17
+
18
+ include ::Utils::Cratususer
19
+
20
+ def user_locked?(response)
21
+ user = response.matches[0][1]
22
+ response.reply_with_mention(t('replies.user_locked?.working'))
23
+ case user_query(user)
24
+ when true
25
+ response.reply_with_mention(
26
+ t('replies.user_locked?.locked', user: user)
27
+ )
28
+ when false
29
+ response.reply_with_mention(
30
+ t('replies.user_locked?.notlocked', user: user)
31
+ )
32
+ when nil
33
+ response.reply_with_mention(
34
+ t('replies.user_locked?.error', user: user)
35
+ )
36
+ end
37
+ end
38
+
39
+ Lita.register_handler(self)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,14 @@
1
+ require 'lita'
2
+ require 'cratus'
3
+
4
+ Lita.load_locales Dir[File.expand_path(
5
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
6
+ )]
7
+
8
+ require 'utils/cratususer'
9
+ require 'lita/handlers/activedirectory'
10
+
11
+ Lita::Handlers::Activedirectory.template_root File.expand_path(
12
+ File.join('..', '..', 'templates'),
13
+ __FILE__
14
+ )
@@ -0,0 +1,20 @@
1
+ module Utils
2
+ # piggy back on cratus for ldap work
3
+ module Cratususer
4
+ def user_query(username)
5
+ options = {
6
+ host: config.host,
7
+ port: config.port,
8
+ base: config.basedn,
9
+ auth: {
10
+ method: :simple,
11
+ username: config.username,
12
+ password: config.password
13
+ }
14
+ }
15
+ Cratus::LDAP.connect(options)
16
+ user = Cratus::User.new(username.to_s)
17
+ user ? user.locked? : user
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,31 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-activedirectory'
3
+ spec.version = '0.0.1'
4
+ spec.authors = ['Daniel Schaaff']
5
+ spec.email = ['dschaaff@knuedge.com']
6
+ spec.description = 'ldap/active directory instructions for Lita'
7
+ spec.summary = 'Allow Lita to interact with Active Directory'
8
+ spec.homepage = 'https://github.com/knuedge/lita-activedirectory'
9
+ spec.license = 'MIT'
10
+ spec.metadata = { 'lita_plugin_type' => 'handler' }
11
+
12
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.required_ruby_version = '~> 2.2'
18
+
19
+ spec.add_runtime_dependency 'lita', '>= 4.7'
20
+ spec.add_runtime_dependency 'cratus'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.3'
23
+ spec.add_development_dependency 'pry-byebug'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rack-test'
26
+ spec.add_development_dependency 'rspec', '>= 3.0.0'
27
+ spec.add_development_dependency 'simplecov'
28
+ spec.add_development_dependency 'coveralls'
29
+ spec.add_development_dependency 'rubocop'
30
+ spec.add_development_dependency 'travis', '~> 1.8'
31
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,14 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ activedirectory:
5
+ help:
6
+ user_locked?:
7
+ syntax: is <username> locked?
8
+ desc: queries active directory to see if a user is locked
9
+ replies:
10
+ user_locked?:
11
+ working: let me check on that
12
+ locked: "looks like '%{user}' is locked"
13
+ notlocked: "'%{user}' is not locked"
14
+ error: "'%{user}' does not appear to be a valid user"
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::Activedirectory, lita_handler: true do
4
+ end
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-activedirectory'
10
+ require 'lita/rspec'
11
+
12
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
13
+ # was generated with Lita 4, the compatibility mode should be left disabled.
14
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,217 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-activedirectory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Schaaff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cratus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rack-test
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coveralls
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: travis
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.8'
167
+ description: ldap/active directory instructions for Lita
168
+ email:
169
+ - dschaaff@knuedge.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rubocop.yml"
176
+ - ".travis.yml"
177
+ - CONTRIBUTING.md
178
+ - Gemfile
179
+ - LICENSE
180
+ - README.md
181
+ - Rakefile
182
+ - lib/lita-activedirectory.rb
183
+ - lib/lita/handlers/activedirectory.rb
184
+ - lib/utils/cratususer.rb
185
+ - lita-activedirectory.gemspec
186
+ - locales/en.yml
187
+ - spec/lita/handlers/activedirectory_spec.rb
188
+ - spec/spec_helper.rb
189
+ - templates/.gitkeep
190
+ homepage: https://github.com/knuedge/lita-activedirectory
191
+ licenses:
192
+ - MIT
193
+ metadata:
194
+ lita_plugin_type: handler
195
+ post_install_message:
196
+ rdoc_options: []
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - "~>"
202
+ - !ruby/object:Gem::Version
203
+ version: '2.2'
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ requirements: []
210
+ rubyforge_project:
211
+ rubygems_version: 2.6.8
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Allow Lita to interact with Active Directory
215
+ test_files:
216
+ - spec/lita/handlers/activedirectory_spec.rb
217
+ - spec/spec_helper.rb