proxes 0.2.0 → 0.3.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 +4 -4
- data/.travis.yml +4 -0
- data/Gemfile.ci +2 -1
- data/README.md +2 -1
- data/config.ru +0 -1
- data/config/logger.yml +0 -1
- data/lib/proxes/container.rb +14 -3
- data/lib/proxes/controllers/application.rb +4 -3
- data/lib/proxes/controllers/component.rb +29 -6
- data/lib/proxes/controllers/users.rb +26 -7
- data/lib/proxes/helpers/pundit.rb +1 -1
- data/lib/proxes/listener.rb +0 -4
- data/lib/proxes/policies/request/root_policy.rb +2 -2
- data/lib/proxes/policies/request/search_policy.rb +2 -2
- data/lib/proxes/policies/request/snapshot_policy.rb +2 -2
- data/lib/proxes/policies/request/stats_policy.rb +2 -2
- data/lib/proxes/proxes.rb +35 -0
- data/lib/proxes/request.rb +1 -1
- data/lib/proxes/request/root.rb +1 -1
- data/lib/proxes/request/search.rb +1 -1
- data/lib/proxes/request/snapshot.rb +1 -1
- data/lib/proxes/request/stats.rb +1 -1
- data/lib/proxes/security.rb +4 -4
- data/lib/proxes/version.rb +1 -1
- data/migrate/{001_tables.rb → 20170207_01_base_tables.rb} +0 -0
- data/migrate/{002_audit_log.rb → 20170207_02_audit_log.rb} +0 -0
- data/proxes.gemspec +1 -0
- data/src/scripts/app.js +6 -1
- data/views/partials/sidebar.haml +6 -17
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b504f6a2dcb6fa6d41872ad0d203d5a57324567
|
4
|
+
data.tar.gz: 203323938f3a6ad123d14a9bd7934af90f40912f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d14a2a8d057c7f9c8b94b2c05e72de6d6df3f91719ef41bd93fc5af069960fe8c039f315c6e1394fbaec3b5f8c91b533d498df6a0f7cd524f7a45bd8809a0c4
|
7
|
+
data.tar.gz: '0490f5333bbc15dce6c32e9bc6e87dfba9314090482e83a14e7f8753d54512edb765b6d571be5f6d8b03af625a61ffd1f011a06539be5ff5f56c1f61f2305cae'
|
data/.travis.yml
CHANGED
data/Gemfile.ci
CHANGED
@@ -6,8 +6,9 @@ gemspec
|
|
6
6
|
gem 'sqlite3'
|
7
7
|
gem 'simplecov'
|
8
8
|
gem 'codeclimate-test-reporter', '~> 1.0.0'
|
9
|
-
if RUBY_VERSION < '1
|
9
|
+
if RUBY_VERSION < '2.1'
|
10
10
|
gem 'activesupport', '<4.0.0'
|
11
|
+
gem 'omniauth', '~>1.4.2'
|
11
12
|
elsif RUBY_VERSION < '2.2.0'
|
12
13
|
gem 'activesupport', '<5.0.0'
|
13
14
|
else
|
data/README.md
CHANGED
@@ -47,7 +47,8 @@ gem install proxes
|
|
47
47
|
|
48
48
|
1. Add the components to your rack config file. See the included [`config.ru`](https://github.com/EagerELK/proxes/blob/master/config.ru) file for an example setup
|
49
49
|
2. Add the ProxES rake tasks to your Rakefile: `require 'proxes/rake_tasks'`
|
50
|
-
3.
|
50
|
+
3. Set the DB connection as the `DATABASE_URL` ENV variable: `DATABASE_URL=sqlite://development.db`
|
51
|
+
4. Create and populate the DB:
|
51
52
|
|
52
53
|
```bash
|
53
54
|
bundle exec rake proxes:migrate
|
data/config.ru
CHANGED
@@ -14,7 +14,6 @@ Sequel.extension :migration
|
|
14
14
|
Sequel::Migrator.check_current(DB, './migrate')
|
15
15
|
|
16
16
|
use Rack::Static, urls: ['/css', '/js'], root: 'public'
|
17
|
-
use Rack::MethodOverride
|
18
17
|
use Rack::Session::Cookie,
|
19
18
|
key: '_ProxES_session',
|
20
19
|
#:secure=>!TEST_MODE, # Uncomment if only allowing https:// access
|
data/config/logger.yml
CHANGED
data/lib/proxes/container.rb
CHANGED
@@ -25,6 +25,10 @@ module ProxES
|
|
25
25
|
def map(&block)
|
26
26
|
@mutex.synchronize{@hash.map(&block)}
|
27
27
|
end
|
28
|
+
|
29
|
+
def inject(memo, &block)
|
30
|
+
@mutex.synchronize{@hash.inject(memo, &block)}
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
# Ripped off from Roda - https://github.com/jeremyevans/roda
|
@@ -80,12 +84,19 @@ module ProxES
|
|
80
84
|
nil
|
81
85
|
end
|
82
86
|
|
87
|
+
# Return a hash of controllers with their routes as keys: `{ '/users' => ProxES::Controllers::Users }`
|
83
88
|
def routes
|
84
|
-
{}
|
89
|
+
Plugins.plugins.inject({}) do |memo, plugin|
|
90
|
+
memo.merge!(plugin[1].route_mappings) if plugin[1].respond_to?(:route_mappings)
|
91
|
+
memo
|
92
|
+
end
|
85
93
|
end
|
86
94
|
|
87
|
-
|
88
|
-
|
95
|
+
# Return an ordered list of navigation items: `[{order:0, link:'/users/', text:'Users'}, {order:1, link:'/roles/', text:'Roles'}]
|
96
|
+
def navigation
|
97
|
+
Plugins.plugins.map do |_key, plugin|
|
98
|
+
plugin.nav_items if plugin.respond_to?(:nav_items)
|
99
|
+
end.flatten.sort_by { |h| h[:order] }
|
89
100
|
end
|
90
101
|
|
91
102
|
def migrations
|
@@ -13,12 +13,13 @@ module ProxES
|
|
13
13
|
class Application < Sinatra::Base
|
14
14
|
set :root, ::File.expand_path(::File.dirname(__FILE__) + '/../../../')
|
15
15
|
# The order here is important, since Wisper has a deprecated method respond_with method
|
16
|
-
helpers Wisper::Publisher,
|
17
|
-
helpers
|
16
|
+
helpers Wisper::Publisher, Helpers::Wisper
|
17
|
+
helpers Helpers::Pundit, Helpers::Views, Helpers::Authentication
|
18
18
|
|
19
19
|
register Sinatra::Flash, Sinatra::RespondWith
|
20
20
|
|
21
21
|
use Rack::PostBodyContentTypeParser
|
22
|
+
use Rack::MethodOverride
|
22
23
|
|
23
24
|
configure :production do
|
24
25
|
disable :show_exceptions
|
@@ -41,7 +42,7 @@ module ProxES
|
|
41
42
|
haml :error, locals: { title: 'Something went wrong', message: error }
|
42
43
|
end
|
43
44
|
|
44
|
-
error
|
45
|
+
error Helpers::NotAuthenticated do
|
45
46
|
flash[:warning] = 'Please log in first.'
|
46
47
|
redirect '/auth/identity'
|
47
48
|
end
|
@@ -4,7 +4,7 @@ require 'proxes/helpers/component'
|
|
4
4
|
|
5
5
|
module ProxES
|
6
6
|
class Component < Application
|
7
|
-
helpers
|
7
|
+
helpers Helpers::Component
|
8
8
|
set base_path: nil
|
9
9
|
set dehumanized: nil
|
10
10
|
set view_location: nil
|
@@ -105,10 +105,24 @@ module ProxES
|
|
105
105
|
success = entity.valid? && entity.save
|
106
106
|
log_action("#{dehumanized}_update".to_sym) if success && settings.track_actions
|
107
107
|
if success
|
108
|
-
|
109
|
-
|
108
|
+
respond_to do |format|
|
109
|
+
format.html do
|
110
|
+
flash[:success] = "#{heading} Updated"
|
111
|
+
redirect "#{base_path}/#{entity.id}"
|
112
|
+
end
|
113
|
+
format.json do
|
114
|
+
content_type 'application/json'
|
115
|
+
headers 'Location' => "#{base_path}/#{entity.id}"
|
116
|
+
body entity.to_hash.to_json
|
117
|
+
status 200
|
118
|
+
end
|
119
|
+
end
|
110
120
|
else
|
111
|
-
|
121
|
+
respond_to do |format|
|
122
|
+
format.html do
|
123
|
+
haml :"#{view_location}/edit", locals: { entity: entity, title: heading(:edit) }
|
124
|
+
end
|
125
|
+
end
|
112
126
|
end
|
113
127
|
end
|
114
128
|
|
@@ -120,8 +134,17 @@ module ProxES
|
|
120
134
|
entity.destroy
|
121
135
|
|
122
136
|
log_action("#{dehumanized}_delete".to_sym) if settings.track_actions
|
123
|
-
|
124
|
-
|
137
|
+
respond_to do |format|
|
138
|
+
format.html do
|
139
|
+
flash[:success] = "#{heading} Deleted"
|
140
|
+
redirect base_path.to_s
|
141
|
+
end
|
142
|
+
format.json do
|
143
|
+
content_type 'application/json'
|
144
|
+
headers 'Location' => '/_proxes/users'
|
145
|
+
status 204
|
146
|
+
end
|
147
|
+
end
|
125
148
|
end
|
126
149
|
end
|
127
150
|
end
|
@@ -16,8 +16,8 @@ module ProxES
|
|
16
16
|
|
17
17
|
locals = {
|
18
18
|
title: heading(:new),
|
19
|
-
entity:
|
20
|
-
identity:
|
19
|
+
entity: User.new,
|
20
|
+
identity: Identity.new
|
21
21
|
}
|
22
22
|
haml :"#{view_location}/new", locals: locals, layout_opts: { locals: locals }
|
23
23
|
end
|
@@ -93,8 +93,18 @@ module ProxES
|
|
93
93
|
roles.each { |role_id| entity.add_role(role_id) } if roles
|
94
94
|
entity.check_roles
|
95
95
|
log_action("#{dehumanized}_update".to_sym) if settings.track_actions
|
96
|
-
|
97
|
-
|
96
|
+
respond_to do |format|
|
97
|
+
format.html do
|
98
|
+
flash[:success] = "#{heading} Updated"
|
99
|
+
redirect "/_proxes/users/#{entity.id}"
|
100
|
+
end
|
101
|
+
format.json do
|
102
|
+
content_type 'application/json'
|
103
|
+
headers 'Location' => "/_proxes/users/#{entity.id}"
|
104
|
+
body entity.to_hash.to_json
|
105
|
+
status 200
|
106
|
+
end
|
107
|
+
end
|
98
108
|
else
|
99
109
|
haml :"#{view_location}/edit", locals: { entity: entity, title: heading(:edit) }
|
100
110
|
end
|
@@ -119,7 +129,7 @@ module ProxES
|
|
119
129
|
end
|
120
130
|
|
121
131
|
# Delete
|
122
|
-
delete '/:id' do |id|
|
132
|
+
delete '/:id', provides: [:html, :json] do |id|
|
123
133
|
entity = dataset[id.to_i]
|
124
134
|
halt 404 unless entity
|
125
135
|
authorize entity, :delete
|
@@ -129,8 +139,17 @@ module ProxES
|
|
129
139
|
entity.destroy
|
130
140
|
|
131
141
|
log_action("#{dehumanized}_delete".to_sym) if settings.track_actions
|
132
|
-
|
133
|
-
|
142
|
+
respond_to do |format|
|
143
|
+
format.html do
|
144
|
+
flash[:success] = "#{heading} Deleted"
|
145
|
+
redirect '/_proxes/users'
|
146
|
+
end
|
147
|
+
format.json do
|
148
|
+
content_type 'application/json'
|
149
|
+
headers 'Location' => '/_proxes/users'
|
150
|
+
status 204
|
151
|
+
end
|
152
|
+
end
|
134
153
|
end
|
135
154
|
|
136
155
|
# Profile
|
data/lib/proxes/listener.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module ProxES
|
3
3
|
class Request
|
4
|
-
class SearchPolicy <
|
5
|
-
class Scope <
|
4
|
+
class SearchPolicy < RequestPolicy
|
5
|
+
class Scope < RequestPolicy::Scope
|
6
6
|
def resolve
|
7
7
|
patterns = ProxES::Permission.where(verb: 'INDEX', role: user.roles).map do |permission|
|
8
8
|
permission.pattern.gsub(/\{user.(.*)\}/) { |match| user.send(Regexp.last_match[1].to_sym) }
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module ProxES
|
3
3
|
class Request
|
4
|
-
class StatsPolicy <
|
5
|
-
class Scope <
|
4
|
+
class StatsPolicy < RequestPolicy
|
5
|
+
class Scope < RequestPolicy::Scope
|
6
6
|
def resolve
|
7
7
|
patterns = ProxES::Permission.where(verb: 'INDEX', role: user.roles).map do |permission|
|
8
8
|
permission.pattern.gsub(/\{user.(.*)\}/) { |match| user.send(Regexp.last_match[1].to_sym) }
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'proxes'
|
3
|
+
require 'proxes/db'
|
4
|
+
require 'proxes/controllers/users'
|
5
|
+
require 'proxes/controllers/roles'
|
6
|
+
require 'proxes/controllers/permissions'
|
7
|
+
require 'proxes/controllers/audit_logs'
|
8
|
+
|
9
|
+
module ProxES
|
10
|
+
class ProxES
|
11
|
+
def self.migration_folder
|
12
|
+
File.expand_path('../../../migrate', __FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.route_mappings
|
16
|
+
{
|
17
|
+
'/' => App,
|
18
|
+
'/users' => Users,
|
19
|
+
'/roles' => Roles,
|
20
|
+
'/permissions' => Permissions,
|
21
|
+
'/audit-logs' => AuditLogs,
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.nav_items
|
26
|
+
[
|
27
|
+
{ order: 0, link:'/users/', text: 'Users', target: User, icon: 'user' },
|
28
|
+
{ order: 1, link:'/roles/', text: 'Roles', target: Role, icon: 'group' },
|
29
|
+
{ order: 2, link:'/permissions/', text: 'Permissions', target: Permission, icon: 'check-square' },
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
ProxES::Container::Plugins.register_plugin(:proxes, ProxES::ProxES)
|
data/lib/proxes/request.rb
CHANGED
data/lib/proxes/request/root.rb
CHANGED
data/lib/proxes/request/stats.rb
CHANGED
data/lib/proxes/security.rb
CHANGED
@@ -11,12 +11,12 @@ module ProxES
|
|
11
11
|
class Security
|
12
12
|
attr_reader :env, :logger
|
13
13
|
|
14
|
-
include
|
15
|
-
include
|
14
|
+
include Helpers::Authentication
|
15
|
+
include Helpers::Pundit
|
16
16
|
|
17
17
|
def initialize(app, logger = nil)
|
18
18
|
@app = app
|
19
|
-
@logger = logger ||
|
19
|
+
@logger = logger || Services::Logger.instance
|
20
20
|
end
|
21
21
|
|
22
22
|
def error(message, code = 500)
|
@@ -26,7 +26,7 @@ module ProxES
|
|
26
26
|
def call(env)
|
27
27
|
@env = env
|
28
28
|
|
29
|
-
request =
|
29
|
+
request = Request.from_env(env)
|
30
30
|
|
31
31
|
logger.debug '==========================BEFORE================================================'
|
32
32
|
logger.debug '= ' + "Request: #{request.fullpath}".ljust(76) + ' ='
|
data/lib/proxes/version.rb
CHANGED
File without changes
|
File without changes
|
data/proxes.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'database_cleaner'
|
29
29
|
spec.add_development_dependency 'factory_girl'
|
30
30
|
|
31
|
+
spec.add_dependency 'rake', '~> 10.0'
|
31
32
|
spec.add_dependency 'rack-proxy'
|
32
33
|
spec.add_dependency 'rack-contrib'
|
33
34
|
spec.add_dependency 'sinatra'
|
data/src/scripts/app.js
CHANGED
@@ -2,4 +2,9 @@ import React from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
3
3
|
import ProxesComponents from 'react-proxes-components/react-proxes-components';
|
4
4
|
|
5
|
-
ReactDOM.render(<ProxesComponents pollInterval="30000"
|
5
|
+
ReactDOM.render(<ProxesComponents pollInterval="30000"/>, document.getElementById('react-dashboard'));
|
6
|
+
|
7
|
+
// ReactDOM.render(
|
8
|
+
// <Health store={new ESStore()}/>,
|
9
|
+
// document.getElementById('indexlist')
|
10
|
+
// );
|
data/views/partials/sidebar.haml
CHANGED
@@ -4,23 +4,12 @@
|
|
4
4
|
%a{ href: '/_proxes' }
|
5
5
|
%i.fa.fa-dashboard.fa-fw
|
6
6
|
Dashboard
|
7
|
-
-
|
8
|
-
|
9
|
-
%
|
10
|
-
%
|
11
|
-
|
12
|
-
|
13
|
-
%a{ href: '/_proxes/roles' }
|
14
|
-
%i.fa.fa-group.fa-fw
|
15
|
-
Roles
|
16
|
-
%li
|
17
|
-
%a{ href: '/_proxes/permissions' }
|
18
|
-
%i.fa.fa-check-square-o.fa-fw
|
19
|
-
Permissions
|
20
|
-
%li
|
21
|
-
%a{ href: '/_proxes/settings' }
|
22
|
-
%i.fa.fa-cog.fa-fw
|
23
|
-
Settings
|
7
|
+
- ProxES::Container.navigation.each do |item|
|
8
|
+
- if policy(item[:target]).list?
|
9
|
+
%li
|
10
|
+
%a{ href: "/_proxes#{item[:link]}" }
|
11
|
+
%i.fa.fa-fw{ class: "fa-#{item[:icon]}" }
|
12
|
+
= item[:text]
|
24
13
|
- else
|
25
14
|
%li.active
|
26
15
|
%a{ href: '/auth/identity' }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proxes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurgens du Toit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '10.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '10.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rack-proxy
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -383,6 +397,7 @@ files:
|
|
383
397
|
- lib/proxes/policies/role_policy.rb
|
384
398
|
- lib/proxes/policies/token_policy.rb
|
385
399
|
- lib/proxes/policies/user_policy.rb
|
400
|
+
- lib/proxes/proxes.rb
|
386
401
|
- lib/proxes/rake_tasks.rb
|
387
402
|
- lib/proxes/request.rb
|
388
403
|
- lib/proxes/request/root.rb
|
@@ -393,8 +408,8 @@ files:
|
|
393
408
|
- lib/proxes/seed.rb
|
394
409
|
- lib/proxes/services/logger.rb
|
395
410
|
- lib/proxes/version.rb
|
396
|
-
- migrate/
|
397
|
-
- migrate/
|
411
|
+
- migrate/20170207_01_base_tables.rb
|
412
|
+
- migrate/20170207_02_audit_log.rb
|
398
413
|
- package.json
|
399
414
|
- proxes.gemspec
|
400
415
|
- public/js/bundle.js
|
@@ -450,7 +465,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
450
465
|
version: '0'
|
451
466
|
requirements: []
|
452
467
|
rubyforge_project:
|
453
|
-
rubygems_version: 2.6.
|
468
|
+
rubygems_version: 2.6.10
|
454
469
|
signing_key:
|
455
470
|
specification_version: 4
|
456
471
|
summary: Rack wrapper around Elasticsearch to provide security and management features
|