lita-openvpnas 0.1.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 +7 -0
- data/.gitignore +17 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +25 -0
- data/Rakefile +6 -0
- data/lib/lita-openvpnas.rb +14 -0
- data/lib/lita/handlers/openvpnas.rb +66 -0
- data/lita-openvpnas.gemspec +25 -0
- data/locales/en.yml +4 -0
- data/spec/lita/handlers/openvpnas_spec.rb +4 -0
- data/spec/spec_helper.rb +6 -0
- data/templates/.gitkeep +0 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 75f2d35fa1bd46a324c96a272e8e2d4dd9aa98cb
|
4
|
+
data.tar.gz: 441dc393fa4ed9c870c49f6eb07bbc37492cb654
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77d243c1711b4b2cad979d2d372571e132b78364eec8d65cdcde6c57454dd1b97e312a28a321af813c509642eed5c3270936a914791051a30dd464a502ecb7b1
|
7
|
+
data.tar.gz: 94dac5ff85cb9f8109e7528d1f7b32f6b9c199d1a9cb22385c275b7e5a3c0b81b06e75d386c988fdb2d6f5e6de8b6487eaf07d7f6304ae3f0f0b2bf330200f71
|
data/.gitignore
ADDED
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
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 KnuEdge
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# lita-openvpnas
|
2
|
+
|
3
|
+
A [Lita](https://www.lita.io/) handler plugin for some basic [OpenVPN Access Server](https://openvpn.net/index.php/access-server/overview.html) operations.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-openvpnas to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-openvpnas"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
* `config.handlers.openvpnas.hostname` - OpenVPN Access Server hostname
|
16
|
+
* `config.handlers.openvpnas.sacli_dir` - Path to the directory containing the `sacli` utility on the OpenVPN Access Server
|
17
|
+
* Defaults to `/usr/local/openvpn_as/scripts`
|
18
|
+
* `config.handlers.openvpnas.ssh_user` - SSH user to connect to OpenVPN Access Server
|
19
|
+
* Defaults to `lita`
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
#### Unlock the Google Authenticator for a User
|
24
|
+
openvpn otp unlock <user>
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "lita"
|
2
|
+
require 'rye'
|
3
|
+
require 'timeout'
|
4
|
+
|
5
|
+
Lita.load_locales Dir[File.expand_path(
|
6
|
+
File.join("..", "..", "locales", "*.yml"), __FILE__
|
7
|
+
)]
|
8
|
+
|
9
|
+
require "lita/handlers/openvpnas"
|
10
|
+
|
11
|
+
Lita::Handlers::Openvpnas.template_root File.expand_path(
|
12
|
+
File.join("..", "..", "templates"),
|
13
|
+
__FILE__
|
14
|
+
)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class Openvpnas < Handler
|
4
|
+
namespace 'OpenVPNAS'
|
5
|
+
config :hostname, required: true, type: String
|
6
|
+
config :ssh_user, required: false, type: String
|
7
|
+
config :sacli_dir, required: false, type: String
|
8
|
+
|
9
|
+
route(
|
10
|
+
/(openvpn)\s+(otp)\s+(unlock)\s+(\S+)/i,
|
11
|
+
:openvpn_as_otp_unlock,
|
12
|
+
command: true,
|
13
|
+
help: {
|
14
|
+
"openvpn otp unlock <user>" => "Unlock the OTP Authenticator for an OpenVPN AS user."
|
15
|
+
}
|
16
|
+
)
|
17
|
+
|
18
|
+
def openvpn_as_otp_unlock(response)
|
19
|
+
user = response.matches[0][3]
|
20
|
+
ssh_user = config.ssh_user || 'lita'
|
21
|
+
ssh_host = config.hostname
|
22
|
+
path_to_sacli = config.sacli_dir || '/usr/local/openvpn_as/scripts'
|
23
|
+
username = response.user.name.split(/\s/).first
|
24
|
+
|
25
|
+
response.reply("#{username}, let me unlock that user's OpenVPN authenticator for you.")
|
26
|
+
|
27
|
+
exception = nil
|
28
|
+
|
29
|
+
remote = Rye::Box.new(
|
30
|
+
ssh_host,
|
31
|
+
user: ssh_user,
|
32
|
+
auth_methods: ['publickey'],
|
33
|
+
password_prompt: false
|
34
|
+
)
|
35
|
+
|
36
|
+
result = begin
|
37
|
+
Timeout::timeout(60) do
|
38
|
+
remote.cd 'path_to_sacli'
|
39
|
+
# Need to use sudo
|
40
|
+
remote.enable_sudo
|
41
|
+
# scary...
|
42
|
+
remote.disable_safe_mode
|
43
|
+
|
44
|
+
remote.execute "./sacli -u #{user} --lock 0 GoogleAuthLock 2>&1"
|
45
|
+
end
|
46
|
+
rescue Rye::Err => e
|
47
|
+
exception = e
|
48
|
+
rescue StandardError => e
|
49
|
+
exception = e
|
50
|
+
ensure
|
51
|
+
remote.disconnect
|
52
|
+
end
|
53
|
+
|
54
|
+
if exception
|
55
|
+
response.reply_with_mention "That OpenVPN authenticator didn't seem to unlock... ;-("
|
56
|
+
response.reply "/code " + exception.message
|
57
|
+
end
|
58
|
+
|
59
|
+
# build a reply
|
60
|
+
response.reply_with_mention("That OpenVPN authenticator is now available for #{user}!")
|
61
|
+
end
|
62
|
+
|
63
|
+
Lita.register_handler(self)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-openvpnas"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Jonathan Gnagy"].sort
|
5
|
+
spec.email = ["jgnagy@knuedge.com"]
|
6
|
+
spec.description = "Some basic OpenVPN Access Server interactions for Lita"
|
7
|
+
spec.summary = "Allow the Lita bot to handle requests for OpenVPN Access Server tasks"
|
8
|
+
spec.homepage = "https://github.com/knuedge/lita-openvpnas"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
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.add_runtime_dependency "lita", "~> 4.7"
|
18
|
+
spec.add_runtime_dependency "rye"
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "pry-byebug"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rack-test"
|
24
|
+
spec.add_development_dependency "rspec", '~> 3.0'
|
25
|
+
end
|
data/locales/en.yml
ADDED
data/spec/spec_helper.rb
ADDED
data/templates/.gitkeep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-openvpnas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Gnagy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-02 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: rye
|
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'
|
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'
|
111
|
+
description: Some basic OpenVPN Access Server interactions for Lita
|
112
|
+
email:
|
113
|
+
- jgnagy@knuedge.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- CONTRIBUTING.md
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/lita-openvpnas.rb
|
125
|
+
- lib/lita/handlers/openvpnas.rb
|
126
|
+
- lita-openvpnas.gemspec
|
127
|
+
- locales/en.yml
|
128
|
+
- spec/lita/handlers/openvpnas_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
- templates/.gitkeep
|
131
|
+
homepage: https://github.com/knuedge/lita-openvpnas
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata:
|
135
|
+
lita_plugin_type: handler
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.5.1
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Allow the Lita bot to handle requests for OpenVPN Access Server tasks
|
156
|
+
test_files:
|
157
|
+
- spec/lita/handlers/openvpnas_spec.rb
|
158
|
+
- spec/spec_helper.rb
|