simple-authorisation 0.0.11 → 0.0.12
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/Gemfile.lock
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
simple-authorisation (0.0.
|
|
4
|
+
simple-authorisation (0.0.12)
|
|
5
|
+
builder (~> 2.0)
|
|
5
6
|
sinatra (~> 1.2.6)
|
|
6
7
|
|
|
7
8
|
GEM
|
|
8
9
|
remote: http://rubygems.org/
|
|
9
10
|
specs:
|
|
11
|
+
builder (2.1.2)
|
|
10
12
|
diff-lcs (1.1.2)
|
|
11
13
|
rack (1.3.2)
|
|
12
14
|
rack-test (0.6.0)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'builder'
|
|
2
|
+
|
|
3
|
+
module Simple
|
|
4
|
+
module AuthorisationHelper
|
|
5
|
+
def link (route, link_options)
|
|
6
|
+
user = send(options.authorisation_current_user)
|
|
7
|
+
link = Builder::XmlMarkup.new
|
|
8
|
+
|
|
9
|
+
if Simple::Authorisation.is_allowed?(route, :user => user,
|
|
10
|
+
:anonymous_user_class => options.authorisation_anonymous_user_class,
|
|
11
|
+
:method => :get)
|
|
12
|
+
main_link = lambda { link.a(:href => route) { |a| a << link_options[:text] }}
|
|
13
|
+
if link_options[:nest]
|
|
14
|
+
link.li {main_link.call}
|
|
15
|
+
else
|
|
16
|
+
main_link.call
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
link.target!
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'simple-authorisation'
|
|
6
|
-
s.version = '0.0.
|
|
6
|
+
s.version = '0.0.12'
|
|
7
7
|
s.authors = ["Derek Ekins"]
|
|
8
8
|
s.description = 'Handles authorisation only'
|
|
9
9
|
s.summary = "simple-authorisation-#{s.version}"
|
|
@@ -21,6 +21,7 @@ Thank you for installing simple-authorisation
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
s.add_dependency 'sinatra', '~> 1.2.6'
|
|
24
|
+
s.add_dependency 'builder', '~> 2.0'
|
|
24
25
|
|
|
25
26
|
s.add_development_dependency 'rake', '>= 0.9.2'
|
|
26
27
|
s.add_development_dependency 'rspec', '>= 2.6.0'
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require 'simple-authorisation/authorisation'
|
|
2
|
+
require 'simple-authorisation/authorisation_helper'
|
|
3
|
+
|
|
4
|
+
module Simple
|
|
5
|
+
describe AuthorisationHelper do
|
|
6
|
+
before do
|
|
7
|
+
Simple::Authorisation.clear
|
|
8
|
+
@helper = Object.new
|
|
9
|
+
@helper.extend Simple::AuthorisationHelper
|
|
10
|
+
|
|
11
|
+
def @helper.options
|
|
12
|
+
options = Object.new
|
|
13
|
+
def options.authorisation_anonymous_user_class
|
|
14
|
+
NilClass
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def options.authorisation_current_user
|
|
18
|
+
:current_user
|
|
19
|
+
end
|
|
20
|
+
options
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'returns a link if you have permission to view it' do
|
|
25
|
+
def @helper.current_user
|
|
26
|
+
Object.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Simple::Authorisation.get '/', :allow => ['*']
|
|
30
|
+
|
|
31
|
+
@helper.link('/', :text => 'Home').should == '<a href="/">Home</a>'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
it 'returns a nested link if you have permission to view it' do
|
|
36
|
+
def @helper.current_user
|
|
37
|
+
Object.new
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
Simple::Authorisation.get '/', :allow => ['*']
|
|
41
|
+
|
|
42
|
+
@helper.link('/', :text => 'Home', :nest => true).should == '<li><a href="/">Home</a></li>'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it "does not return a link if you do not have permission to view it" do
|
|
46
|
+
def @helper.current_user
|
|
47
|
+
nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Simple::Authorisation.get '/', :deny => ['?']
|
|
51
|
+
|
|
52
|
+
@helper.link('/', :text => 'Home').should == ''
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple-authorisation
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.12
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2011-09-
|
|
12
|
+
date: 2011-09-18 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: sinatra
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &16767200 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
@@ -21,10 +21,21 @@ dependencies:
|
|
|
21
21
|
version: 1.2.6
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *16767200
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: builder
|
|
27
|
+
requirement: &16766600 !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ~>
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: *16766600
|
|
25
36
|
- !ruby/object:Gem::Dependency
|
|
26
37
|
name: rake
|
|
27
|
-
requirement: &
|
|
38
|
+
requirement: &16766040 !ruby/object:Gem::Requirement
|
|
28
39
|
none: false
|
|
29
40
|
requirements:
|
|
30
41
|
- - ! '>='
|
|
@@ -32,10 +43,10 @@ dependencies:
|
|
|
32
43
|
version: 0.9.2
|
|
33
44
|
type: :development
|
|
34
45
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
46
|
+
version_requirements: *16766040
|
|
36
47
|
- !ruby/object:Gem::Dependency
|
|
37
48
|
name: rspec
|
|
38
|
-
requirement: &
|
|
49
|
+
requirement: &16765440 !ruby/object:Gem::Requirement
|
|
39
50
|
none: false
|
|
40
51
|
requirements:
|
|
41
52
|
- - ! '>='
|
|
@@ -43,10 +54,10 @@ dependencies:
|
|
|
43
54
|
version: 2.6.0
|
|
44
55
|
type: :development
|
|
45
56
|
prerelease: false
|
|
46
|
-
version_requirements: *
|
|
57
|
+
version_requirements: *16765440
|
|
47
58
|
- !ruby/object:Gem::Dependency
|
|
48
59
|
name: sinatra
|
|
49
|
-
requirement: &
|
|
60
|
+
requirement: &16764860 !ruby/object:Gem::Requirement
|
|
50
61
|
none: false
|
|
51
62
|
requirements:
|
|
52
63
|
- - ! '>='
|
|
@@ -54,10 +65,10 @@ dependencies:
|
|
|
54
65
|
version: 1.2.6
|
|
55
66
|
type: :development
|
|
56
67
|
prerelease: false
|
|
57
|
-
version_requirements: *
|
|
68
|
+
version_requirements: *16764860
|
|
58
69
|
- !ruby/object:Gem::Dependency
|
|
59
70
|
name: rack-test
|
|
60
|
-
requirement: &
|
|
71
|
+
requirement: &16764260 !ruby/object:Gem::Requirement
|
|
61
72
|
none: false
|
|
62
73
|
requirements:
|
|
63
74
|
- - ! '>='
|
|
@@ -65,7 +76,7 @@ dependencies:
|
|
|
65
76
|
version: 0.6.0
|
|
66
77
|
type: :development
|
|
67
78
|
prerelease: false
|
|
68
|
-
version_requirements: *
|
|
79
|
+
version_requirements: *16764260
|
|
69
80
|
description: Handles authorisation only
|
|
70
81
|
email: derek@spathi.com
|
|
71
82
|
executables: []
|
|
@@ -78,12 +89,14 @@ files:
|
|
|
78
89
|
- Rakefile
|
|
79
90
|
- lib/simple-authorisation.rb
|
|
80
91
|
- lib/simple-authorisation/authorisation.rb
|
|
92
|
+
- lib/simple-authorisation/authorisation_helper.rb
|
|
81
93
|
- lib/simple-authorisation/exact_route_rule_finder.rb
|
|
82
94
|
- lib/simple-authorisation/no_rules_for_method.rb
|
|
83
95
|
- lib/simple-authorisation/no_setting_for_route.rb
|
|
84
96
|
- lib/simple-authorisation/route_rule_finder.rb
|
|
85
97
|
- lib/simple-authorisation/sinatra.rb
|
|
86
98
|
- simple-authorisation.gemspec
|
|
99
|
+
- spec/simple-authorisation/authorisation_helper_spec.rb
|
|
87
100
|
- spec/simple-authorisation/authorisation_spec.rb
|
|
88
101
|
- spec/simple-authorisation/sinatra_integration_spec.rb
|
|
89
102
|
- spec/spec_helper.rb
|
|
@@ -121,8 +134,9 @@ rubyforge_project:
|
|
|
121
134
|
rubygems_version: 1.8.6
|
|
122
135
|
signing_key:
|
|
123
136
|
specification_version: 3
|
|
124
|
-
summary: simple-authorisation-0.0.
|
|
137
|
+
summary: simple-authorisation-0.0.12
|
|
125
138
|
test_files:
|
|
139
|
+
- spec/simple-authorisation/authorisation_helper_spec.rb
|
|
126
140
|
- spec/simple-authorisation/authorisation_spec.rb
|
|
127
141
|
- spec/simple-authorisation/sinatra_integration_spec.rb
|
|
128
142
|
- spec/spec_helper.rb
|