ostiary 0.11.0 → 0.15.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4fb578931e7699371535e5d759d387d36587e922d71e9f4c748cf115ec687af4
4
- data.tar.gz: 6134612b7f338b2a2511ca501e8aa3d6cf0100e6df6f7716fbfccc5cdaf5ddb5
3
+ metadata.gz: 06dd41598d092805491bf1002d20b09e64794171c9e5c1544cbe9602d9ce7cd8
4
+ data.tar.gz: fd650ed79a11cd624500bb3e3f6d4b0d21fc87f80a09de630cc06b535f9e765b
5
5
  SHA512:
6
- metadata.gz: 52d562092fdd9555ddb5b8e52073c2c6a939aba1b664e9027f97829a45b3ef363d097811ffea88d7351f026f7ccd73c141a4a67c3ea39615083372b5ee9471e2
7
- data.tar.gz: a5f3d43534641beaa6923129a71e8d05da2d707c42ef3ebe9ff7b58527ec681894adf3063f0320dfb7ea2a8e95cb718cbd339c64e1437c27db42ff2f7623c9f2
6
+ metadata.gz: 88c015f225cb267ab1b52d2732e78125d9e9fc3c04f4ae5cedf1704dc55d8da7f4867dba3df03d4783ff993f5fa6b15ec4889d1be47b673c3d67c4a7f58c6b7e
7
+ data.tar.gz: ea35d66e93f5b9da36b5d4bf88d9bc2ccb8820e5a629f2908217c27d5d0f350e8a7a9704446ca9918184c6cc6cf03cf5647b75e79aaf9744994288987cc8a289
@@ -37,12 +37,12 @@ module Ostiary
37
37
  raise ArgumentError, "Use either only or except" if except && only
38
38
  raise ArgumentError, "Use a symbol for method:" if method && !(method.is_a? Symbol)
39
39
 
40
- if actions.empty?
41
- ostiary.policies << Policy.new(role, method: method&.to_proc)
42
- elsif only
40
+ if only
43
41
  ostiary.policies << PolicyLimited.new(role, only, method: method&.to_proc)
44
42
  elsif except
45
43
  ostiary.policies << PolicyExempted.new(role, except, method: method&.to_proc)
44
+ else
45
+ ostiary.policies << Policy.new(role, method: method&.to_proc)
46
46
  end
47
47
  end
48
48
 
@@ -8,7 +8,7 @@ module Ostiary
8
8
 
9
9
  def authorize!(action, &block)
10
10
  policies.each do |policy|
11
- next if policy.met?(action, block)
11
+ next if policy.met?(action, &block)
12
12
  raise PolicyBroken, policy.error_message(action)
13
13
  end
14
14
  end
@@ -12,7 +12,7 @@ module Ostiary
12
12
  "#{name}"
13
13
  end
14
14
 
15
- def met?(_action)
15
+ def met?(_action, &block)
16
16
  return yield name unless method
17
17
  method.call
18
18
  end
@@ -5,7 +5,7 @@ module Ostiary
5
5
  "#{name} except for #{actions.to_sentence}"
6
6
  end
7
7
 
8
- def met?(action)
8
+ def met?(action, &block)
9
9
  return true if actions.include?(action)
10
10
  super
11
11
  end
@@ -5,7 +5,7 @@ module Ostiary
5
5
  "#{name} only for #{actions.to_sentence}"
6
6
  end
7
7
 
8
- def met?(action)
8
+ def met?(action, &block)
9
9
  return true unless actions.include?(action)
10
10
  super
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module Ostiary
2
- VERSION = "0.11.0"
2
+ VERSION = "0.15.0"
3
3
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ostiary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacques Hakvoort
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-11 00:00:00.000000000 Z
11
+ date: 2022-08-12 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
- version: '1.13'
19
+ version: 2.3.18
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.13'
26
+ version: 2.3.18
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -81,15 +81,8 @@ executables: []
81
81
  extensions: []
82
82
  extra_rdoc_files: []
83
83
  files:
84
- - ".circleci/config.yml"
85
- - ".gitignore"
86
- - ".rspec"
87
- - ".ruby-gemset"
88
- - ".ruby-version"
89
- - Gemfile
90
84
  - LICENSE.txt
91
85
  - README.md
92
- - Rakefile
93
86
  - lib/ostiary.rb
94
87
  - lib/ostiary/controller_helper.rb
95
88
  - lib/ostiary/ostiary.rb
@@ -97,7 +90,6 @@ files:
97
90
  - lib/ostiary/policy_exempted.rb
98
91
  - lib/ostiary/policy_limited.rb
99
92
  - lib/ostiary/version.rb
100
- - ostiary.gemspec
101
93
  homepage: https://github.com/nedap/ostiary
102
94
  licenses:
103
95
  - MIT
@@ -117,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
109
  - !ruby/object:Gem::Version
118
110
  version: '0'
119
111
  requirements: []
120
- rubygems_version: 3.0.3
112
+ rubygems_version: 3.3.11
121
113
  signing_key:
122
114
  specification_version: 4
123
115
  summary: Limit access to (rails) controllers/actions with policies
data/.circleci/config.yml DELETED
@@ -1,42 +0,0 @@
1
- version: 2
2
- jobs:
3
- build:
4
- docker:
5
- - image: circleci/ruby:2.6.5
6
-
7
- working_directory: ~/repo
8
-
9
- steps:
10
- - checkout
11
-
12
- - restore_cache:
13
- keys:
14
- - v1-dependencies-{{ checksum "Gemfile.lock" }}
15
- - v1-dependencies-
16
-
17
- - run:
18
- name: install dependencies
19
- command: |
20
- bundle install --jobs=4 --retry=3 --path vendor/bundle
21
-
22
- - save_cache:
23
- paths:
24
- - ./vendor/bundle
25
- key: v1-dependencies-{{ checksum "Gemfile.lock" }}
26
-
27
- - run:
28
- name: run tests
29
- command: |
30
- mkdir /tmp/test-results
31
- TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
32
- circleci tests split --split-by=timings)"
33
-
34
- bundle exec rspec \
35
- --format progress \
36
- --format RspecJunitFormatter \
37
- --out /tmp/test-results/rspec.xml \
38
- --format progress \
39
- $TEST_FILES
40
-
41
- - store_test_results:
42
- path: /tmp/test-results
data/.gitignore DELETED
@@ -1,53 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .rspec_status
4
- /.config
5
- /coverage/
6
- /InstalledFiles
7
- /pkg/
8
- /spec/reports/
9
- /spec/examples.txt
10
- /test/tmp/
11
- /test/version_tmp/
12
- /tmp/
13
-
14
- # Used by dotenv library to load environment variables.
15
- # .env
16
-
17
- ## Specific to RubyMotion:
18
- .dat*
19
- .repl_history
20
- build/
21
- *.bridgesupport
22
- build-iPhoneOS/
23
- build-iPhoneSimulator/
24
-
25
- ## Specific to RubyMotion (use of CocoaPods):
26
- #
27
- # We recommend against adding the Pods directory to your .gitignore. However
28
- # you should judge for yourself, the pros and cons are mentioned at:
29
- # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
30
- #
31
- # vendor/Pods/
32
-
33
- ## Documentation cache and generated files:
34
- /.yardoc/
35
- /_yardoc/
36
- /doc/
37
- /rdoc/
38
-
39
- ## Environment normalization:
40
- /.bundle/
41
- /vendor/bundle
42
- /lib/bundler/man/
43
-
44
- # for a library or gem, you might want to ignore these files since the code is
45
- # intended to run in multiple environments; otherwise, check them in:
46
- Gemfile.lock
47
- # .ruby-version
48
- # .ruby-gemset
49
-
50
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
51
- .rvmrc
52
-
53
- .DS_Store
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --format documentation
3
- --profile
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- ostiary
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.3.5
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in ostiary.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/ostiary.gemspec DELETED
@@ -1,36 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'ostiary/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "ostiary"
8
- spec.version = Ostiary::VERSION
9
- spec.author = "Jacques Hakvoort"
10
- spec.authors = ["Jacques Hakvoort"]
11
- spec.email = ["jacques.hakvoort@nedap.com"]
12
-
13
- spec.homepage = "https://github.com/nedap/ostiary"
14
- spec.summary = "Limit access to (rails) controllers/actions with policies"
15
- spec.description = <<-TXT;
16
- Ostiary is a security gem for your (rails) controllers & actions.
17
- It employs a before_filter-like call to set policies per controller/action.
18
- You can pass your own security call in block and handle the PolicyBroken
19
- yourself.
20
- Policies are also inherited from parent classes.
21
- From wikipedia: "An ostiarius, a Latin word sometimes anglicized as ostiary
22
- but often literally translated as porter or doorman, originally was a
23
- servant or guard posted at the entrance of a building. See also gatekeeper."
24
- TXT
25
- spec.license = 'MIT'
26
-
27
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
- f.match(%r{^(test|spec|features)/})
29
- end
30
- spec.require_paths = ["lib"]
31
-
32
- spec.add_development_dependency "bundler", "~> 1.13"
33
- spec.add_development_dependency "rake", "~> 10.0"
34
- spec.add_development_dependency "rspec", "~> 3.0"
35
- spec.add_development_dependency 'rspec_junit_formatter'
36
- end