kaseyaws 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/kaseyaws.gemspec +25 -0
- data/lib/kaseyaws/security.rb +52 -0
- data/lib/kaseyaws/version.rb +8 -0
- data/lib/kaseyaws.rb +178 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fa55ab6fd4e0e3dd702df0c3b29bd1775afb6e3a
|
4
|
+
data.tar.gz: 6eab6b4fcb01edaa4e69f5698b7881d58fc11242
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d69947ee91373caa8f9a23f1889ad00bd4a50ff2d1830fd91e4809cbb20912c490414902208225c00f731cad4aa1ea48ec315fc7c38bb23d51ca02b3e7e78956
|
7
|
+
data.tar.gz: 5b6153c44c1d017c213be11ece6bb273d22eec05aaf965b239ad2ad700552cca036c6c8f5df1ca5d1f541e686987182b6dff22b348dcb5f05f2b5ad42ce72d78
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Phillip Henslee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# KaseyaWS
|
2
|
+
|
3
|
+
A simple Ruby Gem that provides a Ruby client for Kaseya's VSA web service.
|
4
|
+
|
5
|
+
This is currently a work in progress, as all Kaseya web service operations are not implemented yet.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'kaseyaws'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install kaseyaws
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
require 'kaseyaws'
|
25
|
+
|
26
|
+
# Create a new web service client instance
|
27
|
+
kclient = KaseyaWS::Client.new("username","password","mykserver.domain.com")
|
28
|
+
|
29
|
+
#Get alarm list, returns hash
|
30
|
+
alarms = kclient.get_alarm_list
|
31
|
+
|
32
|
+
#Get a specific alarm by alarm id, returns hash
|
33
|
+
alarm = kclient.get_alarm(alarms[:alarms][:alarm][0][:monitor_alarm_id])
|
34
|
+
|
35
|
+
alarm[:alarm_subject]
|
36
|
+
# => "Monitoring generated Counter ALARM at 5:47:54 am 01-Feb-13 on computer.systems.company"
|
37
|
+
|
38
|
+
```
|
39
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/kaseyaws.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kaseyaws/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "kaseyaws"
|
8
|
+
s.version = KaseyaWS::VERSION
|
9
|
+
s.authors = ["Phillip Henslee"]
|
10
|
+
s.email = ["phenslee@towerdigital.us"]
|
11
|
+
s.description = ["A Ruby client for Kaseya web services"]
|
12
|
+
s.summary = ["A simple client for the Kaseya VSA web service"]
|
13
|
+
s.homepage = "https://github.com/towerdigital/kaseyaws"
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split($/)
|
17
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|s|features)/})
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.add_dependency("savon", [">= 2.1.0"])
|
21
|
+
s.add_dependency("json")
|
22
|
+
|
23
|
+
s.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
s.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright 2013 by Phillip Henslee (phenslee@towerdigital.us).
|
4
|
+
# All rights reserved.
|
5
|
+
|
6
|
+
# Permission is granted for use, copying, modification, distribution,
|
7
|
+
# and distribution of modified versions of this work as long as the
|
8
|
+
# above copyright notice is included.
|
9
|
+
#
|
10
|
+
|
11
|
+
# Provides some helper methods for web service authentication
|
12
|
+
|
13
|
+
require 'digest'
|
14
|
+
require 'net/http'
|
15
|
+
require 'securerandom'
|
16
|
+
require 'json'
|
17
|
+
|
18
|
+
module KaseyaWS
|
19
|
+
class Security
|
20
|
+
|
21
|
+
# Utility method to return the client's IP address
|
22
|
+
# Most but not all Kaseya VSA SOAP request require <BrowserIP>
|
23
|
+
|
24
|
+
def self.client_ip
|
25
|
+
r = Net::HTTP.get( 'jsonip.com','/' )
|
26
|
+
r = JSON::parse(r)['ip']
|
27
|
+
end
|
28
|
+
|
29
|
+
# Create a secure random number, returns a eight digit string
|
30
|
+
# Used to compute the second hash for the double hash sequence
|
31
|
+
|
32
|
+
def self.secure_random
|
33
|
+
i = SecureRandom.random_bytes
|
34
|
+
i = i.each_byte.map { |b| b.to_s }.join
|
35
|
+
i = i.gsub("0","")
|
36
|
+
i = i[1..8]
|
37
|
+
end
|
38
|
+
|
39
|
+
# Computes the double hashed covered password to authenticate with the VSA
|
40
|
+
|
41
|
+
def self.compute_covered_password(username, password, rnd_number, hashing_algorithm)
|
42
|
+
if hashing_algorithm == "SHA-1"
|
43
|
+
hash1 = Digest::SHA1.hexdigest(password + username)
|
44
|
+
covered_password = Digest::SHA1.hexdigest(hash1 + rnd_number)
|
45
|
+
else # Assume SHA-256
|
46
|
+
hash1 = Digest::SHA256.hexdigest(password + username)
|
47
|
+
covered_password = Digest::SHA256.hexdigest(hash1 + rnd_number)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
data/lib/kaseyaws.rb
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Copyright 2013 by Phillip Henslee (phenslee@towerdigital.us).
|
4
|
+
# All rights reserved.
|
5
|
+
|
6
|
+
# Permission is granted for use, copying, modification, distribution,
|
7
|
+
# and distribution of modified versions of this work as long as the
|
8
|
+
# above copyright notice is included.
|
9
|
+
#
|
10
|
+
|
11
|
+
# Provides a simple client for the Kaseya VSA web service.
|
12
|
+
|
13
|
+
require "kaseyaws/version"
|
14
|
+
require "kaseyaws/security"
|
15
|
+
require "savon"
|
16
|
+
|
17
|
+
module KaseyaWS
|
18
|
+
|
19
|
+
class Client
|
20
|
+
HASH_ALGORITHM = "SHA-256"
|
21
|
+
attr_accessor :client
|
22
|
+
|
23
|
+
def initialize (username,password,hostname)
|
24
|
+
|
25
|
+
@vsa_serviceurl = "https://" + hostname + "/vsaWS/kaseyaWS.asmx?WSDL"
|
26
|
+
@client_ip = KaseyaWS::Security.client_ip
|
27
|
+
@savon_options={
|
28
|
+
wsdl: @vsa_serviceurl,
|
29
|
+
convert_request_keys_to: :camelcase,
|
30
|
+
env_namespace: :soap,
|
31
|
+
open_timeout: 30,
|
32
|
+
log: false
|
33
|
+
}
|
34
|
+
@sessionid = self.authenticate(username,password)
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
# TODO To be added...
|
39
|
+
# def add_org(org_ref, org_name, default_dept_name, default_mg_name, website, no_emps, ann_revenue,
|
40
|
+
# method_of_contact, org_parent_ref, addr1, city, state, postal_code, country_ref, org_type
|
41
|
+
# primary_email, primary_phone, primary_fax, primary_staff_fk, browser_ip, sesion_id)
|
42
|
+
|
43
|
+
# client = Savon.client(@savon_options)
|
44
|
+
|
45
|
+
# response = client.call(:add_org, message: {req:[{
|
46
|
+
# group_name: group_name,
|
47
|
+
# scope_name: scope_name,
|
48
|
+
# browser_ip: @client_ip,
|
49
|
+
# session_i_d: @sessionid}]}
|
50
|
+
# )
|
51
|
+
# response.body[:get_machine_list_response][:get_machine_list_result]
|
52
|
+
# end
|
53
|
+
|
54
|
+
|
55
|
+
def add_mach_group_to_scope(group_name,scope_name)
|
56
|
+
|
57
|
+
response = self.client.call(:add_mach_group_to_scope, message: {req:[{
|
58
|
+
group_name: group_name,
|
59
|
+
scope_name: scope_name,
|
60
|
+
browser_ip: @client_ip,
|
61
|
+
session_i_d: @sessionid}]}
|
62
|
+
)
|
63
|
+
response.body[:add_mach_group_to_scope_response][:add_mach_group_to_scope_result]
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_org_to_scope(company_id,scope_id)
|
67
|
+
|
68
|
+
response = self.client.call(:add_org_to_scope, message: {req:[{
|
69
|
+
company_i_d: company_id,
|
70
|
+
scope_i_d: scope_id,
|
71
|
+
session_i_d: @sessionid}]}
|
72
|
+
)
|
73
|
+
response.body[:add_org_to_scope_response][:add_org_to_scope_result]
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_user_to_role(username,role_id)
|
77
|
+
|
78
|
+
response = self.client.call(:add_user_to_role, message: {req:[{
|
79
|
+
user_name: user_name,
|
80
|
+
role_i_d: role_id,
|
81
|
+
session_i_d: @sessionid}]}
|
82
|
+
)
|
83
|
+
response.body[:add_user_to_role_response][:add_user_to_role_result]
|
84
|
+
end
|
85
|
+
|
86
|
+
def authenticate(username,password)
|
87
|
+
|
88
|
+
random_number = KaseyaWS::Security.secure_random
|
89
|
+
covered_password = KaseyaWS::Security.compute_covered_password(username,password, random_number, HASH_ALGORITHM)
|
90
|
+
browser_ip = @client_ip
|
91
|
+
|
92
|
+
self.client = Savon::Client.new(@savon_options)
|
93
|
+
|
94
|
+
response = self.client.call(:authenticate, message: {req:[{
|
95
|
+
user_name: username,
|
96
|
+
covered_password: covered_password,
|
97
|
+
random_number: random_number,
|
98
|
+
browser_ip: browser_ip,
|
99
|
+
hashing_algorithm: HASH_ALGORITHM}]}
|
100
|
+
)
|
101
|
+
@sessionid = response.body[:authenticate_response][:authenticate_result][:session_id]
|
102
|
+
end
|
103
|
+
|
104
|
+
def close_alarm (monitor_alarm_id, notes)
|
105
|
+
|
106
|
+
response = self.client.call(:close_alarm, message: {req:[{
|
107
|
+
monitor_alarm_i_d: monitor_alarm_id,
|
108
|
+
notes: notes,
|
109
|
+
browser_ip: @client_ip,
|
110
|
+
session_i_d: @sessionid}]}
|
111
|
+
)
|
112
|
+
response.body[:close_alarm_response][:close_alarm_result]
|
113
|
+
end
|
114
|
+
|
115
|
+
def create_role (role_name,role_type,parent_role_name)
|
116
|
+
|
117
|
+
response = self.client.call(:create_role, message: {req:[{
|
118
|
+
role_name: role_name,
|
119
|
+
role_type: role_type,
|
120
|
+
parent_role_name: parent_role_name,
|
121
|
+
browser_ip: @client_ip,
|
122
|
+
session_i_d: @sessionid}]}
|
123
|
+
)
|
124
|
+
response.body[:create_role_response][:create_role_result]
|
125
|
+
end
|
126
|
+
|
127
|
+
def get_alarm (monitor_alarm_id)
|
128
|
+
|
129
|
+
response = self.client.call(:get_alarm, message: {req:[{
|
130
|
+
monitor_alarm_i_d: monitor_alarm_id,
|
131
|
+
browser_ip: @client_ip,
|
132
|
+
session_i_d: @sessionid}]}
|
133
|
+
)
|
134
|
+
response.body[:get_alarm_response][:get_alarm_result]
|
135
|
+
end
|
136
|
+
|
137
|
+
def get_alarm_list (get_all_records=true)
|
138
|
+
|
139
|
+
response = self.client.call(:get_alarm_list, message: {req:[{
|
140
|
+
return_all_records: get_all_records,
|
141
|
+
browser_ip: @client_ip,
|
142
|
+
session_i_d: @sessionid}]}
|
143
|
+
)
|
144
|
+
response.body[:get_alarm_list_response][:get_alarm_list_result]
|
145
|
+
end
|
146
|
+
|
147
|
+
def get_machine(machine_group_id)
|
148
|
+
|
149
|
+
response = self.client.call(:get_machine, message: {req:[{
|
150
|
+
machine___group_i_d: machine_group_id,
|
151
|
+
browser_ip: @client_ip,
|
152
|
+
session_i_d: @sessionid}]}
|
153
|
+
)
|
154
|
+
response.body[:get_machine_response][:get_machine_result]
|
155
|
+
end
|
156
|
+
|
157
|
+
def get_machine_group_list
|
158
|
+
|
159
|
+
response = self.client.call(:get_machine_group_list, message: {req:[{
|
160
|
+
browser_ip: @client_ip,
|
161
|
+
session_i_d: @sessionid}]}
|
162
|
+
)
|
163
|
+
response.body[:get_machine_group_list_response][:get_machine_group_list_result]
|
164
|
+
end
|
165
|
+
|
166
|
+
def get_machine_list(machine_group,machine_collection)
|
167
|
+
|
168
|
+
response = self.client.call(:get_machine_list, message: {req:[{
|
169
|
+
machine_group: machine_group,
|
170
|
+
machine_collection: machine_collection,
|
171
|
+
browser_ip: @client_ip,
|
172
|
+
session_i_d: @sessionid}]}
|
173
|
+
)
|
174
|
+
response.body[:get_machine_list_response][:get_machine_list_result]
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kaseyaws
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Phillip Henslee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: savon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
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: rake
|
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
|
+
description: '["A Ruby client for Kaseya web services"]'
|
70
|
+
email:
|
71
|
+
- phenslee@towerdigital.us
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- kaseyaws.gemspec
|
82
|
+
- lib/kaseyaws.rb
|
83
|
+
- lib/kaseyaws/security.rb
|
84
|
+
- lib/kaseyaws/version.rb
|
85
|
+
homepage: https://github.com/towerdigital/kaseyaws
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.0.3
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: '["A simple client for the Kaseya VSA web service"]'
|
109
|
+
test_files: []
|