yamled_acl 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -1
- data/.rspec +0 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +43 -40
- data/README.markdown +13 -2
- data/Rakefile +2 -10
- data/init.rb +0 -0
- data/lib/yamled_acl/controller_extension.rb +3 -3
- data/lib/yamled_acl/exceptions.rb +0 -0
- data/lib/yamled_acl/version.rb +1 -1
- data/lib/yamled_acl.rb +0 -0
- data/spec/{example_files → fixtures}/example_permissions.yml +0 -0
- data/spec/{example_files → fixtures}/example_permissions_2.yml +0 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/yamled_acl/controller_extension_spec.rb +11 -11
- data/spec/yamled_acl_spec.rb +1 -1
- data/yamled_acl.gemspec +2 -2
- metadata +52 -91
- data/spec/plik +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1b0e6c4c449f724a8dbe3dae1d3eb47166d65ef5
|
4
|
+
data.tar.gz: cd7071eb61d90357c282d24fe12755890b3e332d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c400c686a23716349cddd755b8925373c16bb24c300819990cc416d45f2bfa1e522e4424a2951cf6b20808ad25ae473dfbb3cf1164ebf1e5b8d3db6888e0f10
|
7
|
+
data.tar.gz: f4d4725bc74d3f99498c64900bcc5550d0a06d1af04701ba59772492b0016c3b6daeb8449ba7d8e7d15394ed38253cb79ce9273d521662a6533e4ff0734691e4
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
File without changes
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -4,52 +4,55 @@ PATH
|
|
4
4
|
yamled_acl (0.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
|
-
remote:
|
7
|
+
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
rack (~> 1.2
|
17
|
-
rack-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
i18n (
|
24
|
-
|
25
|
-
builder (
|
26
|
-
diff-lcs (1.1
|
27
|
-
erubis (2.
|
28
|
-
|
29
|
-
i18n (0.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rack-
|
9
|
+
actionpack (3.2.13)
|
10
|
+
activemodel (= 3.2.13)
|
11
|
+
activesupport (= 3.2.13)
|
12
|
+
builder (~> 3.0.0)
|
13
|
+
erubis (~> 2.7.0)
|
14
|
+
journey (~> 1.0.4)
|
15
|
+
rack (~> 1.4.5)
|
16
|
+
rack-cache (~> 1.2)
|
17
|
+
rack-test (~> 0.6.1)
|
18
|
+
sprockets (~> 2.2.1)
|
19
|
+
activemodel (3.2.13)
|
20
|
+
activesupport (= 3.2.13)
|
21
|
+
builder (~> 3.0.0)
|
22
|
+
activesupport (3.2.13)
|
23
|
+
i18n (= 0.6.1)
|
24
|
+
multi_json (~> 1.0)
|
25
|
+
builder (3.0.4)
|
26
|
+
diff-lcs (1.2.1)
|
27
|
+
erubis (2.7.0)
|
28
|
+
hike (1.2.1)
|
29
|
+
i18n (0.6.1)
|
30
|
+
journey (1.0.4)
|
31
|
+
multi_json (1.7.2)
|
32
|
+
rack (1.4.5)
|
33
|
+
rack-cache (1.2)
|
34
|
+
rack (>= 0.4)
|
35
|
+
rack-test (0.6.2)
|
34
36
|
rack (>= 1.0)
|
35
|
-
|
36
|
-
|
37
|
-
rspec-
|
38
|
-
rspec-
|
39
|
-
|
40
|
-
rspec-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
rspec (2.13.0)
|
38
|
+
rspec-core (~> 2.13.0)
|
39
|
+
rspec-expectations (~> 2.13.0)
|
40
|
+
rspec-mocks (~> 2.13.0)
|
41
|
+
rspec-core (2.13.1)
|
42
|
+
rspec-expectations (2.13.0)
|
43
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
44
|
+
rspec-mocks (2.13.0)
|
45
|
+
sprockets (2.2.2)
|
46
|
+
hike (~> 1.2)
|
47
|
+
multi_json (~> 1.0)
|
48
|
+
rack (~> 1.0)
|
49
|
+
tilt (~> 1.1, != 1.3.0)
|
50
|
+
tilt (1.3.6)
|
47
51
|
|
48
52
|
PLATFORMS
|
49
53
|
ruby
|
50
54
|
|
51
55
|
DEPENDENCIES
|
52
56
|
actionpack (~> 3.0)
|
53
|
-
|
54
|
-
rspec (~> 2.0)
|
57
|
+
rspec (~> 2.13)
|
55
58
|
yamled_acl!
|
data/README.markdown
CHANGED
@@ -39,7 +39,7 @@ An example:
|
|
39
39
|
|
40
40
|
In the ApplicationController you should add
|
41
41
|
|
42
|
-
before_filter :
|
42
|
+
before_filter :authorize_action
|
43
43
|
|
44
44
|
It assumes that there is already defined *current_user* method which returns logged user object. User object should respond to *group_name* method which should return name of current user group. If you want to override method name returning group name it could be done by current_user_group_method of the controller. Here is an example:
|
45
45
|
|
@@ -47,7 +47,7 @@ It assumes that there is already defined *current_user* method which returns log
|
|
47
47
|
|
48
48
|
class ApplicationController < ActionController::Base
|
49
49
|
current_user_group_method: group
|
50
|
-
before_filter :
|
50
|
+
before_filter :authorize_action
|
51
51
|
end
|
52
52
|
|
53
53
|
## Setting up permissions ##
|
@@ -77,6 +77,17 @@ Following methods may be used in controllers and views:
|
|
77
77
|
|
78
78
|
* **logged_in?** - returns true if there is a logged in user
|
79
79
|
|
80
|
+
## ChangeLog ##
|
81
|
+
|
82
|
+
0.3.0 (March 24, 2013)
|
83
|
+
|
84
|
+
* ruby 2.0 compatibility
|
85
|
+
* authorize method name relpaced with less conflicting authorize_action
|
86
|
+
|
87
|
+
0.2.0 (November 9, 2010)
|
88
|
+
|
89
|
+
* first official release
|
90
|
+
|
80
91
|
## Copyright ##
|
81
92
|
|
82
93
|
Copyright © 2010 Paweł Kubicki. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require '
|
2
|
+
require 'rdoc/task'
|
3
3
|
|
4
4
|
desc 'Generate documentation for the yamled_acl plugin.'
|
5
5
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
@@ -12,16 +12,11 @@ end
|
|
12
12
|
require "rspec/core/rake_task"
|
13
13
|
RSpec::Core::RakeTask.new(:spec)
|
14
14
|
|
15
|
-
|
16
|
-
RSpec::Core::RakeTask.new(:rcov) do |t|
|
17
|
-
t.rcov = true
|
18
|
-
t.rcov_opts = %q[--exclude "spec" --text-report]
|
19
|
-
end
|
15
|
+
task :default => :spec
|
20
16
|
|
21
17
|
desc "Build current version as a rubygem"
|
22
18
|
task :build do
|
23
19
|
`gem build yamled_acl.gemspec`
|
24
|
-
`mkdir -p pkg`
|
25
20
|
`mv yamled_acl-*.gem pkg/`
|
26
21
|
end
|
27
22
|
|
@@ -32,6 +27,3 @@ task :release => :build do
|
|
32
27
|
`git push origin master --tags`
|
33
28
|
`gem push pkg/yamled_acl-#{YamledAcl::VERSION}.gem`
|
34
29
|
end
|
35
|
-
|
36
|
-
task :default => :spec
|
37
|
-
|
data/init.rb
CHANGED
File without changes
|
@@ -51,9 +51,9 @@ module YamledAcl
|
|
51
51
|
|
52
52
|
# This method should be be called by +before_filter+.
|
53
53
|
#
|
54
|
-
# before_filter :
|
54
|
+
# before_filter :authorize_action
|
55
55
|
#
|
56
|
-
def
|
56
|
+
def authorize_action
|
57
57
|
YamledAcl.init(current_user_group_name, params[:controller])
|
58
58
|
allowed_to?(params[:action]) or raise(YamledAcl::AccessDenied)
|
59
59
|
end
|
@@ -64,7 +64,7 @@ module YamledAcl
|
|
64
64
|
!!current_user
|
65
65
|
end
|
66
66
|
|
67
|
-
# Returns current user group name. Used by +
|
67
|
+
# Returns current user group name. Used by +authorize_action+.
|
68
68
|
def current_user_group_name
|
69
69
|
logged_in? ? current_user.send(self.class.current_user_group_method) : YamledAcl.guest_group_name
|
70
70
|
end
|
File without changes
|
data/lib/yamled_acl/version.rb
CHANGED
data/lib/yamled_acl.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
@@ -12,16 +12,16 @@ describe YamledAcl::ControllerExtension do
|
|
12
12
|
@controller = @controller_class.new
|
13
13
|
end
|
14
14
|
|
15
|
-
it "responds to #
|
16
|
-
@controller.
|
15
|
+
it "responds to #authorize_action" do
|
16
|
+
@controller.respond_to?(:authorize_action, true).should be_true
|
17
17
|
end
|
18
18
|
|
19
19
|
it "responds to #logged_in?" do
|
20
|
-
@controller.
|
20
|
+
@controller.respond_to?(:logged_in?, true).should be_true
|
21
21
|
end
|
22
22
|
|
23
23
|
it "responds to #current_user_group_name" do
|
24
|
-
@controller.
|
24
|
+
@controller.respond_to?(:current_user_group_name, true).should be_true
|
25
25
|
end
|
26
26
|
|
27
27
|
context "given logged in user with admin group" do
|
@@ -54,17 +54,17 @@ describe YamledAcl::ControllerExtension do
|
|
54
54
|
@controller.stub(:params).and_return({:action => "admin_allowed_action"})
|
55
55
|
end
|
56
56
|
|
57
|
-
describe "#
|
57
|
+
describe "#authorize_action" do
|
58
58
|
|
59
59
|
it "doesn't raise any error" do
|
60
|
-
expect{@controller.send(:
|
60
|
+
expect{@controller.send(:authorize_action)}.to_not raise_error
|
61
61
|
end
|
62
62
|
|
63
63
|
it "returns true" do
|
64
|
-
@controller.send(:
|
64
|
+
@controller.send(:authorize_action).should == true
|
65
65
|
end
|
66
66
|
|
67
|
-
end # #
|
67
|
+
end # #authorize_action
|
68
68
|
|
69
69
|
end # when trying to perform action with granted access
|
70
70
|
|
@@ -79,13 +79,13 @@ describe YamledAcl::ControllerExtension do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
describe "#
|
82
|
+
describe "#authorize_action" do
|
83
83
|
|
84
84
|
it "raises YamledAcl::AccessDenied" do
|
85
|
-
expect{@controller.send(:
|
85
|
+
expect{@controller.send(:authorize_action)}.to raise_error(YamledAcl::AccessDenied)
|
86
86
|
end
|
87
87
|
|
88
|
-
end # #
|
88
|
+
end # #authorize_action
|
89
89
|
|
90
90
|
end # when trying to perform action without granted access
|
91
91
|
|
data/spec/yamled_acl_spec.rb
CHANGED
@@ -30,7 +30,7 @@ describe YamledAcl do
|
|
30
30
|
context "when setup invoked before" do
|
31
31
|
before(:all) do
|
32
32
|
YamledAcl.setup do |config|
|
33
|
-
config.files_with_permissions_path = File.expand_path('../
|
33
|
+
config.files_with_permissions_path = File.expand_path('../fixtures', __FILE__)
|
34
34
|
config.reload_permissions_on_each_request = true
|
35
35
|
config.groups = %w(admin member guest)
|
36
36
|
end
|
data/yamled_acl.gemspec
CHANGED
@@ -11,10 +11,10 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://github.com/pkubicki/yamled_acl"
|
12
12
|
s.summary = "Simple authorization library for Ruby on Rails."
|
13
13
|
s.description = "Simple authorization library for Ruby on Rails in which permissions are stored in YAML files."
|
14
|
+
s.licenses = ["MIT"]
|
14
15
|
|
15
|
-
s.add_development_dependency "rspec", "~> 2.
|
16
|
+
s.add_development_dependency "rspec", "~> 2.13"
|
16
17
|
s.add_development_dependency "actionpack", "~> 3.0"
|
17
|
-
s.add_development_dependency "rcov", "~> 0.9"
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
20
20
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
metadata
CHANGED
@@ -1,78 +1,51 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamled_acl
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
6
|
+
authors:
|
7
|
+
- Paweł Kubicki
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: rspec
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
27
17
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
version: "2.0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.13'
|
34
20
|
type: :development
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: actionpack
|
38
21
|
prerelease: false
|
39
|
-
|
40
|
-
|
41
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
42
24
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
49
34
|
type: :development
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: rcov
|
53
35
|
prerelease: false
|
54
|
-
|
55
|
-
|
56
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
57
38
|
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
version: "0.9"
|
64
|
-
type: :development
|
65
|
-
version_requirements: *id003
|
66
|
-
description: Simple authorization library for Ruby on Rails in which permissions are stored in YAML files.
|
67
|
-
email:
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
description: Simple authorization library for Ruby on Rails in which permissions are
|
42
|
+
stored in YAML files.
|
43
|
+
email:
|
68
44
|
- pawel.kubicki@gmail.com
|
69
45
|
executables: []
|
70
|
-
|
71
46
|
extensions: []
|
72
|
-
|
73
47
|
extra_rdoc_files: []
|
74
|
-
|
75
|
-
files:
|
48
|
+
files:
|
76
49
|
- .gitignore
|
77
50
|
- .rspec
|
78
51
|
- Gemfile
|
@@ -85,51 +58,39 @@ files:
|
|
85
58
|
- lib/yamled_acl/controller_extension.rb
|
86
59
|
- lib/yamled_acl/exceptions.rb
|
87
60
|
- lib/yamled_acl/version.rb
|
88
|
-
- spec/
|
89
|
-
- spec/
|
90
|
-
- spec/plik
|
61
|
+
- spec/fixtures/example_permissions.yml
|
62
|
+
- spec/fixtures/example_permissions_2.yml
|
91
63
|
- spec/spec_helper.rb
|
92
64
|
- spec/yamled_acl/controller_extension_spec.rb
|
93
65
|
- spec/yamled_acl_spec.rb
|
94
66
|
- yamled_acl.gemspec
|
95
|
-
has_rdoc: true
|
96
67
|
homepage: http://github.com/pkubicki/yamled_acl
|
97
|
-
licenses:
|
98
|
-
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
99
71
|
post_install_message:
|
100
72
|
rdoc_options: []
|
101
|
-
|
102
|
-
require_paths:
|
73
|
+
require_paths:
|
103
74
|
- lib
|
104
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
none: false
|
115
|
-
requirements:
|
116
|
-
- - ">="
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
hash: 3
|
119
|
-
segments:
|
120
|
-
- 0
|
121
|
-
version: "0"
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
122
85
|
requirements: []
|
123
|
-
|
124
86
|
rubyforge_project:
|
125
|
-
rubygems_version:
|
87
|
+
rubygems_version: 2.0.2
|
126
88
|
signing_key:
|
127
|
-
specification_version:
|
89
|
+
specification_version: 4
|
128
90
|
summary: Simple authorization library for Ruby on Rails.
|
129
|
-
test_files:
|
130
|
-
- spec/
|
131
|
-
- spec/
|
132
|
-
- spec/plik
|
91
|
+
test_files:
|
92
|
+
- spec/fixtures/example_permissions.yml
|
93
|
+
- spec/fixtures/example_permissions_2.yml
|
133
94
|
- spec/spec_helper.rb
|
134
95
|
- spec/yamled_acl/controller_extension_spec.rb
|
135
96
|
- spec/yamled_acl_spec.rb
|
data/spec/plik
DELETED
File without changes
|