chook 1.0.0.b1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +174 -0
  3. data/README.md +259 -0
  4. data/bin/chook-server +28 -0
  5. data/data/sample_handlers/RestAPIOperation-executable +91 -0
  6. data/data/sample_handlers/RestAPIOperation.rb +45 -0
  7. data/data/sample_handlers/SmartGroupComputerMembershipChange-executable +47 -0
  8. data/data/sample_handlers/SmartGroupComputerMembershipChange.rb +33 -0
  9. data/data/sample_jsons/ComputerAdded.json +27 -0
  10. data/data/sample_jsons/ComputerCheckIn.json +27 -0
  11. data/data/sample_jsons/ComputerInventoryCompleted.json +27 -0
  12. data/data/sample_jsons/ComputerPolicyFinished.json +27 -0
  13. data/data/sample_jsons/ComputerPushCapabilityChanged.json +27 -0
  14. data/data/sample_jsons/JSSShutdown.json +14 -0
  15. data/data/sample_jsons/JSSStartup.json +14 -0
  16. data/data/sample_jsons/MobileDeviceCheckIn.json +26 -0
  17. data/data/sample_jsons/MobileDeviceCommandCompleted.json +26 -0
  18. data/data/sample_jsons/MobileDeviceEnrolled.json +26 -0
  19. data/data/sample_jsons/MobileDevicePushSent.json +26 -0
  20. data/data/sample_jsons/MobileDeviceUnEnrolled.json +26 -0
  21. data/data/sample_jsons/PatchSoftwareTitleUpdated.json +14 -0
  22. data/data/sample_jsons/PushSent.json +11 -0
  23. data/data/sample_jsons/README +4 -0
  24. data/data/sample_jsons/RestAPIOperation.json +15 -0
  25. data/data/sample_jsons/SCEPChallenge.json +10 -0
  26. data/data/sample_jsons/SmartGroupComputerMembershipChange.json +13 -0
  27. data/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +13 -0
  28. data/lib/chook.rb +38 -0
  29. data/lib/chook/configuration.rb +198 -0
  30. data/lib/chook/event.rb +153 -0
  31. data/lib/chook/event/handled_event.rb +154 -0
  32. data/lib/chook/event/handled_event/handlers.rb +206 -0
  33. data/lib/chook/event/test_event.rb +140 -0
  34. data/lib/chook/event_handling.rb +40 -0
  35. data/lib/chook/event_testing.rb +43 -0
  36. data/lib/chook/foundation.rb +33 -0
  37. data/lib/chook/handled_events.rb +33 -0
  38. data/lib/chook/handled_subjects.rb +33 -0
  39. data/lib/chook/procs.rb +46 -0
  40. data/lib/chook/server.rb +121 -0
  41. data/lib/chook/server/routes.rb +27 -0
  42. data/lib/chook/server/routes/handle_webhook_event.rb +39 -0
  43. data/lib/chook/server/routes/home.rb +37 -0
  44. data/lib/chook/subject.rb +143 -0
  45. data/lib/chook/subject/computer.rb +121 -0
  46. data/lib/chook/subject/handled_subject.rb +84 -0
  47. data/lib/chook/subject/jss.rb +56 -0
  48. data/lib/chook/subject/mobile_device.rb +115 -0
  49. data/lib/chook/subject/patch_software_title_update.rb +55 -0
  50. data/lib/chook/subject/push.rb +38 -0
  51. data/lib/chook/subject/randomizers.rb +506 -0
  52. data/lib/chook/subject/rest_api_operation.rb +62 -0
  53. data/lib/chook/subject/samplers.rb +360 -0
  54. data/lib/chook/subject/scep_challenge.rb +32 -0
  55. data/lib/chook/subject/smart_group.rb +50 -0
  56. data/lib/chook/subject/test_subject.rb +195 -0
  57. data/lib/chook/subject/validators.rb +117 -0
  58. data/lib/chook/test_events.rb +33 -0
  59. data/lib/chook/test_subjects.rb +33 -0
  60. data/lib/chook/version.rb +32 -0
  61. metadata +129 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: be77286c156ae0dd290704d210128d545f71186f
4
+ data.tar.gz: 39ceafe849ab9f66cf26e98b1868c8657aa688ea
5
+ SHA512:
6
+ metadata.gz: 6d3874811333ab0b06791cb49f2791ac5138a6b0fa0724f88c1251ffb0613ea44505c1ebfbc3f95304fa6cf4fc0362c8940f2898d68166c4f9601aa50e77afd7
7
+ data.tar.gz: c87b572097bc89d91c9eae034d06c1324965d97c037fe530ba15e0265d479fba9c5232b6d0addd041ea4f00c3ff1c879e0bad88d3ad78b1e9d4450a1318658e9
@@ -0,0 +1,174 @@
1
+
2
+ Modified Apache 2.0 License
3
+
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor
140
+ and its affiliates, except as required to comply with Section 4(c) of
141
+ the License and to reproduce the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
@@ -0,0 +1,259 @@
1
+
2
+ # Chook
3
+
4
+ - [Introduction](#introduction)
5
+ - [The Framework](#the-framework)
6
+ - [Event Handlers](#event-handlers)
7
+ - [Internal Handlers](#internal-handlers)
8
+ - [External Handlers](#external-handlers)
9
+ - [Putting It Together](#putting-it-together)
10
+ - [Events and Subjects](#events-and-subjects)
11
+ - [The Server](#the-server)
12
+ - [Installing Chook alongside ruby-jss](#installing-chook-alongside-ruby-jss)
13
+ - [TODOs](#todos)
14
+
15
+
16
+ ## Introduction
17
+
18
+ Chook is a Ruby module that implements a framework for working with webhook events
19
+ sent by the JSS, the core of [Jamf Pro](https://www.jamf.com/products/jamf-pro/),
20
+ a management tool for Apple devices.
21
+
22
+ Chook also provides a simple, sinatra-based HTTP server for handling those Events,
23
+ and classes for sending simulated TestEvents to a webhook handling server.
24
+
25
+ ** You do not need to be a Ruby developer to use this framework! **
26
+
27
+ The webhook handling server that comes with Chook can use "Event Handlers" written in
28
+ any language. See _Event Handlers_ and _The Server_ below for more information.
29
+
30
+ Chook is still in development. While many of the basics work,
31
+ there is much to be done before it can be considered complete.
32
+
33
+ Although Chook integrates well with [ruby-jss](http://pixaranimationstudios.github.io/ruby-jss/index.html),
34
+ it's a separate tool, and the two projects aren't dependent. However, ruby-jss
35
+ does become a requirement when using sampling features to generate TestEvents.
36
+
37
+ For more detail about the JSS webhooks API and the JSON data it passes, please see
38
+ [Bryson Tyrrell's documentation.](https://unofficial-jss-api-docs.atlassian.net/wiki/display/JRA/Webhooks+API)
39
+
40
+ **Note:** When creating webhooks from your JSS to be handled by the framework, you must
41
+ specify JSON in the "Content Type" section. This framework does not support XML.
42
+
43
+ ## The Framework
44
+
45
+ The Chook framework abstracts webhook Events and their components as Ruby
46
+ classes. When the JSON payload of a JSS webhook POST request is passed into the
47
+ `Chook::Event.parse_event` method, an instance of the appropriate subclass
48
+ of `Chook::Event` is returned, for example
49
+ `Chook::Event::ComputerInventoryCompletedEvent`
50
+
51
+ Each Event instance contains these important attributes:
52
+
53
+ * **webhook_id:** A read-only instance of the webhook ID stored in the JSS
54
+ which caused the POST request. This attribute matches the "webhook[:id]"
55
+ dictionary of the POSTed JSON.
56
+
57
+ * **webhook_name:** A read-only instance of the webhook name stored in the JSS
58
+ which caused the POST request. This attribute matches the "webhook[:name]"
59
+ dictionary of the POSTed JSON.
60
+
61
+ * **subject:** A read-only instance of a `Chook::Subject::<Class>`
62
+ representing the "subject" that accompanies the event that triggered the
63
+ webhook. It comes from the "event" dictionary of the POSTed JSON, and
64
+ different events come with different subjects attached. For example, the
65
+ ComputerInventoryCompleted event comes with a "computer" subject containing
66
+ data about the JSS computer that completed inventory.
67
+
68
+ This is not full `JSS::Computer` object from the REST API, but rather a group
69
+ of named attributes about that computer. At the moment, only the Chook Samplers
70
+ module attempts to look up subject data from the API, but any
71
+ Handlers written for the event could easily do a similar operation.
72
+
73
+ * **event_json:** The JSON content from the POST request, parsed into
74
+ a Ruby hash with symbolized keys (meaning the JSON key "deviceName" becomes
75
+ the symbol :deviceName).
76
+
77
+ * **raw_json:** A String containing the raw JSON from the POST
78
+ request.
79
+
80
+ * **handlers:** An Array of custom plug-ins for working with the
81
+ event. See _Event Handlers_, below.
82
+
83
+
84
+ ### Event Handlers
85
+
86
+ A handler is a file containing code to run when a webhook event occurs. These
87
+ files are located in a specified directory, `/Library/Application
88
+ Support/Chook/` by default, and are loaded at runtime. It's up to the Jamf
89
+ administrator to create these handlers to perform desired tasks. Each class of
90
+ event can have as many handlers as desired, all will be executed when the event's
91
+ `handle` method is called.
92
+
93
+ Handler files must begin with the name of the event they handle, e.g.
94
+ ComputerAdded, followed by: nothing, a dot, a dash, or an underscore. Handler
95
+ filenames are case-insensitive.
96
+
97
+ All of these file names are valid handlers for ComputerAdded events:
98
+
99
+ - ComputerAdded
100
+ - computeradded.sh
101
+ - COMPUTERAdded_notify_team
102
+ - Computeradded-update-ldap
103
+
104
+ There are two kinds of handlers:
105
+
106
+ #### Internal Handlers
107
+
108
+ These handlers are _non-executable_ files containing Ruby code. The code is
109
+ loaded at runtime and executed in the context of the Chook Framework when
110
+ called by an event.
111
+
112
+ Internal handlers must be defined as a [ruby code block](http://rubylearning.com/satishtalim/ruby_blocks.html) passed to the
113
+ `Chook.event_handler` method. The block must take one parameter, the
114
+ Chook::Event subclass instance being handled. Here's a simple example of
115
+ a handler for a Chook::ComputerAddedEvent
116
+
117
+ ```ruby
118
+ Chook.event_handler do |event|
119
+ cname = event.subject.deviceName
120
+ uname = event.subject.realName
121
+ puts "Computer '#{cname}' was just added to the JSS for user #{uname}."
122
+ end
123
+ ```
124
+
125
+ In this example, the code block takes one parameter, which it expects to be
126
+ a Chook::ComputerAddedEvent instance, and uses it in the variable "event."
127
+ It then extracts the "deviceName" and "realName" values from the subject
128
+ contained in the event, and uses them to send a message to stdout.
129
+
130
+ Internal handlers **must not** be executable files. Executability is how the
131
+ framework determines if a handler is internal or external.
132
+
133
+ #### External Handlers
134
+
135
+ External handlers are _executable_ files that are executed when called by an
136
+ event. They can be written in any language, but they must accept raw JSON on
137
+ their standard input. It's up to them to parse that JSON and react to it as
138
+ desired. In this case the Chook framework is merely a conduit for passing
139
+ the Posted JSON to the executable program.
140
+
141
+ Here's a simple example using bash and [jq](https://stedolan.github.io/jq/) to
142
+ do the same as the ruby example above:
143
+
144
+ ```bash
145
+ #!/bin/bash
146
+ JQ="/usr/local/bin/jq"
147
+ while read line ; do JSON="$JSON $line" ; done
148
+ cname=`echo $JSON | "$JQ" -r '.event.deviceName'`
149
+ uname=`echo $JSON | "$JQ" -r '.event.realName'`
150
+ echo "Computer '${cname}' was just added to the JSS for user ${uname}."
151
+ ```
152
+
153
+ External handlers **must** be executable files. Executability is how the
154
+ framework determines if a handler is internal or external.
155
+
156
+ See `data/sample_handlers/RestAPIOperation-executable`
157
+ for a more detailed bash example that handles RestAPIOperation events.
158
+
159
+ ### Putting It Together
160
+
161
+ Here is a commented sample of ruby code that uses the framework to process a
162
+ ComputerAdded Event:
163
+
164
+ ```ruby
165
+ # load the framework
166
+ require 'chook'
167
+
168
+ # The framework comes with sample JSON files for each Event type.
169
+ # In reality, a webserver would extract this from the data POSTed from the JSS
170
+ posted_json = Chook.sample_jsons[:ComputerAdded]
171
+
172
+ # Create Chook::HandledEvents::ComputerAddedEvent instance for the event
173
+ event = Chook::HandledEvent.parse_event posted_json
174
+
175
+ # Call the events #handle method, which will execute any ComputerAdded
176
+ # handlers that were in the Handler directory when the framework was loaded.
177
+ event.handle
178
+ ```
179
+
180
+ Of course, you can use the framework without using the built-in #handle method,
181
+ and if you don't have any handlers in the directory, it won't do anything
182
+ anyway. Instead you are welcome to use the objects as desired in your own
183
+ Ruby code.
184
+
185
+ ### Events and Subjects
186
+
187
+ Here are the Event classes supported by the framework and the Subject classes
188
+ they contain.
189
+ For details about the attributes of each Subject, see [The Unofficial JSS API
190
+ Docs](https://unofficial-jss-api-docs.atlassian.net/wiki/display/JRA/Webhooks+API).
191
+
192
+ Each Event class is a subclass of `Chook::Event`, where all of their
193
+ functionality is defined.
194
+
195
+ The Subject classes aren't subclasses, but are dynamically-defined members of
196
+ the `Chook::Subjects` module.
197
+
198
+ | Event Classes | Subject Classes |
199
+ | -------------- | ------------ |
200
+ | Chook::ComputerAddedEvent | Chook::Subjects::Computer |
201
+ | Chook::ComputerCheckInEvent | Chook::Subjects::Computer |
202
+ | Chook::ComputerInventoryCompletedEvent | Chook::Subjects::Computer |
203
+ | Chook::ComputerPolicyFinishedEvent | Chook::Subjects::Computer |
204
+ | Chook::ComputerPushCapabilityChangedEvent | Chook::Subjects::Computer |
205
+ | Chook::JSSShutdownEvent | Chook::Subjects::JSS |
206
+ | Chook::JSSStartupEvent | Chook::Subjects::JSS |
207
+ | Chook::MobileDeviceCheckinEvent | Chook::Subjects::MobileDevice |
208
+ | Chook::MobileDeviceCommandCompletedEvent | Chook::Subjects::MobileDevice |
209
+ | Chook::MobileDeviceEnrolledEvent | Chook::Subjects::MobileDevice |
210
+ | Chook::MobileDevicePushSentEvent | Chook::Subjects::MobileDevice |
211
+ | Chook::MobileDeviceUnenrolledEvent | Chook::Subjects::MobileDevice |
212
+ | Chook::PatchSoftwareTitleUpdateEvent | Chook::Subjects::PatchSoftwareTitleUpdate |
213
+ | Chook::PushSentEvent | Chook::Subjects::Push |
214
+ | Chook::RestAPIOperationEvent | Chook::Subjects::RestAPIOperation |
215
+ | Chook::SCEPChallengeEvent | Chook::Subjects::SCEPChallenge |
216
+ | Chook::SmartGroupComputerMembershipChangeEvent | Chook::Subjects::SmartGroup |
217
+ | Chook::SmartGroupMobileDeviveMembershipChangeEvent | Chook::Subjects::SmartGroup |
218
+
219
+
220
+ ## The Server
221
+
222
+ Chook comes with a simple HTTP server that uses the Chook framework
223
+ to handle all incoming webhook POST requests from the JSS via a single URL.
224
+
225
+ To use it you'll need the [sinatra](http://www.sinatrarb.com/)
226
+ ruby gem (`gem install sinatra`).
227
+
228
+ After that, just run the `chook-server` command located in the bin
229
+ directory for chook and then point your webhooks at:
230
+ http://my_hostname/handle_webhook_event
231
+
232
+ It will then process all incoming webhook POST requests using whatever handlers
233
+ you have installed.
234
+
235
+ To automate it on a dedicated machine, just make a LaunchDaemon plist to run
236
+ that command and keep it running.
237
+
238
+ ## Installing Chook
239
+
240
+ `gem install chook -n /usr/local/bin`. It will also install "sinatra."
241
+
242
+ Then fire up `irb` and `require chook` to start playing around.
243
+
244
+ OR
245
+
246
+ run `/usr/local/bin/chook` and point some JSS webhooks at that machine.
247
+
248
+
249
+ ## TODOs
250
+
251
+ - Add SSL support to the server
252
+ - Improved thread management for handlers
253
+ - Logging and Debug options
254
+ - Handler reloading for individual, or all, Event subclasses
255
+ - Better YARD docs
256
+ - Better namespace protection for internal handlers
257
+ - Improved configuration
258
+ - Proper documentation beyond this README
259
+ - I'm sure there's more to do...
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/ruby
2
+
3
+ ### Copyright 2017 Pixar
4
+
5
+ ###
6
+ ### Licensed under the Apache License, Version 2.0 (the "Apache License")
7
+ ### with the following modification; you may not use this file except in
8
+ ### compliance with the Apache License and the following modification to it:
9
+ ### Section 6. Trademarks. is deleted and replaced with:
10
+ ###
11
+ ### 6. Trademarks. This License does not grant permission to use the trade
12
+ ### names, trademarks, service marks, or product names of the Licensor
13
+ ### and its affiliates, except as required to comply with Section 4(c) of
14
+ ### the License and to reproduce the content of the NOTICE file.
15
+ ###
16
+ ### You may obtain a copy of the Apache License at
17
+ ###
18
+ ### http://www.apache.org/licenses/LICENSE-2.0
19
+ ###
20
+ ### Unless required by applicable law or agreed to in writing, software
21
+ ### distributed under the Apache License with the above modification is
22
+ ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
+ ### KIND, either express or implied. See the Apache License for the specific
24
+ ### language governing permissions and limitations under the Apache License.
25
+ ###
26
+ ###
27
+ require 'chook/server'
28
+ Chook::Server.run!