eucalypt 0.5.0 → 0.5.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/README.md +23 -3
- data/lib/eucalypt/core/templates/eucalypt/config/logging.rb +1 -1
- data/lib/eucalypt/load.rb +4 -1
- data/lib/eucalypt/security/namespaces/security-policy/cli/security-policy.rb +1 -10
- data/lib/eucalypt/security/namespaces/security-policy/generators/policy.rb +11 -1
- data/lib/eucalypt/security/namespaces/security-policy/templates/policy.tt +0 -8
- data/lib/eucalypt/security/namespaces/security-policy/templates/policy_role.tt +3 -0
- data/lib/eucalypt/security/namespaces/security-policy-permission/cli/security-policy-permission.rb +1 -1
- data/lib/eucalypt/security/namespaces/security-policy-role/cli/security-policy-role.rb +1 -1
- data/lib/eucalypt/security/permissions.rb +19 -0
- data/lib/eucalypt/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63a868422a94bde49b8b30b2e6bc5af7b7dd87099452bbb7d0dd4e64eeb4d155
|
4
|
+
data.tar.gz: f3acffad61e46e0664131a530a33294ecaf376d1890c0f7a5f48cf45a163b11a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67a75c326f188a04327302632f5aaa41a0d1c69d4df04d14c5d849d5711fb3a4226c33dd27f2166f16f95d79cae6dc632936d20fa263693012418110d961a9dc
|
7
|
+
data.tar.gz: 1cb228a0816a3176184804b1466f4b3e3145ace396e55f914e125cb23ed5d275bddb62714a45a07ab4a80d991f7cf123695e53fae34e1344e151b33f73f58809
|
data/README.md
CHANGED
@@ -27,10 +27,30 @@ $ eucalypt init my-new-app
|
|
27
27
|
```
|
28
28
|
|
29
29
|
> Once the setup is complete, make sure the required gems have been installed (without any errors).
|
30
|
-
>
|
31
|
-
> This should have been done automatically unless you used the `--no-bundle` flag during initialization.
|
32
30
|
|
33
|
-
|
31
|
+
### Commands
|
32
|
+
|
33
|
+
Move into your new application's directory and run the top-level `eucalypt` command to display a list of all available commands:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
$ eucalypt
|
37
|
+
|
38
|
+
Commands:
|
39
|
+
eucalypt init [NAME] ·› Sets up your application
|
40
|
+
eucalypt launch [ENV] ·› Launches your application
|
41
|
+
eucalypt console ·› Interactive console with all files loaded
|
42
|
+
eucalypt test ·› Run all application tests
|
43
|
+
eucalypt version ·› Display installed Eucalypt version
|
44
|
+
eucalypt rake ·› Run all database migrations
|
45
|
+
eucalypt blog [COMMAND] ·› Manage static blog environment
|
46
|
+
eucalypt generate [COMMAND] ·› Generate individual MVC files or scaffolds
|
47
|
+
eucalypt destroy [COMMAND] ·› Destroy individual MVC files or scaffolds
|
48
|
+
eucalypt security [COMMAND] ·› Manage authentication and authorization
|
49
|
+
eucalypt migration [COMMAND] ·› Generate ActiveRecord migrations
|
50
|
+
|
51
|
+
For more information about a specific command, use eucalypt -H.
|
52
|
+
Example: eucalypt -H generate scaffold
|
53
|
+
```
|
34
54
|
|
35
55
|
## Documentation
|
36
56
|
|
data/lib/eucalypt/load.rb
CHANGED
@@ -5,4 +5,7 @@ require 'eucalypt/core/helpers/maintenance'
|
|
5
5
|
|
6
6
|
Eucalypt.require 'app', 'helpers', '{application_helper.rb}'
|
7
7
|
Eucalypt.require 'app', 'controllers', 'application_controller.rb'
|
8
|
-
Eucalypt.require 'app', '{models,
|
8
|
+
Eucalypt.require 'app', '{models}', '{roles}', '*.rb'
|
9
|
+
Eucalypt.require 'app', '{models,policies,helpers,controllers}', '*.rb'
|
10
|
+
|
11
|
+
require 'eucalypt/security/permissions'
|
@@ -46,16 +46,7 @@ module Eucalypt
|
|
46
46
|
policy_generator.generate_policy_roles_migration(policy: policy.resource)
|
47
47
|
|
48
48
|
# Create policy role model
|
49
|
-
|
50
|
-
Eucalypt::CLI.start(['generate', 'model', "#{policy.resource}_role", '--no-spec', '--no-table'])
|
51
|
-
end
|
52
|
-
|
53
|
-
# Add validation to role model
|
54
|
-
role_model_file = File.join directory, 'app', 'models', "#{policy.resource}_role.rb"
|
55
|
-
File.open(role_model_file) do |f|
|
56
|
-
insert = " validates :permission, uniqueness: true"
|
57
|
-
inject_into_class(role_model_file, "#{policy.resource}_role".camelize, "#{insert}\n") unless f.read.include? insert
|
58
|
-
end
|
49
|
+
policy_generator.generate_policy_role_model(policy: policy)
|
59
50
|
|
60
51
|
# Add policy column to user roles table
|
61
52
|
Dir.chdir(directory) do
|
@@ -16,7 +16,17 @@ module Eucalypt
|
|
16
16
|
def generate(headless:, name:)
|
17
17
|
policy = Inflect.new(:policy, name)
|
18
18
|
config = {class_name: policy.class_name, resource: policy.resource, constant: policy.constant, headless: headless}
|
19
|
-
template
|
19
|
+
template 'policy.tt', policy.file_path, config
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate_policy_role_model(policy:)
|
23
|
+
roles_directory = File.join 'app', 'models', 'roles'
|
24
|
+
role_model_file = File.join roles_directory, "#{policy.resource}_role.rb"
|
25
|
+
|
26
|
+
empty_directory roles_directory unless File.directory? roles_directory
|
27
|
+
|
28
|
+
config = {constant: policy.constant}
|
29
|
+
template 'policy_role.tt', role_model_file, config
|
20
30
|
end
|
21
31
|
|
22
32
|
def generate_policy_roles_migration(policy:)
|
@@ -5,12 +5,4 @@ class <%= config[:class_name] %><%= " < Struct.new(:user, :#{config[:resource]})
|
|
5
5
|
@user = user
|
6
6
|
@<%= config[:resource] %> = <%= config[:resource] %>
|
7
7
|
end
|
8
|
-
|
9
|
-
if ActiveRecord::Base.connection.table_exists?(:<%= config[:resource] %>_roles)
|
10
|
-
<%= config[:constant] %>Role.pluck(:permission).each do |permission|
|
11
|
-
define_method("#{permission}?") do
|
12
|
-
<%= config[:constant] %>Role.find_by(permission: permission).send(user.role.<%= config[:resource] %>)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
8
|
end
|
data/lib/eucalypt/security/namespaces/security-policy-permission/cli/security-policy-permission.rb
CHANGED
@@ -34,7 +34,7 @@ module Eucalypt
|
|
34
34
|
|
35
35
|
# Check for policy file and policy role model
|
36
36
|
policy_file = File.join(directory, 'app', 'policies', policy.file_name)
|
37
|
-
policy_role_model = File.join(directory, 'app', 'models', "#{policy.resource}_role.rb")
|
37
|
+
policy_role_model = File.join(directory, 'app', 'models', 'roles', "#{policy.resource}_role.rb")
|
38
38
|
unless File.exist?(policy_file) && File.exist?(policy_role_model)
|
39
39
|
Eucalypt::Error.no_policy(policy.resource)
|
40
40
|
return
|
@@ -33,7 +33,7 @@ module Eucalypt
|
|
33
33
|
|
34
34
|
# Check for policy file and policy role model
|
35
35
|
policy_file = File.join(directory, 'app', 'policies', policy.file_name)
|
36
|
-
policy_role_model = File.join(directory, 'app', 'models', "#{policy.resource}_role.rb")
|
36
|
+
policy_role_model = File.join(directory, 'app', 'models', 'roles', "#{policy.resource}_role.rb")
|
37
37
|
unless File.exist?(policy_file) && File.exist?(policy_role_model)
|
38
38
|
Eucalypt::Error.no_policy(policy.resource)
|
39
39
|
return
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
|
4
|
+
Eucalypt.glob('app', '{policies}', '*.rb') do |file|
|
5
|
+
policy_name = File.basename file, '.rb'
|
6
|
+
policy_constant = policy_name.camelize.constantize
|
7
|
+
resource_name = policy_name.gsub '_policy', ''
|
8
|
+
roles_name = "#{resource_name}_roles"
|
9
|
+
role_constant_name = roles_name.singularize.camelize
|
10
|
+
role_constant = role_constant_name.constantize
|
11
|
+
|
12
|
+
if ActiveRecord::Base.connection.table_exists? roles_name
|
13
|
+
role_constant.pluck(:permission).each do |permission|
|
14
|
+
policy_constant.define_method "#{permission}?" do
|
15
|
+
role_constant.find_by(permission: permission).send(user.role.send resource_name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/eucalypt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eucalypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin Onuonga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -356,6 +356,7 @@ files:
|
|
356
356
|
- lib/eucalypt/security/namespaces/security-policy/generators/policy.rb
|
357
357
|
- lib/eucalypt/security/namespaces/security-policy/templates/create_policy_roles_migration.tt
|
358
358
|
- lib/eucalypt/security/namespaces/security-policy/templates/policy.tt
|
359
|
+
- lib/eucalypt/security/namespaces/security-policy/templates/policy_role.tt
|
359
360
|
- lib/eucalypt/security/namespaces/security-pundit/cli/security-pundit.rb
|
360
361
|
- lib/eucalypt/security/namespaces/security-pundit/generators/role.rb
|
361
362
|
- lib/eucalypt/security/namespaces/security-pundit/templates/create_roles_migration.tt
|
@@ -369,6 +370,7 @@ files:
|
|
369
370
|
- lib/eucalypt/security/namespaces/security-warden/templates/user.tt
|
370
371
|
- lib/eucalypt/security/namespaces/security-warden/templates/warden.tt
|
371
372
|
- lib/eucalypt/security/namespaces/security/cli/security.rb
|
373
|
+
- lib/eucalypt/security/permissions.rb
|
372
374
|
- lib/eucalypt/static.rb
|
373
375
|
- lib/eucalypt/version.rb
|
374
376
|
- lib/eucalypt/whitelist.rb
|