role_based_authorization 0.2.0 → 0.2.1
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.
- data/.gitignore +4 -0
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/role_based_authorization/role_based_authorization.rb +2 -3
- data/role_based_authorization.gemspec +33 -25
- data/test/role_based_authorization_test.rb +16 -0
- data/test/test_helper.rb +8 -0
- metadata +27 -15
data/.gitignore
ADDED
data/Rakefile
CHANGED
@@ -34,8 +34,8 @@ begin
|
|
34
34
|
gemspec.email = "boborbt@gmail.com"
|
35
35
|
gemspec.homepage = "http://github.com/boborbt/role_based_authorization"
|
36
36
|
gemspec.authors = ["Roberto Esposito"]
|
37
|
-
gemspec.add_dependency('rails', '
|
38
|
-
gemspec.add_dependency('mocha')
|
37
|
+
gemspec.add_dependency('rails', '~> 2.3')
|
38
|
+
gemspec.add_dependency('mocha', '~> 0')
|
39
39
|
end
|
40
40
|
rescue LoadError
|
41
41
|
puts "Jeweler not available. Install it with: gem install jeweler"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
@@ -1,8 +1,7 @@
|
|
1
|
-
|
2
1
|
module RoleBasedAuthorization
|
3
2
|
# AuthorizationLogger instance that is used throughout the plugin for logging
|
4
3
|
# events.
|
5
|
-
AUTHORIZATION_LOGGER = AuthorizationLogger.new(File.join(Rails.root,'log','authorization.log'))
|
4
|
+
AUTHORIZATION_LOGGER = AuthorizationLogger.new(File.join(Rails.root || '.','log','authorization.log'))
|
6
5
|
|
7
6
|
# Fires when the module is included into the controllers. It adds all class methods
|
8
7
|
# defined in the ClassAdditions sub-module and the authorize_action? and if_authorized?
|
@@ -36,7 +35,7 @@ module RoleBasedAuthorization
|
|
36
35
|
def RoleBasedAuthorization.path_or_options_to_options(opts)
|
37
36
|
path_cleanup_regexp = %r{(#{ActionController::Base.relative_url_root})?}
|
38
37
|
|
39
|
-
url_options = (opts.class
|
38
|
+
url_options = (opts.class <= String) && ActionController::Routing::Routes.recognize_path(opts.gsub(path_cleanup_regexp,''))
|
40
39
|
url_options ||= opts.dup
|
41
40
|
|
42
41
|
url_options
|
@@ -1,54 +1,62 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{role_based_authorization}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Roberto Esposito"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2012-08-01}
|
13
13
|
s.description = %q{Provides a simple DSL for specifying the authorization logic of your application. Install the gem, add a role attribute to your user model and your almost ready to go.}
|
14
14
|
s.email = %q{boborbt@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
19
|
+
".gitignore",
|
20
|
+
"MIT-LICENSE",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/role_based_authorization.rb",
|
25
|
+
"lib/role_based_authorization/authorization_logger.rb",
|
26
|
+
"lib/role_based_authorization/class_additions.rb",
|
27
|
+
"lib/role_based_authorization/role_based_authorization.rb",
|
28
|
+
"lib/role_based_authorization/rule.rb",
|
29
|
+
"rails/init.rb",
|
30
|
+
"role_based_authorization.gemspec",
|
31
|
+
"test/authorization_logger_test.rb",
|
32
|
+
"test/role_based_authorization_test.rb",
|
33
|
+
"test/test_helper.rb"
|
33
34
|
]
|
34
35
|
s.homepage = %q{http://github.com/boborbt/role_based_authorization}
|
36
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
37
|
s.require_paths = ["lib"]
|
36
|
-
s.rubygems_version = %q{1.
|
38
|
+
s.rubygems_version = %q{1.3.6}
|
37
39
|
s.summary = %q{Basic authorization module for rails}
|
40
|
+
s.test_files = [
|
41
|
+
"test/authorization_logger_test.rb",
|
42
|
+
"test/role_based_authorization_test.rb",
|
43
|
+
"test/test_helper.rb"
|
44
|
+
]
|
38
45
|
|
39
46
|
if s.respond_to? :specification_version then
|
47
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
48
|
s.specification_version = 3
|
41
49
|
|
42
|
-
if Gem::Version.new(Gem::
|
43
|
-
s.add_runtime_dependency(%q<rails>, ["
|
44
|
-
s.add_runtime_dependency(%q<mocha>, ["
|
50
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_runtime_dependency(%q<rails>, ["~> 2.3"])
|
52
|
+
s.add_runtime_dependency(%q<mocha>, ["~> 0"])
|
45
53
|
else
|
46
|
-
s.add_dependency(%q<rails>, ["
|
47
|
-
s.add_dependency(%q<mocha>, ["
|
54
|
+
s.add_dependency(%q<rails>, ["~> 2.3"])
|
55
|
+
s.add_dependency(%q<mocha>, ["~> 0"])
|
48
56
|
end
|
49
57
|
else
|
50
|
-
s.add_dependency(%q<rails>, ["
|
51
|
-
s.add_dependency(%q<mocha>, ["
|
58
|
+
s.add_dependency(%q<rails>, ["~> 2.3"])
|
59
|
+
s.add_dependency(%q<mocha>, ["~> 0"])
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
@@ -120,6 +120,22 @@ class RoleBasedAuthorizationTest < ActiveSupport::TestCase
|
|
120
120
|
assert got_inside
|
121
121
|
end
|
122
122
|
|
123
|
+
test "helper_method should work with String subclasses" do
|
124
|
+
class MySubstring < String
|
125
|
+
def new_meth
|
126
|
+
0
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
got_inside = false
|
131
|
+
@controller.if_authorized?( MySubstring.new('/dummy/very_low_security') ) do
|
132
|
+
got_inside = true
|
133
|
+
end
|
134
|
+
|
135
|
+
assert got_inside
|
136
|
+
end
|
137
|
+
|
138
|
+
|
123
139
|
test "helper_method should work with resource paths even when prefixed with the ActionController::Base.relative_url_root" do
|
124
140
|
ActionController::Base.relative_url_root = '/appname'
|
125
141
|
|
data/test/test_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
gem 'rails', '~>2.3.14'
|
2
3
|
require 'active_support'
|
3
4
|
require 'action_controller'
|
4
5
|
require 'active_support/test_case'
|
@@ -8,6 +9,13 @@ RAILS_ROOT='.'
|
|
8
9
|
AUTH_LOG_DIR = File.join(RAILS_ROOT,'log')
|
9
10
|
Dir.mkdir(AUTH_LOG_DIR) unless File.directory?(AUTH_LOG_DIR)
|
10
11
|
|
12
|
+
|
13
|
+
module Rails
|
14
|
+
def Rails.root
|
15
|
+
'.'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
11
19
|
ActionController::Routing::Routes.draw do |map|
|
12
20
|
map.dummy_low_action '/dummy/very_low_security', :controller => :dummy, :action => :very_low_security
|
13
21
|
end
|
metadata
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: role_based_authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
6
10
|
platform: ruby
|
7
11
|
authors:
|
8
12
|
- Roberto Esposito
|
@@ -10,28 +14,31 @@ autorequire:
|
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
16
|
|
13
|
-
date:
|
17
|
+
date: 2012-08-01 00:00:00 +02:00
|
14
18
|
default_executable:
|
15
19
|
dependencies:
|
16
20
|
- !ruby/object:Gem::Dependency
|
17
21
|
name: rails
|
18
22
|
prerelease: false
|
19
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
24
|
requirements:
|
22
|
-
- -
|
25
|
+
- - ~>
|
23
26
|
- !ruby/object:Gem::Version
|
24
|
-
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 3
|
30
|
+
version: "2.3"
|
25
31
|
type: :runtime
|
26
32
|
version_requirements: *id001
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: mocha
|
29
35
|
prerelease: false
|
30
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
-
none: false
|
32
37
|
requirements:
|
33
|
-
- -
|
38
|
+
- - ~>
|
34
39
|
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
35
42
|
version: "0"
|
36
43
|
type: :runtime
|
37
44
|
version_requirements: *id002
|
@@ -44,6 +51,7 @@ extensions: []
|
|
44
51
|
extra_rdoc_files:
|
45
52
|
- README.rdoc
|
46
53
|
files:
|
54
|
+
- .gitignore
|
47
55
|
- MIT-LICENSE
|
48
56
|
- README.rdoc
|
49
57
|
- Rakefile
|
@@ -63,28 +71,32 @@ homepage: http://github.com/boborbt/role_based_authorization
|
|
63
71
|
licenses: []
|
64
72
|
|
65
73
|
post_install_message:
|
66
|
-
rdoc_options:
|
67
|
-
|
74
|
+
rdoc_options:
|
75
|
+
- --charset=UTF-8
|
68
76
|
require_paths:
|
69
77
|
- lib
|
70
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
79
|
requirements:
|
73
80
|
- - ">="
|
74
81
|
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
75
84
|
version: "0"
|
76
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
86
|
requirements:
|
79
87
|
- - ">="
|
80
88
|
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
81
91
|
version: "0"
|
82
92
|
requirements: []
|
83
93
|
|
84
94
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.
|
95
|
+
rubygems_version: 1.3.6
|
86
96
|
signing_key:
|
87
97
|
specification_version: 3
|
88
98
|
summary: Basic authorization module for rails
|
89
|
-
test_files:
|
90
|
-
|
99
|
+
test_files:
|
100
|
+
- test/authorization_logger_test.rb
|
101
|
+
- test/role_based_authorization_test.rb
|
102
|
+
- test/test_helper.rb
|