proxes 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +0 -0
- data/.gitignore +0 -0
- data/.pryrc +6 -0
- data/.rspec +0 -0
- data/.rubocop.yml +0 -0
- data/.ruby-version +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/Gemfile.ci +0 -0
- data/Gemfile.dev +1 -1
- data/Gemfile.dev.lock +14 -3
- data/LICENSE.txt +1 -1
- data/README.md +7 -3
- data/Rakefile +0 -0
- data/Vagrantfile +0 -0
- data/config.ru +2 -0
- data/config/logger.yml +1 -0
- data/gulpfile.js +0 -0
- data/lib/proxes.rb +1 -1
- data/lib/proxes/app.rb +7 -6
- data/lib/proxes/container.rb +106 -0
- data/lib/proxes/controllers/application.rb +9 -1
- data/lib/proxes/controllers/audit_logs.rb +0 -0
- data/lib/proxes/controllers/auth_identity.rb +1 -0
- data/lib/proxes/controllers/component.rb +25 -6
- data/lib/proxes/controllers/permissions.rb +0 -0
- data/lib/proxes/controllers/roles.rb +0 -0
- data/lib/proxes/controllers/users.rb +35 -9
- data/lib/proxes/db.rb +0 -0
- data/lib/proxes/helpers/authentication.rb +0 -0
- data/lib/proxes/helpers/component.rb +4 -0
- data/lib/proxes/helpers/indices.rb +0 -0
- data/lib/proxes/helpers/pundit.rb +0 -0
- data/lib/proxes/helpers/views.rb +0 -0
- data/lib/proxes/helpers/wisper.rb +14 -0
- data/lib/proxes/listener.rb +21 -0
- data/lib/proxes/loggers/elasticsearch.rb +0 -0
- data/lib/proxes/models/audit_log.rb +3 -3
- data/lib/proxes/models/base.rb +3 -0
- data/lib/proxes/models/identity.rb +2 -2
- data/lib/proxes/models/permission.rb +2 -2
- data/lib/proxes/models/role.rb +2 -2
- data/lib/proxes/models/user.rb +2 -2
- data/lib/proxes/policies/application_policy.rb +0 -0
- data/lib/proxes/policies/audit_log_policy.rb +0 -0
- data/lib/proxes/policies/identity_policy.rb +0 -0
- data/lib/proxes/policies/permission_policy.rb +0 -0
- data/lib/proxes/policies/request/root_policy.rb +0 -0
- data/lib/proxes/policies/request/search_policy.rb +0 -0
- data/lib/proxes/policies/request/snapshot_policy.rb +0 -0
- data/lib/proxes/policies/request/stats_policy.rb +0 -0
- data/lib/proxes/policies/request_policy.rb +0 -2
- data/lib/proxes/policies/role_policy.rb +0 -0
- data/lib/proxes/policies/token_policy.rb +0 -0
- data/lib/proxes/policies/user_policy.rb +0 -0
- data/lib/proxes/rake_tasks.rb +0 -0
- data/lib/proxes/request.rb +0 -0
- data/lib/proxes/request/root.rb +0 -0
- data/lib/proxes/request/search.rb +0 -0
- data/lib/proxes/request/snapshot.rb +0 -0
- data/lib/proxes/request/stats.rb +0 -0
- data/lib/proxes/security.rb +0 -0
- data/lib/proxes/seed.rb +0 -1
- data/lib/proxes/services/logger.rb +0 -0
- data/lib/proxes/version.rb +1 -1
- data/migrate/001_tables.rb +0 -0
- data/migrate/002_audit_log.rb +1 -1
- data/package.json +0 -0
- data/proxes.gemspec +2 -0
- data/public/js/bundle.js +0 -0
- data/src/scripts/app.js +1 -6
- data/views/404.haml +0 -0
- data/views/audit_logs/index.haml +4 -1
- data/views/error.haml +0 -0
- data/views/getting_started.haml +0 -0
- data/views/identity/login.haml +0 -0
- data/views/identity/register.haml +0 -0
- data/views/index.haml +0 -0
- data/views/layout.haml +0 -0
- data/views/partials/delete_form.haml +0 -0
- data/views/partials/form_control.haml +0 -0
- data/views/partials/navbar.haml +0 -0
- data/views/partials/notifications.haml +0 -0
- data/views/partials/pager.haml +0 -0
- data/views/partials/sidebar.haml +0 -0
- data/views/permissions/display.haml +0 -0
- data/views/permissions/edit.haml +0 -0
- data/views/permissions/form.haml +0 -0
- data/views/permissions/index.haml +0 -0
- data/views/permissions/new.haml +0 -0
- data/views/roles/display.haml +0 -0
- data/views/roles/edit.haml +0 -0
- data/views/roles/form.haml +0 -0
- data/views/roles/index.haml +0 -0
- data/views/roles/new.haml +0 -0
- data/views/users/display.haml +0 -0
- data/views/users/edit.haml +0 -0
- data/views/users/identity.haml +0 -0
- data/views/users/index.haml +0 -0
- data/views/users/new.haml +0 -0
- data/views/users/profile.haml +0 -0
- data/views/users/user.haml +0 -0
- metadata +35 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f09dfca277df91363c5c406d7f7a2a04538ac709
|
4
|
+
data.tar.gz: 272207ef5bc8708b42cc5cfb41790e68ee54ffb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ac4a096a65c81667622c772e049352f15cd7bb78bbda5f4c5641968ebcf8f95cf441ec66f200e1aa4e8ae119475addd2840b9f62d9825a5fc07a05fe6b925a
|
7
|
+
data.tar.gz: 0c19669d5c38423cdf8b1f81f0f0d287a20378c7e848b296d200c0a8539454871746654c67e464a2fba978f0a75cd7d546e3eee81a57fb0c7996fcb9fe3dd450
|
data/.codeclimate.yml
CHANGED
File without changes
|
data/.gitignore
CHANGED
File without changes
|
data/.pryrc
ADDED
data/.rspec
CHANGED
File without changes
|
data/.rubocop.yml
CHANGED
File without changes
|
data/.ruby-version
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/Gemfile.ci
CHANGED
File without changes
|
data/Gemfile.dev
CHANGED
data/Gemfile.dev.lock
CHANGED
@@ -9,7 +9,7 @@ GIT
|
|
9
9
|
PATH
|
10
10
|
remote: .
|
11
11
|
specs:
|
12
|
-
proxes (0.
|
12
|
+
proxes (0.2.0)
|
13
13
|
bcrypt
|
14
14
|
elasticsearch
|
15
15
|
haml
|
@@ -17,12 +17,14 @@ PATH
|
|
17
17
|
omniauth
|
18
18
|
omniauth-identity
|
19
19
|
pundit
|
20
|
+
rack-contrib
|
20
21
|
rack-proxy
|
21
22
|
sequel
|
22
23
|
sinatra
|
23
24
|
sinatra-contrib
|
24
25
|
sinatra-flash
|
25
26
|
tilt (>= 2)
|
27
|
+
wisper
|
26
28
|
|
27
29
|
GEM
|
28
30
|
remote: https://rubygems.org/
|
@@ -36,6 +38,7 @@ GEM
|
|
36
38
|
bcrypt (3.1.11)
|
37
39
|
bcrypt-ruby (3.1.5)
|
38
40
|
bcrypt (>= 3.1.3)
|
41
|
+
byebug (9.0.6)
|
39
42
|
coderay (1.1.1)
|
40
43
|
concurrent-ruby (1.0.4)
|
41
44
|
database_cleaner (1.5.3)
|
@@ -54,6 +57,7 @@ GEM
|
|
54
57
|
faraday (0.11.0)
|
55
58
|
multipart-post (>= 1.2, < 3)
|
56
59
|
ffi (1.9.14)
|
60
|
+
git-version-bump (0.15.1)
|
57
61
|
haml (4.0.7)
|
58
62
|
tilt
|
59
63
|
hashie (3.4.6)
|
@@ -78,9 +82,15 @@ GEM
|
|
78
82
|
coderay (~> 1.1.0)
|
79
83
|
method_source (~> 0.8.1)
|
80
84
|
slop (~> 3.4)
|
85
|
+
pry-byebug (3.4.2)
|
86
|
+
byebug (~> 9.0)
|
87
|
+
pry (~> 0.10)
|
81
88
|
pundit (1.1.0)
|
82
89
|
activesupport (>= 3.0.0)
|
83
90
|
rack (1.6.5)
|
91
|
+
rack-contrib (1.4.0)
|
92
|
+
git-version-bump (~> 0.15)
|
93
|
+
rack (~> 1.4)
|
84
94
|
rack-protection (1.5.3)
|
85
95
|
rack
|
86
96
|
rack-proxy (0.6.0)
|
@@ -130,9 +140,10 @@ GEM
|
|
130
140
|
slop (3.6.0)
|
131
141
|
sqlite3 (1.3.12)
|
132
142
|
thread_safe (0.3.5)
|
133
|
-
tilt (2.0.
|
143
|
+
tilt (2.0.6)
|
134
144
|
tzinfo (1.2.2)
|
135
145
|
thread_safe (~> 0.1)
|
146
|
+
wisper (1.6.1)
|
136
147
|
|
137
148
|
PLATFORMS
|
138
149
|
ruby
|
@@ -142,7 +153,7 @@ DEPENDENCIES
|
|
142
153
|
database_cleaner
|
143
154
|
factory_girl
|
144
155
|
proxes!
|
145
|
-
pry
|
156
|
+
pry-byebug
|
146
157
|
rack-test
|
147
158
|
racksh
|
148
159
|
rake (~> 10.0)
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# ProxES
|
6
6
|
|
7
|
-
ProxES provides a
|
7
|
+
ProxES provides a management interface and security layer for Elasticsearch.
|
8
8
|
|
9
9
|
## Components
|
10
10
|
|
@@ -75,9 +75,13 @@ gulp deploy
|
|
75
75
|
|
76
76
|
## Contributing
|
77
77
|
|
78
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
78
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/EagerELK/proxes.
|
79
79
|
|
80
80
|
## License
|
81
81
|
|
82
|
-
The gem is
|
82
|
+
The ProxES gem is an Open Source project licensed under the terms of
|
83
|
+
the LGPLv3 license. Please see [LGPLv3 license](http://www.gnu.org/licenses/lgpl-3.0.html)
|
84
|
+
for license text.
|
83
85
|
|
86
|
+
A commercial-friendly license allowing private forks and modifications of
|
87
|
+
ProxES is available. Please contact info@jadeit.co.za more detail.
|
data/Rakefile
CHANGED
File without changes
|
data/Vagrantfile
CHANGED
File without changes
|
data/config.ru
CHANGED
data/config/logger.yml
CHANGED
data/gulpfile.js
CHANGED
File without changes
|
data/lib/proxes.rb
CHANGED
data/lib/proxes/app.rb
CHANGED
@@ -18,6 +18,10 @@ module ProxES
|
|
18
18
|
post '/auth/identity/new' do
|
19
19
|
identity = Identity.new(params['identity'])
|
20
20
|
if identity.valid? && identity.save
|
21
|
+
user = User.find_or_create(email: identity.username)
|
22
|
+
user.add_identity identity
|
23
|
+
|
24
|
+
log_action(:identity_register, user: user)
|
21
25
|
flash[:info] = 'Successfully Registered. Please log in'
|
22
26
|
redirect '/auth/identity'
|
23
27
|
else
|
@@ -27,19 +31,16 @@ module ProxES
|
|
27
31
|
end
|
28
32
|
|
29
33
|
post '/auth/identity/callback' do
|
30
|
-
user = User.
|
31
|
-
|
32
|
-
identity = Identity.find(username: user.email)
|
33
|
-
user.add_identity identity unless identity.user == user
|
34
|
-
|
34
|
+
user = User.find(email: env['omniauth.auth']['info']['email'])
|
35
35
|
self.current_user = user
|
36
|
+
log_action(:identity_login, user: user)
|
36
37
|
flash[:success] = 'Logged In'
|
37
38
|
redirect '/_proxes'
|
38
39
|
end
|
39
40
|
|
40
41
|
delete '/auth/identity' do
|
42
|
+
log_action(:identity_logout)
|
41
43
|
logout
|
42
|
-
|
43
44
|
flash[:info] = 'Logged Out'
|
44
45
|
|
45
46
|
redirect '/_proxes'
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module ProxES
|
2
|
+
class Container
|
3
|
+
class ContainerError < StandardError; end
|
4
|
+
|
5
|
+
# A thread safe cache class, offering only #[] and #[]= methods,
|
6
|
+
# each protected by a mutex.
|
7
|
+
# Ripped off from Roda - https://github.com/jeremyevans/roda
|
8
|
+
class PluginCache
|
9
|
+
# Create a new thread safe cache.
|
10
|
+
def initialize
|
11
|
+
@mutex = Mutex.new
|
12
|
+
@hash = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
# Make getting value from underlying hash thread safe.
|
16
|
+
def [](key)
|
17
|
+
@mutex.synchronize{@hash[key]}
|
18
|
+
end
|
19
|
+
|
20
|
+
# Make setting value in underlying hash thread safe.
|
21
|
+
def []=(key, value)
|
22
|
+
@mutex.synchronize{@hash[key] = value}
|
23
|
+
end
|
24
|
+
|
25
|
+
def map(&block)
|
26
|
+
@mutex.synchronize{@hash.map(&block)}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Ripped off from Roda - https://github.com/jeremyevans/roda
|
31
|
+
module Plugins
|
32
|
+
# Stores registered plugins
|
33
|
+
@plugins = PluginCache.new
|
34
|
+
|
35
|
+
# If the registered plugin already exists, use it. Otherwise,
|
36
|
+
# require it and return it. This raises a LoadError if such a
|
37
|
+
# plugin doesn't exist, or a ContainerError if it exists but it does
|
38
|
+
# not register itself correctly.
|
39
|
+
def self.load_plugin(name)
|
40
|
+
h = @plugins
|
41
|
+
unless plugin = h[name]
|
42
|
+
require "proxes/plugins/#{name}"
|
43
|
+
raise ContainerError, "Plugin #{name} did not register itself correctly in ProxES::Container::Plugins" unless plugin = h[name]
|
44
|
+
end
|
45
|
+
plugin
|
46
|
+
end
|
47
|
+
|
48
|
+
# Register the given plugin with Container, so that it can be loaded using #plugin
|
49
|
+
# with a symbol. Should be used by plugin files. Example:
|
50
|
+
#
|
51
|
+
# ProxES::Container::Plugins.register_plugin(:plugin_name, PluginModule)
|
52
|
+
def self.register_plugin(name, mod)
|
53
|
+
@plugins[name] = mod
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.plugins
|
57
|
+
@plugins
|
58
|
+
end
|
59
|
+
|
60
|
+
module Base
|
61
|
+
module ClassMethods
|
62
|
+
# Load a new plugin into the current class. A plugin can be a module
|
63
|
+
# which is used directly, or a symbol represented a registered plugin
|
64
|
+
# which will be required and then used. Returns nil.
|
65
|
+
#
|
66
|
+
# Container.plugin PluginModule
|
67
|
+
# Container.plugin :csrf
|
68
|
+
def plugin(plugin, *args, &block)
|
69
|
+
raise ContainerError, "Cannot add a plugin to a frozen Container class" if frozen?
|
70
|
+
plugin = Plugins.load_plugin(plugin) if plugin.is_a?(Symbol)
|
71
|
+
plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
|
72
|
+
include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
|
73
|
+
extend(plugin::ClassMethods) if defined?(plugin::ClassMethods)
|
74
|
+
plugin.configure(self, *args, &block) if plugin.respond_to?(:configure)
|
75
|
+
|
76
|
+
# One option is to add controllers / nav on registration:
|
77
|
+
@controllers.merge(plugin.controllers) if plugin.respond_to?(:controllers)
|
78
|
+
@navigation << plugin.navigation if plugin.respond_to?(:navigation)
|
79
|
+
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
|
83
|
+
def routes
|
84
|
+
{} # Return a hash of controllers with their routes as keys: `{ '/users' => ProxES::Controllers::Users }`
|
85
|
+
end
|
86
|
+
|
87
|
+
def nav_items
|
88
|
+
[] # Return an ordered list of navigation items: `[{order:0, link:'/users/' text:'Users'}, {order:1, link:'/roles/', text:'Roles'}]
|
89
|
+
end
|
90
|
+
|
91
|
+
def migrations
|
92
|
+
Plugins.plugins.map do |_key, plugin|
|
93
|
+
plugin.migration_folder if plugin.respond_to?(:migration_folder)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
module InstanceMethods
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
extend Plugins::Base::ClassMethods
|
104
|
+
plugin Plugins::Base
|
105
|
+
end
|
106
|
+
end
|
@@ -1,17 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'wisper'
|
2
3
|
require 'sinatra/base'
|
3
4
|
require 'sinatra/flash'
|
4
5
|
require 'sinatra/respond_with'
|
5
6
|
require 'proxes/helpers/views'
|
6
7
|
require 'proxes/helpers/pundit'
|
8
|
+
require 'proxes/helpers/wisper'
|
7
9
|
require 'proxes/helpers/authentication'
|
10
|
+
require 'rack/contrib'
|
8
11
|
|
9
12
|
module ProxES
|
10
13
|
class Application < Sinatra::Base
|
11
14
|
set :root, ::File.expand_path(::File.dirname(__FILE__) + '/../../../')
|
12
|
-
|
15
|
+
# The order here is important, since Wisper has a deprecated method respond_with method
|
16
|
+
helpers Wisper::Publisher, ProxES::Helpers::Wisper
|
13
17
|
helpers ProxES::Helpers::Pundit, ProxES::Helpers::Views, ProxES::Helpers::Authentication
|
14
18
|
|
19
|
+
register Sinatra::Flash, Sinatra::RespondWith
|
20
|
+
|
21
|
+
use Rack::PostBodyContentTypeParser
|
22
|
+
|
15
23
|
configure :production do
|
16
24
|
disable :show_exceptions
|
17
25
|
end
|
File without changes
|
@@ -6,7 +6,9 @@ module ProxES
|
|
6
6
|
class Component < Application
|
7
7
|
helpers ProxES::Helpers::Component
|
8
8
|
set base_path: nil
|
9
|
+
set dehumanized: nil
|
9
10
|
set view_location: nil
|
11
|
+
set track_actions: false
|
10
12
|
|
11
13
|
# List
|
12
14
|
get '/', provides: [:html, :json] do
|
@@ -15,6 +17,7 @@ module ProxES
|
|
15
17
|
actions = {}
|
16
18
|
actions["#{base_path}/new"] = "New #{heading}" if policy(settings.model_class).create?
|
17
19
|
|
20
|
+
log_action("#{dehumanized}_list".to_sym) if settings.track_actions
|
18
21
|
respond_to do |format|
|
19
22
|
format.html do
|
20
23
|
haml :"#{view_location}/index",
|
@@ -44,11 +47,22 @@ module ProxES
|
|
44
47
|
authorize settings.model_class, :create
|
45
48
|
|
46
49
|
entity = settings.model_class.new(permitted_attributes(settings.model_class, :create))
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
success = entity.valid? && entity.save
|
51
|
+
|
52
|
+
log_action("#{dehumanized}_create".to_sym) if success && settings.track_actions
|
53
|
+
respond_to do |format|
|
54
|
+
format.html do
|
55
|
+
if success
|
56
|
+
flash[:success] = "#{heading} Created"
|
57
|
+
redirect "#{base_path}/#{entity.id}"
|
58
|
+
else
|
59
|
+
haml :"#{view_location}/new", locals: { entity: entity, title: heading(:new) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
format.json do
|
63
|
+
headers 'Content-Type' => 'application/json'
|
64
|
+
redirect "#{base_path}/#{entity.id}", 201 if success
|
65
|
+
end
|
52
66
|
end
|
53
67
|
end
|
54
68
|
|
@@ -61,6 +75,7 @@ module ProxES
|
|
61
75
|
actions = {}
|
62
76
|
actions["#{base_path}/#{entity.id}/edit"] = "Edit #{heading}" if policy(entity).update?
|
63
77
|
|
78
|
+
log_action("#{dehumanized}_read".to_sym) if settings.track_actions
|
64
79
|
respond_to do |format|
|
65
80
|
format.html do
|
66
81
|
haml :"#{view_location}/display",
|
@@ -86,7 +101,10 @@ module ProxES
|
|
86
101
|
authorize entity, :update
|
87
102
|
|
88
103
|
entity.set(permitted_attributes(settings.model_class, :update))
|
89
|
-
|
104
|
+
|
105
|
+
success = entity.valid? && entity.save
|
106
|
+
log_action("#{dehumanized}_update".to_sym) if success && settings.track_actions
|
107
|
+
if success
|
90
108
|
flash[:success] = "#{heading} Updated"
|
91
109
|
redirect "#{base_path}/#{entity.id}"
|
92
110
|
else
|
@@ -101,6 +119,7 @@ module ProxES
|
|
101
119
|
|
102
120
|
entity.destroy
|
103
121
|
|
122
|
+
log_action("#{dehumanized}_delete".to_sym) if settings.track_actions
|
104
123
|
flash[:success] = "#{heading} Deleted"
|
105
124
|
redirect base_path.to_s
|
106
125
|
end
|
File without changes
|
File without changes
|
@@ -8,6 +8,7 @@ require 'proxes/policies/identity_policy'
|
|
8
8
|
module ProxES
|
9
9
|
class Users < Component
|
10
10
|
set model_class: ProxES::User
|
11
|
+
set track_actions: true
|
11
12
|
|
12
13
|
# New
|
13
14
|
get '/new' do
|
@@ -40,19 +41,41 @@ module ProxES
|
|
40
41
|
identity.save
|
41
42
|
user.save
|
42
43
|
user.add_identity identity
|
43
|
-
roles
|
44
|
-
|
45
|
-
|
44
|
+
if roles
|
45
|
+
roles.each do |role_id|
|
46
|
+
user.add_role(role_id) unless user.roles.map(&:id).include? role_id.to_i
|
47
|
+
end
|
48
|
+
end
|
46
49
|
user.check_roles
|
47
50
|
end
|
48
51
|
|
49
|
-
|
50
|
-
|
52
|
+
log_action("#{dehumanized}_create".to_sym) if settings.track_actions
|
53
|
+
respond_to do |format|
|
54
|
+
format.html do
|
55
|
+
flash[:success] = 'User created'
|
56
|
+
redirect "/_proxes/users/#{user.id}"
|
57
|
+
end
|
58
|
+
format.json do
|
59
|
+
headers 'Content-Type' => 'application/json'
|
60
|
+
redirect "/_proxes/users/#{user.id}", 201
|
61
|
+
end
|
62
|
+
end
|
51
63
|
else
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
respond_to do |format|
|
65
|
+
format.html do
|
66
|
+
flash.now[:danger] = 'Could not create the user'
|
67
|
+
locals[:entity] = user
|
68
|
+
locals[:identity] = identity
|
69
|
+
haml :"#{view_location}/new", locals: locals
|
70
|
+
end
|
71
|
+
format.json do
|
72
|
+
headers \
|
73
|
+
'Content-Type' => 'application/json',
|
74
|
+
'Content-Location' => "#{view_location}/new"
|
75
|
+
body ''
|
76
|
+
status 402
|
77
|
+
end
|
78
|
+
end
|
56
79
|
end
|
57
80
|
end
|
58
81
|
|
@@ -69,6 +92,7 @@ module ProxES
|
|
69
92
|
entity.remove_all_roles
|
70
93
|
roles.each { |role_id| entity.add_role(role_id) } if roles
|
71
94
|
entity.check_roles
|
95
|
+
log_action("#{dehumanized}_update".to_sym) if settings.track_actions
|
72
96
|
flash[:success] = "#{heading} Updated"
|
73
97
|
redirect "/_proxes/users/#{entity.id}"
|
74
98
|
else
|
@@ -86,6 +110,7 @@ module ProxES
|
|
86
110
|
values = permitted_attributes(Identity, :create)
|
87
111
|
identity.set values
|
88
112
|
if identity.valid? && identity.save
|
113
|
+
log_action("#{dehumanized}_update_password".to_sym) if settings.track_actions
|
89
114
|
flash[:success] = "Password Updated"
|
90
115
|
redirect '/_proxes/users/profile'
|
91
116
|
else
|
@@ -103,6 +128,7 @@ module ProxES
|
|
103
128
|
entity.remove_all_roles
|
104
129
|
entity.destroy
|
105
130
|
|
131
|
+
log_action("#{dehumanized}_delete".to_sym) if settings.track_actions
|
106
132
|
flash[:success] = "#{heading} Deleted"
|
107
133
|
redirect '/_proxes/users'
|
108
134
|
end
|
data/lib/proxes/db.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/proxes/helpers/views.rb
CHANGED
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Use this to restrict users, clusters, etc.
|
2
|
+
# Also add a check to ensure that this is running, so that if people try to
|
3
|
+
# bypass it it gets picked up
|
4
|
+
# Also run regular async checks as another check
|
5
|
+
require 'wisper'
|
6
|
+
|
7
|
+
module ProxES
|
8
|
+
class Listener
|
9
|
+
def method_missing(method, *args, &block)
|
10
|
+
vals = { action: method }
|
11
|
+
vals[:user] = args[0][:user] if (args[0] && args[0].has_key?(:user))
|
12
|
+
AuditLog.create vals
|
13
|
+
end
|
14
|
+
|
15
|
+
def respond_to_missing?(method, include_private = false)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Wisper.subscribe(ProxES::Listener.new)
|
File without changes
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'proxes/models/base'
|
3
3
|
|
4
4
|
module ProxES
|
5
|
-
class AuditLog <
|
5
|
+
class AuditLog < Base
|
6
6
|
many_to_one :user
|
7
7
|
|
8
8
|
def validate
|
9
|
-
validates_presence [:
|
9
|
+
validates_presence [:action]
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'proxes/models/base'
|
3
3
|
require 'omniauth-identity'
|
4
4
|
require 'active_support'
|
5
5
|
require 'active_support/core_ext/object/blank'
|
6
6
|
|
7
7
|
module ProxES
|
8
|
-
class Identity <
|
8
|
+
class Identity < Base
|
9
9
|
many_to_one :user
|
10
10
|
|
11
11
|
attr_accessor :password, :password_confirmation
|
data/lib/proxes/models/role.rb
CHANGED
data/lib/proxes/models/user.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'proxes/models/base'
|
3
3
|
require 'bcrypt'
|
4
4
|
require 'digest/md5'
|
5
5
|
require 'active_support'
|
@@ -7,7 +7,7 @@ require 'active_support/core_ext/object/blank'
|
|
7
7
|
|
8
8
|
# Why not store this in Elasticsearch?
|
9
9
|
module ProxES
|
10
|
-
class User <
|
10
|
+
class User < Base
|
11
11
|
one_to_many :identity
|
12
12
|
many_to_many :roles
|
13
13
|
one_to_many :audit_logs
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -18,8 +18,6 @@ module ProxES
|
|
18
18
|
def method_missing(method_sym, *arguments, &block)
|
19
19
|
if method_sym.to_s[-1] == '?'
|
20
20
|
return false if user.nil?
|
21
|
-
require 'pry'
|
22
|
-
# binding.pry
|
23
21
|
|
24
22
|
if record.indices?
|
25
23
|
patterns = ProxES::Permission.where(verb: 'INDEX', role: user.roles).map do |permission|
|
File without changes
|
File without changes
|
File without changes
|
data/lib/proxes/rake_tasks.rb
CHANGED
File without changes
|
data/lib/proxes/request.rb
CHANGED
File without changes
|
data/lib/proxes/request/root.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/proxes/request/stats.rb
CHANGED
File without changes
|
data/lib/proxes/security.rb
CHANGED
File without changes
|
data/lib/proxes/seed.rb
CHANGED
@@ -3,7 +3,6 @@ require 'proxes/models/role'
|
|
3
3
|
require 'proxes/models/permission'
|
4
4
|
|
5
5
|
ProxES::Role.find_or_create(name: 'user')
|
6
|
-
ProxES::Role.find_or_create(name: 'admin')
|
7
6
|
sa = ProxES::Role.find_or_create(name: 'super_admin')
|
8
7
|
%w(GET POST PUT DELETE HEAD OPTIONS).each do |verb|
|
9
8
|
ProxES::Permission.find_or_create(role: sa, verb: verb, pattern: '.*')
|
File without changes
|
data/lib/proxes/version.rb
CHANGED
data/migrate/001_tables.rb
CHANGED
File without changes
|
data/migrate/002_audit_log.rb
CHANGED
data/package.json
CHANGED
File without changes
|
data/proxes.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'factory_girl'
|
30
30
|
|
31
31
|
spec.add_dependency 'rack-proxy'
|
32
|
+
spec.add_dependency 'rack-contrib'
|
32
33
|
spec.add_dependency 'sinatra'
|
33
34
|
spec.add_dependency 'sinatra-flash'
|
34
35
|
spec.add_dependency 'sinatra-contrib'
|
@@ -40,5 +41,6 @@ Gem::Specification.new do |spec|
|
|
40
41
|
spec.add_dependency 'omniauth'
|
41
42
|
spec.add_dependency 'omniauth-identity'
|
42
43
|
spec.add_dependency 'haml'
|
44
|
+
spec.add_dependency 'wisper'
|
43
45
|
spec.add_dependency 'tilt', '>= 2'
|
44
46
|
end
|
data/public/js/bundle.js
CHANGED
File without changes
|
data/src/scripts/app.js
CHANGED
@@ -2,9 +2,4 @@ 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"/>, document.getElementById('react-dashboard'));
|
6
|
-
|
7
|
-
// ReactDOM.render(
|
8
|
-
// <Health store={new ESStore()}/>,
|
9
|
-
// document.getElementById('indexlist')
|
10
|
-
// );
|
5
|
+
ReactDOM.render(<ProxesComponents pollInterval="30000" elasticsearch_url="./"/>, document.getElementById('react-dashboard'));
|
data/views/404.haml
CHANGED
File without changes
|
data/views/audit_logs/index.haml
CHANGED
data/views/error.haml
CHANGED
File without changes
|
data/views/getting_started.haml
CHANGED
File without changes
|
data/views/identity/login.haml
CHANGED
File without changes
|
File without changes
|
data/views/index.haml
CHANGED
File without changes
|
data/views/layout.haml
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/views/partials/navbar.haml
CHANGED
File without changes
|
File without changes
|
data/views/partials/pager.haml
CHANGED
File without changes
|
data/views/partials/sidebar.haml
CHANGED
File without changes
|
File without changes
|
data/views/permissions/edit.haml
CHANGED
File without changes
|
data/views/permissions/form.haml
CHANGED
File without changes
|
File without changes
|
data/views/permissions/new.haml
CHANGED
File without changes
|
data/views/roles/display.haml
CHANGED
File without changes
|
data/views/roles/edit.haml
CHANGED
File without changes
|
data/views/roles/form.haml
CHANGED
File without changes
|
data/views/roles/index.haml
CHANGED
File without changes
|
data/views/roles/new.haml
CHANGED
File without changes
|
data/views/users/display.haml
CHANGED
File without changes
|
data/views/users/edit.haml
CHANGED
File without changes
|
data/views/users/identity.haml
CHANGED
File without changes
|
data/views/users/index.haml
CHANGED
File without changes
|
data/views/users/new.haml
CHANGED
File without changes
|
data/views/users/profile.haml
CHANGED
File without changes
|
data/views/users/user.haml
CHANGED
File without changes
|
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.2.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-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rack-contrib
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: sinatra
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,6 +290,20 @@ dependencies:
|
|
276
290
|
- - ">="
|
277
291
|
- !ruby/object:Gem::Version
|
278
292
|
version: '0'
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: wisper
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - ">="
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: '0'
|
300
|
+
type: :runtime
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - ">="
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '0'
|
279
307
|
- !ruby/object:Gem::Dependency
|
280
308
|
name: tilt
|
281
309
|
requirement: !ruby/object:Gem::Requirement
|
@@ -300,6 +328,7 @@ extra_rdoc_files: []
|
|
300
328
|
files:
|
301
329
|
- ".codeclimate.yml"
|
302
330
|
- ".gitignore"
|
331
|
+
- ".pryrc"
|
303
332
|
- ".rspec"
|
304
333
|
- ".rubocop.yml"
|
305
334
|
- ".ruby-version"
|
@@ -319,6 +348,7 @@ files:
|
|
319
348
|
- gulpfile.js
|
320
349
|
- lib/proxes.rb
|
321
350
|
- lib/proxes/app.rb
|
351
|
+
- lib/proxes/container.rb
|
322
352
|
- lib/proxes/controllers/application.rb
|
323
353
|
- lib/proxes/controllers/audit_logs.rb
|
324
354
|
- lib/proxes/controllers/auth_identity.rb
|
@@ -332,8 +362,11 @@ files:
|
|
332
362
|
- lib/proxes/helpers/indices.rb
|
333
363
|
- lib/proxes/helpers/pundit.rb
|
334
364
|
- lib/proxes/helpers/views.rb
|
365
|
+
- lib/proxes/helpers/wisper.rb
|
366
|
+
- lib/proxes/listener.rb
|
335
367
|
- lib/proxes/loggers/elasticsearch.rb
|
336
368
|
- lib/proxes/models/audit_log.rb
|
369
|
+
- lib/proxes/models/base.rb
|
337
370
|
- lib/proxes/models/identity.rb
|
338
371
|
- lib/proxes/models/permission.rb
|
339
372
|
- lib/proxes/models/role.rb
|