fortress 0.2.1 → 0.2.2
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/.gitignore +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +2 -0
- data/README.md +1 -1
- data/lib/fortress/controller.rb +3 -1
- data/lib/fortress/version.rb +1 -1
- data/spec/fortress/authorisations_appending_spec.rb +43 -0
- data/spec/spec_helper.rb +3 -0
- metadata +4 -28
- data/bin/bundler +0 -16
- data/bin/erubis +0 -16
- data/bin/htmldiff +0 -16
- data/bin/ldiff +0 -16
- data/bin/nokogiri +0 -16
- data/bin/rackup +0 -16
- data/bin/rails +0 -16
- data/bin/rake +0 -16
- data/bin/rspec +0 -16
- data/bin/rubocop +0 -16
- data/bin/ruby-parse +0 -16
- data/bin/ruby-rewrite +0 -16
- data/bin/thor +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8807ceb07a787af9e28880231b85215cd11e10c4
|
4
|
+
data.tar.gz: 916d0af542ab25823cac2db1df20d7810502f8ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11fb3fce13b31dd8f0db8236051b7386df0c9d9007812aba764a4d2d1a724ef747e726a81ef939d2164a1f39ad46c7b2ddd8fc5c8d2d30200e629998a5add6a3
|
7
|
+
data.tar.gz: 38b701f41f66e26b1a7869fb7f08cfc54a2ce277c5bf3c328df2b0e189adceae8811364cdc9eb3607536a6e54b63d3c2f4eeced5014d33175be46973e1a54339
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Fortress
|
2
2
|
|
3
|
-
[](https://travis-ci.org/YourCursus/fortress) [](https://codeclimate.com/github/YourCursus/fortress) [](http://badge.fury.io/rb/fortress)
|
3
|
+
[](https://travis-ci.org/YourCursus/fortress) [](https://codeclimate.com/github/YourCursus/fortress) [](http://badge.fury.io/rb/fortress) [](https://codeclimate.com/github/YourCursus/fortress)
|
4
4
|
|
5
5
|
Implement the simple but powerful protection: close everything and open the
|
6
6
|
access explecitely.
|
data/lib/fortress/controller.rb
CHANGED
@@ -43,7 +43,9 @@ module Fortress
|
|
43
43
|
#
|
44
44
|
module ClassMethods
|
45
45
|
def fortress_allow(actions, options = {})
|
46
|
-
|
46
|
+
(options.blank? || actions == :all) &&
|
47
|
+
Mechanism.authorise!(name, actions)
|
48
|
+
|
47
49
|
Mechanism.parse_options(self, actions, options) if options.present?
|
48
50
|
end
|
49
51
|
end
|
data/lib/fortress/version.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Authorisations appending (YourCursus/fortress#7)' do
|
4
|
+
describe GuitarsController, type: :controller do
|
5
|
+
let(:controller) { 'GuitarsController' }
|
6
|
+
before { Fortress::Mechanism.initialize_authorisations }
|
7
|
+
context 'when calling the first time `fortress_allow` method' do
|
8
|
+
before { GuitarsController.fortress_allow [:index, :show] }
|
9
|
+
it 'should create a new authorisation for the controller' do
|
10
|
+
expect(Fortress::Mechanism.authorisations).to have_key(controller)
|
11
|
+
expect(Fortress::Mechanism.authorisations[controller])
|
12
|
+
.to eql(only: [:index, :show])
|
13
|
+
end
|
14
|
+
context 'when calling a second time `fortress_allow` method' do
|
15
|
+
before { GuitarsController.fortress_allow :create, if: true }
|
16
|
+
it 'should append keys to the existing controller authorisation' do
|
17
|
+
expect(Fortress::Mechanism.authorisations).to have_key(controller)
|
18
|
+
expect(Fortress::Mechanism.authorisations[controller])
|
19
|
+
.to eql(only: [:index, :show],
|
20
|
+
if: { method: true, actions: [:create] })
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when calling the first time `fortress_allow` method' do
|
26
|
+
before { GuitarsController.fortress_allow :all, except: :destroy }
|
27
|
+
it 'should create a new authorisation for the controller' do
|
28
|
+
expect(Fortress::Mechanism.authorisations).to have_key(controller)
|
29
|
+
expect(Fortress::Mechanism.authorisations[controller])
|
30
|
+
.to eql(all: true, except: [:destroy])
|
31
|
+
end
|
32
|
+
context 'when calling a second time `fortress_allow` method' do
|
33
|
+
before { GuitarsController.fortress_allow :destroy, if: true }
|
34
|
+
it 'should append keys to the existing controller authorisation' do
|
35
|
+
expect(Fortress::Mechanism.authorisations).to have_key(controller)
|
36
|
+
expect(Fortress::Mechanism.authorisations[controller])
|
37
|
+
.to eql(all: true, except: [:destroy],
|
38
|
+
if: { method: true, actions: [:destroy] })
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fortress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Hain
|
@@ -114,20 +114,7 @@ description: 'The rigths management libraries available today are all based on t
|
|
114
114
|
then up to you to open the allowed actions.'
|
115
115
|
email:
|
116
116
|
- zedtux@zedroot.org
|
117
|
-
executables:
|
118
|
-
- bundler
|
119
|
-
- erubis
|
120
|
-
- htmldiff
|
121
|
-
- ldiff
|
122
|
-
- nokogiri
|
123
|
-
- rackup
|
124
|
-
- rails
|
125
|
-
- rake
|
126
|
-
- rspec
|
127
|
-
- rubocop
|
128
|
-
- ruby-parse
|
129
|
-
- ruby-rewrite
|
130
|
-
- thor
|
117
|
+
executables: []
|
131
118
|
extensions: []
|
132
119
|
extra_rdoc_files: []
|
133
120
|
files:
|
@@ -140,19 +127,6 @@ files:
|
|
140
127
|
- LICENSE.txt
|
141
128
|
- README.md
|
142
129
|
- Rakefile
|
143
|
-
- bin/bundler
|
144
|
-
- bin/erubis
|
145
|
-
- bin/htmldiff
|
146
|
-
- bin/ldiff
|
147
|
-
- bin/nokogiri
|
148
|
-
- bin/rackup
|
149
|
-
- bin/rails
|
150
|
-
- bin/rake
|
151
|
-
- bin/rspec
|
152
|
-
- bin/rubocop
|
153
|
-
- bin/ruby-parse
|
154
|
-
- bin/ruby-rewrite
|
155
|
-
- bin/thor
|
156
130
|
- fortress.gemspec
|
157
131
|
- lib/fortress.rb
|
158
132
|
- lib/fortress/configuration.rb
|
@@ -163,6 +137,7 @@ files:
|
|
163
137
|
- spec/fixtures/application.rb
|
164
138
|
- spec/fixtures/controllers.rb
|
165
139
|
- spec/fortress/access_deny_spec.rb
|
140
|
+
- spec/fortress/authorisations_appending_spec.rb
|
166
141
|
- spec/fortress/configuration_spec.rb
|
167
142
|
- spec/fortress/controller_interface_spec.rb
|
168
143
|
- spec/fortress/controller_spec.rb
|
@@ -198,6 +173,7 @@ test_files:
|
|
198
173
|
- spec/fixtures/application.rb
|
199
174
|
- spec/fixtures/controllers.rb
|
200
175
|
- spec/fortress/access_deny_spec.rb
|
176
|
+
- spec/fortress/authorisations_appending_spec.rb
|
201
177
|
- spec/fortress/configuration_spec.rb
|
202
178
|
- spec/fortress/controller_interface_spec.rb
|
203
179
|
- spec/fortress/controller_spec.rb
|
data/bin/bundler
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'bundler' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('bundler', 'bundler')
|
data/bin/erubis
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'erubis' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('erubis', 'erubis')
|
data/bin/htmldiff
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'htmldiff' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('diff-lcs', 'htmldiff')
|
data/bin/ldiff
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'ldiff' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('diff-lcs', 'ldiff')
|
data/bin/nokogiri
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'nokogiri' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('nokogiri', 'nokogiri')
|
data/bin/rackup
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rackup' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('rack', 'rackup')
|
data/bin/rails
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rails' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('railties', 'rails')
|
data/bin/rake
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rake' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('rake', 'rake')
|
data/bin/rspec
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rspec' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/rubocop
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'rubocop' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('rubocop', 'rubocop')
|
data/bin/ruby-parse
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'ruby-parse' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('parser', 'ruby-parse')
|
data/bin/ruby-rewrite
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'ruby-rewrite' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('parser', 'ruby-rewrite')
|
data/bin/thor
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'thor' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'pathname'
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
load Gem.bin_path('thor', 'thor')
|