ingress 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 +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +2 -2
- data/README.md +2 -2
- data/ingress.gemspec +2 -2
- data/lib/ingress/permissions.rb +11 -11
- data/lib/ingress/permissions_repository.rb +0 -12
- data/lib/ingress/version.rb +1 -1
- metadata +12 -11
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5f6fadfe0fa815422092e415f66fd83dc1915ce0cec8852544d877b1adb763f0
|
4
|
+
data.tar.gz: 731ff12c70dcbfbe16e1b6abb1c2162cd86aee4c4c4e643077280e1b8f90cab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb49bb4e9cae990a081babb2be38d814c443a6e7d60b2abf0c1eeb2d508e02f5a136e6ec4201f70555938adfe5a31f93216fd1aafba903f0f4d6016bdc263948
|
7
|
+
data.tar.gz: a92d7ae6f9246b5c0457744d1644fd0fc338c83b333cef0993f064fff8ee609098b7d9c841c6b71cbbdb97e5e7aff83bd131445ef22a901e86e13d1f6d440d63
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3
|
1
|
+
2.6.3
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -285,13 +285,13 @@ This framework has no hooks into Rails (these would be trivial to write if neces
|
|
285
285
|
|
286
286
|
## Development
|
287
287
|
|
288
|
-
After checking out the repo, run `
|
288
|
+
After checking out the repo, run `script/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `script/console` for an interactive prompt that will allow you to experiment.
|
289
289
|
|
290
290
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
291
291
|
|
292
292
|
## Contributing
|
293
293
|
|
294
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
294
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/skorks/ingress.
|
295
295
|
|
296
296
|
## License
|
297
297
|
|
data/ingress.gemspec
CHANGED
@@ -15,10 +15,10 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
17
|
spec.bindir = "bin"
|
18
|
-
spec.executables = spec.files.grep(%r{^
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "
|
21
|
+
spec.add_development_dependency "bundler", ">= 1.10", "< 3"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
end
|
data/lib/ingress/permissions.rb
CHANGED
@@ -43,22 +43,22 @@ module Ingress
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def can?(action, subject)
|
46
|
-
|
47
|
-
|
46
|
+
user_role_identifiers.any? do |role_identifier|
|
47
|
+
rules = self.class.permissions_repository.rules_for(role_identifier, action, subject)
|
48
|
+
|
49
|
+
cannot_match = rules.reject(&:allows?).any? do |rule|
|
50
|
+
rule.match?(action, subject, user)
|
51
|
+
end
|
52
|
+
break false if cannot_match
|
53
|
+
|
54
|
+
rules.select(&:allows?).any? do |rule|
|
55
|
+
rule.match?(action, subject, user)
|
56
|
+
end
|
48
57
|
end
|
49
58
|
end
|
50
59
|
|
51
60
|
def user_role_identifiers
|
52
61
|
[]
|
53
62
|
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
def find_matching_rules(action, subject)
|
58
|
-
user_role_identifiers.reduce([]) do |rules, role_identifier|
|
59
|
-
rules += self.class.permissions_repository.rules_for(role_identifier, action, subject)
|
60
|
-
rules
|
61
|
-
end
|
62
|
-
end
|
63
63
|
end
|
64
64
|
end
|
@@ -21,7 +21,6 @@ module Ingress
|
|
21
21
|
rules += find_rules(role_identifier, "*", "*")
|
22
22
|
rules += find_rules(role_identifier, action, "*")
|
23
23
|
rules += find_rules(role_identifier, "*", subject)
|
24
|
-
rules = apply_negative_rules(rules)
|
25
24
|
|
26
25
|
rules
|
27
26
|
end
|
@@ -46,17 +45,6 @@ module Ingress
|
|
46
45
|
|
47
46
|
private
|
48
47
|
|
49
|
-
def apply_negative_rules(rules)
|
50
|
-
# remove rules that cancel each other out since we're within the
|
51
|
-
# context of 1 role, i.e. if any rule is a negation it will
|
52
|
-
# cancel all other ones
|
53
|
-
if rules.any? { |rule| !rule.allows? }
|
54
|
-
[]
|
55
|
-
else
|
56
|
-
rules
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
48
|
def find_rules(role_identifier, action, subject)
|
61
49
|
rules = []
|
62
50
|
rules += @role_subject_action_rule[role_identifier][subject][action]
|
data/lib/ingress/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ingress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Skorkin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3'
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.10'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rake
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,9 +61,7 @@ dependencies:
|
|
55
61
|
description:
|
56
62
|
email:
|
57
63
|
- alan@skorks.com
|
58
|
-
executables:
|
59
|
-
- console
|
60
|
-
- setup
|
64
|
+
executables: []
|
61
65
|
extensions: []
|
62
66
|
extra_rdoc_files: []
|
63
67
|
files:
|
@@ -69,8 +73,6 @@ files:
|
|
69
73
|
- LICENSE.txt
|
70
74
|
- README.md
|
71
75
|
- Rakefile
|
72
|
-
- bin/console
|
73
|
-
- bin/setup
|
74
76
|
- ingress.gemspec
|
75
77
|
- lib/ingress.rb
|
76
78
|
- lib/ingress/build_permissions_repository_for_role.rb
|
@@ -101,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
103
|
- !ruby/object:Gem::Version
|
102
104
|
version: '0'
|
103
105
|
requirements: []
|
104
|
-
|
105
|
-
rubygems_version: 2.5.1
|
106
|
+
rubygems_version: 3.0.3
|
106
107
|
signing_key:
|
107
108
|
specification_version: 4
|
108
109
|
summary: Simple role based authorization for Ruby applications
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "ingress"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|