omniperm 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/omniperm/decorators.rb +2 -2
- data/lib/omniperm/version.rb +1 -1
- data/omniperm.gemspec +1 -1
- data/test/decorators_test.rb +5 -0
- data/test/omniperm_test.rb +8 -0
- data/test/services/class_service.rb +5 -0
- data/test/services/external_service_class_decorated.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c54a89f4bab72c45f50cff612e24eaba566ab7803fc09c7c021898e5639f5598
|
4
|
+
data.tar.gz: 6f81efb19ac42ed400d906eb0a44858c9fccbcbdf5fb6c76c4d5c34192cf3dd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b7f6bfe5e79e679d07f26f548b31b3f813120f59c90a758f60fa2167355b055467e94580822ef6422c26c1468f6ef74f1f039dd1253abd6b4cbc9c57329f754
|
7
|
+
data.tar.gz: 6c7a383564f2a33fe135e3f71b22b455623d14c5d63879436cbdbae64f1deec63f6364972cc99bad3aecf3a46a2c580a113cf9ef2b522730dc22c86f03d72fe2
|
data/Gemfile.lock
CHANGED
data/lib/omniperm/decorators.rb
CHANGED
@@ -14,8 +14,8 @@ module Omniperm
|
|
14
14
|
target_methods.reject{|value| [:inject_before_to_methods, :__before_method, :__after_method].include?(value) }.each { |m|
|
15
15
|
# Rename original method
|
16
16
|
target = nil
|
17
|
-
target = self if instance_methods(false).include?(m.to_sym)
|
18
|
-
target = self.singleton_class if singleton_methods(false).include?(m.to_sym)
|
17
|
+
target = self if instance_methods(false).include?(m.to_sym) # decorate instance methods
|
18
|
+
# target = self.singleton_class if singleton_methods(false).include?(m.to_sym) # decorate class methods
|
19
19
|
if target
|
20
20
|
target.send(:alias_method, "__#{m}_original", m)
|
21
21
|
target.define_method m do |*args, **kwargs|
|
data/lib/omniperm/version.rb
CHANGED
data/omniperm.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = %w(samuel@hydrodigit.com)
|
11
11
|
s.date = %q{2020-07-21}
|
12
12
|
s.description = %q{With Omniperm you can centralize your authorization strategies in a YAML file against a configurable context }
|
13
|
-
s.summary = 'Flexible Authorization for Ruby
|
13
|
+
s.summary = 'Flexible Authorization for Ruby and Rails'
|
14
14
|
s.homepage = 'https://github.com/3pns/omniperm'
|
15
15
|
s.license = 'MIT'
|
16
16
|
s.files = `git ls-files`.split($/)
|
data/test/decorators_test.rb
CHANGED
@@ -20,6 +20,11 @@ describe Omniperm::Core do
|
|
20
20
|
assert_equal 42, @service_class_decorated_allowed.buy
|
21
21
|
end
|
22
22
|
|
23
|
+
it 'should not perform authorization for class methods' do
|
24
|
+
# @user is pear
|
25
|
+
assert_equal 42, Services::ExternalServiceClassDecorated.my_class_method
|
26
|
+
end
|
27
|
+
|
23
28
|
it 'should perform authorization' do
|
24
29
|
assert_equal false, @service_class_decorated_allowed.bucket
|
25
30
|
end
|
data/test/omniperm_test.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative 'helper'
|
|
5
5
|
describe Omniperm::Core do
|
6
6
|
before do
|
7
7
|
@user = User.new(:pear)
|
8
|
+
@user_nanosoft = User.new(:nanosoft)
|
8
9
|
@service = Services::ExternalService.new(@user)
|
9
10
|
@internal_service = Services::InternalService.new(@user)
|
10
11
|
@secret_service = Services::InternalService::SecretService.new(@user)
|
@@ -16,6 +17,13 @@ describe Omniperm::Core do
|
|
16
17
|
|
17
18
|
it 'should properly detect hierarchy and method_name from a class method' do
|
18
19
|
assert_equal 42, Services::ClassService.compute(@user)
|
20
|
+
assert_equal false, Services::ClassService.compute(@user_nanosoft)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should properly detect instance variables from a class method' do
|
24
|
+
skip ("impossible case")
|
25
|
+
assert_equal 42, Services::ClassService.compute_instance_variable
|
26
|
+
assert_equal false, Services::ClassService.compute_instance_variable
|
19
27
|
end
|
20
28
|
|
21
29
|
it 'should deny if element has default to true' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniperm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Bohn
|
@@ -110,5 +110,5 @@ requirements: []
|
|
110
110
|
rubygems_version: 3.0.8
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
|
-
summary: Flexible Authorization for Ruby
|
113
|
+
summary: Flexible Authorization for Ruby and Rails
|
114
114
|
test_files: []
|