miau 1.1.6 → 1.1.8

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/miau/error.rb +4 -8
  4. data/lib/miau/run.rb +2 -2
  5. data/lib/miau/storage.rb.bak +63 -0
  6. data/lib/miau/version.rb +3 -1
  7. data/lib/miau/version.rb.bak +17 -0
  8. data/lib/miau.rb +5 -0
  9. data/lib/miau.rb.bak +72 -0
  10. metadata +16 -44
  11. data/.github/workflows/rake.yml +0 -27
  12. data/.gitignore +0 -10
  13. data/.ruby-gemset +0 -1
  14. data/.ruby-version +0 -1
  15. data/Appraisals +0 -13
  16. data/Gemfile +0 -12
  17. data/Gemfile.lock +0 -279
  18. data/Rakefile +0 -10
  19. data/gemfiles/rails_6.1.gemfile +0 -16
  20. data/gemfiles/rails_7.0.gemfile +0 -16
  21. data/gemfiles/rails_7.1.gemfile +0 -15
  22. data/miau.gemspec +0 -27
  23. data/test/authorization_test.rb +0 -28
  24. data/test/benchmark_test.rb +0 -34
  25. data/test/controller_test.rb +0 -58
  26. data/test/controllers/orders_controller_test.rb +0 -47
  27. data/test/internal/app/controllers/application_controller.rb +0 -7
  28. data/test/internal/app/controllers/orders_controller.rb +0 -61
  29. data/test/internal/app/controllers/posts_controller.rb +0 -10
  30. data/test/internal/app/models/application_record.rb +0 -3
  31. data/test/internal/app/models/order.rb +0 -2
  32. data/test/internal/app/models/post.rb +0 -2
  33. data/test/internal/app/policies/orders_policy.rb +0 -16
  34. data/test/internal/app/policies/posts_policy.rb +0 -18
  35. data/test/internal/app/views/orders/new.html.erb +0 -5
  36. data/test/internal/config/database.yml +0 -3
  37. data/test/internal/config/routes.rb +0 -3
  38. data/test/internal/db/migrate/20141016161801_create_orders.rb +0 -10
  39. data/test/internal/db/schema.rb +0 -8
  40. data/test/miau_test.rb +0 -46
  41. data/test/run_test.rb +0 -69
  42. data/test/storage_test.rb +0 -51
  43. data/test/test_helper.rb +0 -17
  44. /data/{LICENSE → MIT-LICENSE} +0 -0
data/Gemfile.lock DELETED
@@ -1,279 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- miau (1.1.6)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- actioncable (7.1.2)
10
- actionpack (= 7.1.2)
11
- activesupport (= 7.1.2)
12
- nio4r (~> 2.0)
13
- websocket-driver (>= 0.6.1)
14
- zeitwerk (~> 2.6)
15
- actionmailbox (7.1.2)
16
- actionpack (= 7.1.2)
17
- activejob (= 7.1.2)
18
- activerecord (= 7.1.2)
19
- activestorage (= 7.1.2)
20
- activesupport (= 7.1.2)
21
- mail (>= 2.7.1)
22
- net-imap
23
- net-pop
24
- net-smtp
25
- actionmailer (7.1.2)
26
- actionpack (= 7.1.2)
27
- actionview (= 7.1.2)
28
- activejob (= 7.1.2)
29
- activesupport (= 7.1.2)
30
- mail (~> 2.5, >= 2.5.4)
31
- net-imap
32
- net-pop
33
- net-smtp
34
- rails-dom-testing (~> 2.2)
35
- actionpack (7.1.2)
36
- actionview (= 7.1.2)
37
- activesupport (= 7.1.2)
38
- nokogiri (>= 1.8.5)
39
- racc
40
- rack (>= 2.2.4)
41
- rack-session (>= 1.0.1)
42
- rack-test (>= 0.6.3)
43
- rails-dom-testing (~> 2.2)
44
- rails-html-sanitizer (~> 1.6)
45
- actiontext (7.1.2)
46
- actionpack (= 7.1.2)
47
- activerecord (= 7.1.2)
48
- activestorage (= 7.1.2)
49
- activesupport (= 7.1.2)
50
- globalid (>= 0.6.0)
51
- nokogiri (>= 1.8.5)
52
- actionview (7.1.2)
53
- activesupport (= 7.1.2)
54
- builder (~> 3.1)
55
- erubi (~> 1.11)
56
- rails-dom-testing (~> 2.2)
57
- rails-html-sanitizer (~> 1.6)
58
- activejob (7.1.2)
59
- activesupport (= 7.1.2)
60
- globalid (>= 0.3.6)
61
- activemodel (7.1.2)
62
- activesupport (= 7.1.2)
63
- activerecord (7.1.2)
64
- activemodel (= 7.1.2)
65
- activesupport (= 7.1.2)
66
- timeout (>= 0.4.0)
67
- activestorage (7.1.2)
68
- actionpack (= 7.1.2)
69
- activejob (= 7.1.2)
70
- activerecord (= 7.1.2)
71
- activesupport (= 7.1.2)
72
- marcel (~> 1.0)
73
- activesupport (7.1.2)
74
- base64
75
- bigdecimal
76
- concurrent-ruby (~> 1.0, >= 1.0.2)
77
- connection_pool (>= 2.2.5)
78
- drb
79
- i18n (>= 1.6, < 2)
80
- minitest (>= 5.1)
81
- mutex_m
82
- tzinfo (~> 2.0)
83
- appraisal (2.5.0)
84
- bundler
85
- rake
86
- thor (>= 0.14.0)
87
- ast (2.4.2)
88
- base64 (0.2.0)
89
- benchmark-ips (2.13.0)
90
- bigdecimal (3.1.5)
91
- builder (3.2.4)
92
- combustion (1.3.7)
93
- activesupport (>= 3.0.0)
94
- railties (>= 3.0.0)
95
- thor (>= 0.14.6)
96
- concurrent-ruby (1.2.2)
97
- connection_pool (2.4.1)
98
- crass (1.0.6)
99
- date (3.3.4)
100
- docile (1.4.0)
101
- drb (2.2.0)
102
- ruby2_keywords
103
- erubi (1.12.0)
104
- globalid (1.2.1)
105
- activesupport (>= 6.1)
106
- i18n (1.14.1)
107
- concurrent-ruby (~> 1.0)
108
- io-console (0.7.1)
109
- irb (1.11.1)
110
- rdoc
111
- reline (>= 0.4.2)
112
- json (2.7.1)
113
- language_server-protocol (3.17.0.3)
114
- lint_roller (1.1.0)
115
- loofah (2.22.0)
116
- crass (~> 1.0.2)
117
- nokogiri (>= 1.12.0)
118
- mail (2.8.1)
119
- mini_mime (>= 0.1.1)
120
- net-imap
121
- net-pop
122
- net-smtp
123
- marcel (1.0.2)
124
- mini_mime (1.1.5)
125
- minitest (5.21.1)
126
- mutex_m (0.2.0)
127
- net-imap (0.4.9.1)
128
- date
129
- net-protocol
130
- net-pop (0.1.2)
131
- net-protocol
132
- net-protocol (0.2.2)
133
- timeout
134
- net-smtp (0.4.0.1)
135
- net-protocol
136
- nio4r (2.7.0)
137
- nokogiri (1.16.0-aarch64-linux)
138
- racc (~> 1.4)
139
- nokogiri (1.16.0-arm-linux)
140
- racc (~> 1.4)
141
- nokogiri (1.16.0-arm64-darwin)
142
- racc (~> 1.4)
143
- nokogiri (1.16.0-x86-linux)
144
- racc (~> 1.4)
145
- nokogiri (1.16.0-x86_64-darwin)
146
- racc (~> 1.4)
147
- nokogiri (1.16.0-x86_64-linux)
148
- racc (~> 1.4)
149
- observr (1.0.5)
150
- parallel (1.24.0)
151
- parser (3.3.0.3)
152
- ast (~> 2.4.1)
153
- racc
154
- psych (5.1.2)
155
- stringio
156
- racc (1.7.3)
157
- rack (3.0.8)
158
- rack-session (2.0.0)
159
- rack (>= 3.0.0)
160
- rack-test (2.1.0)
161
- rack (>= 1.3)
162
- rackup (2.1.0)
163
- rack (>= 3)
164
- webrick (~> 1.8)
165
- rails (7.1.2)
166
- actioncable (= 7.1.2)
167
- actionmailbox (= 7.1.2)
168
- actionmailer (= 7.1.2)
169
- actionpack (= 7.1.2)
170
- actiontext (= 7.1.2)
171
- actionview (= 7.1.2)
172
- activejob (= 7.1.2)
173
- activemodel (= 7.1.2)
174
- activerecord (= 7.1.2)
175
- activestorage (= 7.1.2)
176
- activesupport (= 7.1.2)
177
- bundler (>= 1.15.0)
178
- railties (= 7.1.2)
179
- rails-dom-testing (2.2.0)
180
- activesupport (>= 5.0.0)
181
- minitest
182
- nokogiri (>= 1.6)
183
- rails-html-sanitizer (1.6.0)
184
- loofah (~> 2.21)
185
- nokogiri (~> 1.14)
186
- railties (7.1.2)
187
- actionpack (= 7.1.2)
188
- activesupport (= 7.1.2)
189
- irb
190
- rackup (>= 1.0.0)
191
- rake (>= 12.2)
192
- thor (~> 1.0, >= 1.2.2)
193
- zeitwerk (~> 2.6)
194
- rainbow (3.1.1)
195
- rake (13.1.0)
196
- rdoc (6.6.2)
197
- psych (>= 4.0.0)
198
- regexp_parser (2.9.0)
199
- reline (0.4.2)
200
- io-console (~> 0.5)
201
- rexml (3.2.6)
202
- ricecream (0.2.1)
203
- rubocop (1.59.0)
204
- json (~> 2.3)
205
- language_server-protocol (>= 3.17.0)
206
- parallel (~> 1.10)
207
- parser (>= 3.2.2.4)
208
- rainbow (>= 2.2.2, < 4.0)
209
- regexp_parser (>= 1.8, < 3.0)
210
- rexml (>= 3.2.5, < 4.0)
211
- rubocop-ast (>= 1.30.0, < 2.0)
212
- ruby-progressbar (~> 1.7)
213
- unicode-display_width (>= 2.4.0, < 3.0)
214
- rubocop-ast (1.30.0)
215
- parser (>= 3.2.1.0)
216
- rubocop-performance (1.20.2)
217
- rubocop (>= 1.48.1, < 2.0)
218
- rubocop-ast (>= 1.30.0, < 2.0)
219
- ruby-progressbar (1.13.0)
220
- ruby2_keywords (0.0.5)
221
- simplecov (0.22.0)
222
- docile (~> 1.1)
223
- simplecov-html (~> 0.11)
224
- simplecov_json_formatter (~> 0.1)
225
- simplecov-html (0.12.3)
226
- simplecov_json_formatter (0.1.4)
227
- sqlite3 (1.7.0-aarch64-linux)
228
- sqlite3 (1.7.0-arm-linux)
229
- sqlite3 (1.7.0-arm64-darwin)
230
- sqlite3 (1.7.0-x86-linux)
231
- sqlite3 (1.7.0-x86_64-darwin)
232
- sqlite3 (1.7.0-x86_64-linux)
233
- standard (1.33.0)
234
- language_server-protocol (~> 3.17.0.2)
235
- lint_roller (~> 1.0)
236
- rubocop (~> 1.59.0)
237
- standard-custom (~> 1.0.0)
238
- standard-performance (~> 1.3)
239
- standard-custom (1.0.2)
240
- lint_roller (~> 1.0)
241
- rubocop (~> 1.50)
242
- standard-performance (1.3.1)
243
- lint_roller (~> 1.1)
244
- rubocop-performance (~> 1.20.2)
245
- stringio (3.1.0)
246
- thor (1.3.0)
247
- timeout (0.4.1)
248
- tzinfo (2.0.6)
249
- concurrent-ruby (~> 1.0)
250
- unicode-display_width (2.5.0)
251
- webrick (1.8.1)
252
- websocket-driver (0.7.6)
253
- websocket-extensions (>= 0.1.0)
254
- websocket-extensions (0.1.5)
255
- zeitwerk (2.6.12)
256
-
257
- PLATFORMS
258
- aarch64-linux
259
- arm-linux
260
- arm64-darwin
261
- x86-linux
262
- x86_64-darwin
263
- x86_64-linux
264
-
265
- DEPENDENCIES
266
- appraisal
267
- benchmark-ips
268
- combustion
269
- miau!
270
- minitest
271
- observr
272
- rails
273
- ricecream
274
- simplecov
275
- sqlite3
276
- standard
277
-
278
- BUNDLED WITH
279
- 2.5.3
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "rake/testtask"
2
-
3
- desc "Run the tests."
4
- Rake::TestTask.new do |t|
5
- t.libs << "test"
6
- t.pattern = "test/**/*_test.rb"
7
- t.verbose = false
8
- end
9
-
10
- task default: :test
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 6.1"
6
- gem "dryer-config", "~> 6.0"
7
-
8
- group :test do
9
- gem "benchmark-ips"
10
- gem "observr"
11
- gem "ricecream"
12
- gem "simplecov", require: false
13
- gem "standard", require: false
14
- end
15
-
16
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 7.0"
6
- gem "dryer-config", "~> 7.0"
7
-
8
- group :test do
9
- gem "benchmark-ips"
10
- gem "observr"
11
- gem "ricecream"
12
- gem "simplecov", require: false
13
- gem "standard", require: false
14
- end
15
-
16
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 7.1"
6
-
7
- group :test do
8
- gem "benchmark-ips"
9
- gem "observr"
10
- gem "ricecream"
11
- gem "simplecov", require: false
12
- gem "standard", require: false
13
- end
14
-
15
- gemspec path: "../"
data/miau.gemspec DELETED
@@ -1,27 +0,0 @@
1
- require_relative "lib/miau/version"
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "miau"
5
- s.version = Miau::VERSION
6
- s.platform = Gem::Platform::RUBY
7
- s.summary = %(Simple and lightweight authorization solution for Rails.)
8
- s.license = "MIT"
9
-
10
- s.description = <<~EOS
11
- MIAU (MIcro AUthorization) provides some helpers which
12
- raises an exception if a given user violates a policy.
13
- EOS
14
-
15
- s.authors = ["Dittmar Krall"]
16
- s.email = "dittmar.krall@matiq.com"
17
- s.homepage = "https://github.com/matique/miau"
18
-
19
- s.files = `git ls-files`.split("\n")
20
- s.require_paths = ["lib"]
21
-
22
- s.add_development_dependency "appraisal"
23
- s.add_development_dependency "combustion"
24
- s.add_development_dependency "minitest"
25
- s.add_development_dependency "ricecream"
26
- s.add_development_dependency "sqlite3"
27
- end
@@ -1,28 +0,0 @@
1
- require "test_helper"
2
-
3
- describe Miau, "performed authorization" do
4
- let(:user) { "User" }
5
- let(:post) { Post.new(user, 1) }
6
- let(:params) { {action: "si", controller: "posts"} }
7
- let(:posts_controller) { PostsController.new(user, params) }
8
-
9
- def test_does_nothing_when_authorized
10
- posts_controller.authorize!(post)
11
- posts_controller.verify_authorized
12
- end
13
-
14
- def test_exception_when_not_authorized
15
- assert_raises(Miau::AuthorizationNotPerformedError) {
16
- posts_controller.verify_authorized
17
- }
18
- end
19
-
20
- def test_authorization_performed
21
- posts_controller.authorize!(post)
22
- assert posts_controller.miau_authorization_performed?
23
- end
24
-
25
- def test_authorization_not_performed
26
- refute posts_controller.miau_authorization_performed?
27
- end
28
- end
@@ -1,34 +0,0 @@
1
- require "test_helper"
2
- require "benchmark"
3
- require "benchmark/ips"
4
-
5
- describe "Internal timings" do
6
- let(:user) { "User" }
7
- let(:params) { {action: "si", controller: "posts"} }
8
- let(:posts_controller) { PostsController.new(user, params) }
9
- let(:storage) { Miau::PolicyStorage.instance }
10
-
11
- # run_flag = true
12
- run_flag ||= false
13
-
14
- it "times ips" do
15
- return unless run_flag
16
-
17
- Benchmark.ips do |x|
18
- x.report("empty ") {}
19
- x.report("authorize! ") { posts_controller.authorize! }
20
- x.report("authorized? ") { posts_controller.authorized? }
21
- # x.report("PostsPolicy.new") { PostsPolicy.new }
22
- # x.report("find_or_create_policy") {
23
- # storage.find_or_create_policy "application"
24
- # }
25
- # x.report("name & constantize.new") {
26
- # klass = :posts
27
- # name = "#{klass.to_s.camelcase}Policy"
28
- # name.constantize.new
29
- # }
30
-
31
- x.compare!
32
- end
33
- end
34
- end
@@ -1,58 +0,0 @@
1
- require "test_helper"
2
-
3
- class NotController
4
- include Miau
5
-
6
- attr_accessor :current_user, :params
7
-
8
- def initialize(current_user, params = {})
9
- @current_user = current_user
10
- @params = params
11
- end
12
- end
13
-
14
- class NotPolicy < ApplicationPolicy
15
- end
16
-
17
- class FalseController
18
- include Miau
19
-
20
- attr_accessor :current_user, :params
21
-
22
- def initialize(current_user, params = {})
23
- @current_user = current_user
24
- @params = params
25
- end
26
- end
27
-
28
- class FalsePolicy < ApplicationPolicy
29
- def controller
30
- false
31
- end
32
- end
33
-
34
- describe Miau, "controller" do
35
- let(:user) { "User" }
36
-
37
- def test_authorize_controller!
38
- params = {controller: "posts", action: :any}
39
- posts_controller = PostsController.new(user, params)
40
- posts_controller.authorize_controller!
41
- end
42
-
43
- def test_authorize_controller_not_defined
44
- params = {controller: "not", action: :any}
45
- not_controller = NotController.new(user, params)
46
- assert_raises(Miau::NotDefinedError) {
47
- not_controller.authorize_controller!
48
- }
49
- end
50
-
51
- def test_authorize_controller_false
52
- params = {controller: "false", action: :any}
53
- false_controller = FalseController.new(user, params)
54
- assert_raises(Miau::NotAuthorizedError) {
55
- false_controller.authorize_controller!
56
- }
57
- end
58
- end
@@ -1,47 +0,0 @@
1
- require "test_helper"
2
-
3
- class OrdersControllerTest < ActionDispatch::IntegrationTest
4
- setup do
5
- @order = Order.create!(name: "Name", qty: 123)
6
- end
7
-
8
- def test_new
9
- out, _err = capture_io do
10
- get new_order_url
11
- end
12
-
13
- assert_response :success
14
- assert_equal "controller\nnew\n", out
15
- end
16
-
17
- def test_create
18
- out, _err = capture_io do
19
- assert_difference("Order.count") do
20
- post orders_url, params: {order: {name: @order.name, qty: 234}}
21
- end
22
- end
23
-
24
- assert_redirected_to order_url(Order.last)
25
- assert_equal "controller\n", out
26
- end
27
-
28
- def test_update
29
- out, _err = capture_io do
30
- patch order_url(@order), params: {order: {name: @order.name}}
31
- end
32
-
33
- assert_redirected_to order_url(@order)
34
- assert_equal "controller\n", out
35
- end
36
-
37
- def test_destroy
38
- out, _err = capture_io do
39
- assert_difference("Order.count", -1) do
40
- delete order_url(@order)
41
- end
42
- end
43
-
44
- assert_redirected_to orders_url
45
- assert_equal "controller\ndestroy\n", out
46
- end
47
- end
@@ -1,7 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- include Miau
3
-
4
- def miau_user
5
- "User"
6
- end
7
- end
@@ -1,61 +0,0 @@
1
- class OrdersController < ApplicationController
2
- before_action :authorize_controller!
3
- before_action :set_order, only: %i[show edit update destroy]
4
-
5
- # # GET /orders
6
- # def index
7
- # @orders = Order.all
8
- # end
9
- #
10
- # # GET /orders/1
11
- # def show
12
- # end
13
-
14
- # GET /orders/new
15
- def new
16
- @order = Order.new
17
- end
18
-
19
- # # GET /orders/1/edit
20
- # def edit
21
- # end
22
-
23
- # POST /orders
24
- def create
25
- @order = Order.new(order_params)
26
-
27
- if @order.save
28
- redirect_to @order, notice: "Order was successfully created."
29
- else
30
- render :new, status: :unprocessable_entity
31
- end
32
- end
33
-
34
- # PATCH/PUT /orders/1
35
- def update
36
- if @order.update(order_params)
37
- redirect_to @order, notice: "Order was successfully updated.", status: :see_other
38
- else
39
- render :edit, status: :unprocessable_entity
40
- end
41
- end
42
-
43
- # DELETE /orders/1
44
- def destroy
45
- authorize!
46
- @order.destroy!
47
- redirect_to orders_url, notice: "Order was successfully destroyed.", status: :see_other
48
- end
49
-
50
- private
51
-
52
- # Use callbacks to share common setup or constraints between actions.
53
- def set_order
54
- @order = Order.find(params[:id])
55
- end
56
-
57
- # Only allow a list of trusted parameters through.
58
- def order_params
59
- params.require(:order).permit(:name, :qty)
60
- end
61
- end
@@ -1,10 +0,0 @@
1
- class PostsController
2
- include Miau
3
-
4
- attr_accessor :current_user, :params
5
-
6
- def initialize(current_user, params = {})
7
- @current_user = current_user
8
- @params = params
9
- end
10
- end
@@ -1,3 +0,0 @@
1
- class ApplicationRecord < ActiveRecord::Base
2
- primary_abstract_class
3
- end
@@ -1,2 +0,0 @@
1
- class Order < ApplicationRecord
2
- end
@@ -1,2 +0,0 @@
1
- class Post < Struct.new(:user, :id)
2
- end
@@ -1,16 +0,0 @@
1
- class OrdersPolicy < ApplicationPolicy
2
- def controller
3
- puts :controller
4
- true
5
- end
6
-
7
- def new
8
- puts :new
9
- true
10
- end
11
-
12
- def destroy
13
- puts :destroy
14
- true
15
- end
16
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class PostsPolicy < ApplicationPolicy
4
- miau %i[asi bsi], :si
5
- miau %i[sino], %i[si no]
6
-
7
- def controller
8
- true
9
- end
10
-
11
- def si
12
- true
13
- end
14
-
15
- def no
16
- false
17
- end
18
- end
@@ -1,5 +0,0 @@
1
- <% if authorized? %>
2
- <p> authorized </p>
3
- <% else %>
4
- <p> NOT authorized </p>
5
- <% end %>
@@ -1,3 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: db/test.sqlite3
@@ -1,3 +0,0 @@
1
- Rails.application.routes.draw do
2
- resources :orders
3
- end
@@ -1,10 +0,0 @@
1
- class CreateOrders < ActiveRecord::Migration
2
- def change
3
- create_table :orders do |t|
4
- t.string :name
5
- t.string :qty
6
-
7
- t.timestamps null: false
8
- end
9
- end
10
- end