chook 1.1.0 → 1.1.1
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 +4 -4
- data/CHANGES.md +7 -4
- data/README.md +289 -264
- data/data/chook.conf.example +82 -3
- data/lib/chook/configuration.rb +8 -1
- data/lib/chook/event/handled_event.rb +2 -2
- data/lib/chook/server.rb +24 -47
- data/lib/chook/server/auth.rb +164 -0
- data/lib/chook/server/public/css/chook.css +4 -0
- data/lib/chook/server/public/js/chook.js +20 -0
- data/lib/chook/server/routes.rb +7 -25
- data/lib/chook/server/routes/handle_webhook_event.rb +1 -1
- data/lib/chook/server/routes/handlers.rb +0 -2
- data/lib/chook/server/routes/home.rb +0 -1
- data/lib/chook/server/routes/log.rb +2 -3
- data/lib/chook/server/routes/login_logout.rb +48 -0
- data/lib/chook/server/views/layout.haml +21 -1
- data/lib/chook/version.rb +1 -1
- metadata +4 -2
@@ -30,7 +30,6 @@ module Chook
|
|
30
30
|
|
31
31
|
# reload the handlers
|
32
32
|
get '/reload_handlers' do
|
33
|
-
protected!
|
34
33
|
logger.info 'Reloading handlers'
|
35
34
|
Chook::HandledEvent::Handlers.load_handlers reload: true
|
36
35
|
'Handlers reloaded'
|
@@ -38,7 +37,6 @@ module Chook
|
|
38
37
|
|
39
38
|
# used by javascript to fetch the content of a handler
|
40
39
|
get '/handler_code/:file' do
|
41
|
-
protected!
|
42
40
|
file = Chook.config.handler_dir + params[:file]
|
43
41
|
if file.file?
|
44
42
|
body file.read
|
@@ -41,7 +41,8 @@ module Chook
|
|
41
41
|
# https://user:passwd@chookserver.myorg.org:443/log
|
42
42
|
#
|
43
43
|
post '/log' do
|
44
|
-
|
44
|
+
protect_via_basic_auth!
|
45
|
+
|
45
46
|
request.body.rewind # in case someone already read it
|
46
47
|
raw = request.body.read
|
47
48
|
|
@@ -72,7 +73,6 @@ module Chook
|
|
72
73
|
#
|
73
74
|
#
|
74
75
|
get '/subscribe_to_log_stream', provides: 'text/event-stream' do
|
75
|
-
protected!
|
76
76
|
content_type 'text/event-stream'
|
77
77
|
cache_control 'no-cache'
|
78
78
|
|
@@ -97,7 +97,6 @@ module Chook
|
|
97
97
|
|
98
98
|
# get the log level via the admin page.
|
99
99
|
get '/current_log_level' do
|
100
|
-
protected!
|
101
100
|
Chook::Server::Log::LOG_LEVELS.invert[Chook.logger.level].to_s
|
102
101
|
end
|
103
102
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
### Copyright 2017 Pixar
|
2
|
+
|
3
|
+
###
|
4
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
### with the following modification; you may not use this file except in
|
6
|
+
### compliance with the Apache License and the following modification to it:
|
7
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
###
|
9
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
### names, trademarks, service marks, or product names of the Licensor
|
11
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
### the License and to reproduce the content of the NOTICE file.
|
13
|
+
###
|
14
|
+
### You may obtain a copy of the Apache License at
|
15
|
+
###
|
16
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
###
|
18
|
+
### Unless required by applicable law or agreed to in writing, software
|
19
|
+
### distributed under the Apache License with the above modification is
|
20
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
### KIND, either express or implied. See the Apache License for the specific
|
22
|
+
### language governing permissions and limitations under the Apache License.
|
23
|
+
###
|
24
|
+
###
|
25
|
+
|
26
|
+
module Chook
|
27
|
+
|
28
|
+
# see server.rb
|
29
|
+
class Server < Sinatra::Base
|
30
|
+
|
31
|
+
# reload the handlers
|
32
|
+
get '/logout' do
|
33
|
+
session[:authed_admin] = nil
|
34
|
+
session[:auth_failed] = nil
|
35
|
+
redirect '/'
|
36
|
+
end # get /
|
37
|
+
|
38
|
+
# reload the handlers
|
39
|
+
post '/login' do
|
40
|
+
Chook.logger.debug "Attempting to log in #{params[:username]}"
|
41
|
+
session[:auth_failed] = !authenticate_admin(params[:username], params[:password])
|
42
|
+
redirect '/'
|
43
|
+
end # get /
|
44
|
+
|
45
|
+
|
46
|
+
end # class
|
47
|
+
|
48
|
+
end # module
|
@@ -34,6 +34,26 @@
|
|
34
34
|
%span.def_dialect Australian/NZ informal
|
35
35
|
%br/
|
36
36
|
%span.def_definition a chicken or fowl
|
37
|
+
%hr/
|
38
|
+
- if Chook.config.admin_user
|
39
|
+
#login_logout_div
|
37
40
|
|
41
|
+
- if session[:authed_admin]
|
42
|
+
%a{ href: '/logout' }
|
43
|
+
%button#logout_btn{ type: 'button' } Log Out
|
44
|
+
= yield
|
38
45
|
|
39
|
-
|
46
|
+
- else
|
47
|
+
%form#login_form{ name: 'login_form', method: 'POST', action: '/login' }
|
48
|
+
- if Chook.config.admin_user == Chook::Server::Auth::USE_JAMF_ADMIN_USER
|
49
|
+
Jamf Pro
|
50
|
+
Username:
|
51
|
+
%input#username{ type: :text, name: 'username' }
|
52
|
+
Password:
|
53
|
+
%input#password{ type: :password, name: 'password' }
|
54
|
+
%input#login_btn{ type: :submit, value: 'Log In' }
|
55
|
+
- if session[:auth_failed]
|
56
|
+
%span#login_incorrect Login Incorrect!
|
57
|
+
|
58
|
+
- else
|
59
|
+
= yield
|
data/lib/chook/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-10-
|
12
|
+
date: 2018-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/chook/handled_subjects.rb
|
125
125
|
- lib/chook/procs.rb
|
126
126
|
- lib/chook/server.rb
|
127
|
+
- lib/chook/server/auth.rb
|
127
128
|
- lib/chook/server/log.rb
|
128
129
|
- lib/chook/server/public/css/chook.css
|
129
130
|
- lib/chook/server/public/imgs/ChookLogoAlMcWhiggin.png
|
@@ -134,6 +135,7 @@ files:
|
|
134
135
|
- lib/chook/server/routes/handlers.rb
|
135
136
|
- lib/chook/server/routes/home.rb
|
136
137
|
- lib/chook/server/routes/log.rb
|
138
|
+
- lib/chook/server/routes/login_logout.rb
|
137
139
|
- lib/chook/server/views/admin.haml
|
138
140
|
- lib/chook/server/views/bak.haml
|
139
141
|
- lib/chook/server/views/config.haml
|