-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ru
More file actions
33 lines (24 loc) · 770 Bytes
/
config.ru
File metadata and controls
33 lines (24 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'active_support/time'
require 'active_support'
require 'dashing'
require 'yaml'
$global_config = YAML.load_file('./config/integrations.yml')
configure do
set :auth_token, 'YOUR_AUTH_TOKEN'
helpers do
def protected!
unless authorized?
response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
throw(:halt, [401, "Not authorized\n"])
end
end
def authorized?
@auth ||= Rack::Auth::Basic::Request.new(request.env)
@auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [$global_config['dashboard_username'], $global_config['dashboard_password']]
end
end
end
map Sinatra::Application.assets_prefix do
run Sinatra::Application.sprockets
end
run Sinatra::Application