pebblebed 0.0.42 → 0.0.43

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -49,13 +49,14 @@ This exception has the fields `status` and `message`.
49
49
  Other helper methods provided by this extension:
50
50
 
51
51
  part(partspec, params = {}) # Include a part from a kit (See https://github.com/benglerpebbles/kits)
52
- parts_script_include_tags # All script tags required by the kits
52
+ parts_script_include_tags # All script tags required by the kits
53
53
  parts_stylesheet_include_tags # All stylesheet-tags required by the kits
54
54
  current_session # The hash string that identifies the current browser session
55
55
  pebbles # Common entrypoint for the Pebblebed::Connector
56
56
  current_identity # Returns the a DeepStruct record with the vital data for the current user
57
57
  require_identity # Halts with 403 if there is no current user
58
58
  require_god # Halts with 403 if the current user is not a god
59
+ require_access_to_path(path) # Halts with 403 if the current user is not a member of a checkpoint access group with privileged access to that path
59
60
  require_parameters(parameters, *keys) # Halts with 409 if the at least one of the provided keys is not in the params-hash
60
61
 
61
62
  ### Testing Sinatra APIs
@@ -85,6 +85,14 @@ module Sinatra
85
85
  halt 409, "missing parameters: #{missing.join(', ')}" unless missing.empty?
86
86
  end
87
87
 
88
+ def require_access_to_path(path)
89
+ require_identity
90
+ return if current_identity.god and path.split(".")[0] == current_identity.realm
91
+ res = pebbles.checkpoint.get("/identities/#{current_identity.id}/access_to/#{path}")
92
+ return if res['access'] and res['access']['granted'] == true
93
+ halt 403, "Access denied."
94
+ end
95
+
88
96
  def limit_offset_collection(collection, options)
89
97
  limit = (options[:limit] || 20).to_i
90
98
  offset = (options[:offset] || 0).to_i
@@ -1,3 +1,3 @@
1
1
  module Pebblebed
2
- VERSION = "0.0.42"
2
+ VERSION = "0.0.43"
3
3
  end
@@ -24,6 +24,11 @@ class TestApp < Sinatra::Base
24
24
  "You are logged in"
25
25
  end
26
26
 
27
+ get '/group' do
28
+ require_access_to_path("testrealm.specialgroup.123")
29
+ "You are granted access to this content"
30
+ end
31
+
27
32
  get '/root' do
28
33
  require_god
29
34
  "You are most powerful"
@@ -107,6 +112,48 @@ describe Sinatra::Pebblebed do
107
112
  end
108
113
  end
109
114
 
115
+ describe "with access groups control" do
116
+ let(:checkpoint) {
117
+ checkpoint = stub
118
+ checkpoint.stub!(:service_url => 'http://example.com')
119
+ checkpoint
120
+ }
121
+ context "as a guest" do
122
+ specify "not allowed" do
123
+ guest!
124
+ get '/group'
125
+ last_response.status.should == 403
126
+ end
127
+ end
128
+ context "as a god" do
129
+ specify "allowed without policy check" do
130
+ god!(:session => random_session)
131
+ get '/group'
132
+ last_response.body.should == "You are granted access to this content"
133
+ end
134
+ end
135
+ context "as user without grants" do
136
+ specify "is disallowed" do
137
+ user!
138
+ checkpoint.should_receive(:get).with("/identities/me").and_return(DeepStruct.wrap(:identity => {:realm => 'testrealm', :id => 1, :god => false}))
139
+ checkpoint.should_receive(:get).with("/identities/1/access_to/testrealm.specialgroup.123").and_return(DeepStruct.wrap(:access => {:granted => false}))
140
+ Pebblebed::Connector.any_instance.stub(:checkpoint => checkpoint)
141
+ get '/group'
142
+ last_response.status.should == 403
143
+ end
144
+ end
145
+ context "as user with grants" do
146
+ specify "is allowed" do
147
+ user!
148
+ checkpoint.should_receive(:get).with("/identities/me").and_return(DeepStruct.wrap(:identity => {:realm => 'testrealm', :id => 1, :god => false}))
149
+ checkpoint.should_receive(:get).with("/identities/1/access_to/testrealm.specialgroup.123").and_return(DeepStruct.wrap(:access => {:granted => true}))
150
+ Pebblebed::Connector.any_instance.stub(:checkpoint => checkpoint)
151
+ get '/group'
152
+ last_response.body.should == "You are granted access to this content"
153
+ end
154
+ end
155
+ end
156
+
110
157
  describe "error handling" do
111
158
  before(:each) { guest! }
112
159
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pebblebed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.42
4
+ version: 0.0.43
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-25 00:00:00.000000000 Z
13
+ date: 2013-02-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &70269360765760 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,15 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70269360765760
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: rake
28
- requirement: &70269360765140 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
36
  - - ! '>='
@@ -33,10 +38,15 @@ dependencies:
33
38
  version: '0'
34
39
  type: :development
35
40
  prerelease: false
36
- version_requirements: *70269360765140
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: simplecov
39
- requirement: &70269360764520 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: '0'
45
55
  type: :development
46
56
  prerelease: false
47
- version_requirements: *70269360764520
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: sinatra
50
- requirement: &70269360763860 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0'
56
71
  type: :development
57
72
  prerelease: false
58
- version_requirements: *70269360763860
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: rack-test
61
- requirement: &70269360763420 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ! '>='
@@ -66,10 +86,15 @@ dependencies:
66
86
  version: '0'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *70269360763420
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: memcache_mock
72
- requirement: &70269360762920 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
73
98
  none: false
74
99
  requirements:
75
100
  - - ! '>='
@@ -77,10 +102,15 @@ dependencies:
77
102
  version: '0'
78
103
  type: :development
79
104
  prerelease: false
80
- version_requirements: *70269360762920
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
81
111
  - !ruby/object:Gem::Dependency
82
112
  name: deepstruct
83
- requirement: &70269360778520 !ruby/object:Gem::Requirement
113
+ requirement: !ruby/object:Gem::Requirement
84
114
  none: false
85
115
  requirements:
86
116
  - - ! '>='
@@ -88,10 +118,15 @@ dependencies:
88
118
  version: 0.0.4
89
119
  type: :runtime
90
120
  prerelease: false
91
- version_requirements: *70269360778520
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: 0.0.4
92
127
  - !ruby/object:Gem::Dependency
93
128
  name: curb
94
- requirement: &70269360777860 !ruby/object:Gem::Requirement
129
+ requirement: !ruby/object:Gem::Requirement
95
130
  none: false
96
131
  requirements:
97
132
  - - ! '>='
@@ -99,10 +134,15 @@ dependencies:
99
134
  version: 0.7.14
100
135
  type: :runtime
101
136
  prerelease: false
102
- version_requirements: *70269360777860
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: 0.7.14
103
143
  - !ruby/object:Gem::Dependency
104
144
  name: yajl-ruby
105
- requirement: &70269360777480 !ruby/object:Gem::Requirement
145
+ requirement: !ruby/object:Gem::Requirement
106
146
  none: false
107
147
  requirements:
108
148
  - - ! '>='
@@ -110,10 +150,15 @@ dependencies:
110
150
  version: '0'
111
151
  type: :runtime
112
152
  prerelease: false
113
- version_requirements: *70269360777480
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
114
159
  - !ruby/object:Gem::Dependency
115
160
  name: queryparams
116
- requirement: &70269360777020 !ruby/object:Gem::Requirement
161
+ requirement: !ruby/object:Gem::Requirement
117
162
  none: false
118
163
  requirements:
119
164
  - - ! '>='
@@ -121,10 +166,15 @@ dependencies:
121
166
  version: '0'
122
167
  type: :runtime
123
168
  prerelease: false
124
- version_requirements: *70269360777020
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
125
175
  - !ruby/object:Gem::Dependency
126
176
  name: futurevalue
127
- requirement: &70269360776580 !ruby/object:Gem::Requirement
177
+ requirement: !ruby/object:Gem::Requirement
128
178
  none: false
129
179
  requirements:
130
180
  - - ! '>='
@@ -132,10 +182,15 @@ dependencies:
132
182
  version: '0'
133
183
  type: :runtime
134
184
  prerelease: false
135
- version_requirements: *70269360776580
185
+ version_requirements: !ruby/object:Gem::Requirement
186
+ none: false
187
+ requirements:
188
+ - - ! '>='
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
136
191
  - !ruby/object:Gem::Dependency
137
192
  name: pathbuilder
138
- requirement: &70269360776120 !ruby/object:Gem::Requirement
193
+ requirement: !ruby/object:Gem::Requirement
139
194
  none: false
140
195
  requirements:
141
196
  - - ! '>='
@@ -143,10 +198,15 @@ dependencies:
143
198
  version: '0'
144
199
  type: :runtime
145
200
  prerelease: false
146
- version_requirements: *70269360776120
201
+ version_requirements: !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ! '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
147
207
  - !ruby/object:Gem::Dependency
148
208
  name: nokogiri
149
- requirement: &70269360775660 !ruby/object:Gem::Requirement
209
+ requirement: !ruby/object:Gem::Requirement
150
210
  none: false
151
211
  requirements:
152
212
  - - ! '>='
@@ -154,10 +214,15 @@ dependencies:
154
214
  version: '0'
155
215
  type: :runtime
156
216
  prerelease: false
157
- version_requirements: *70269360775660
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ none: false
219
+ requirements:
220
+ - - ! '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
158
223
  - !ruby/object:Gem::Dependency
159
224
  name: i18n
160
- requirement: &70269360775220 !ruby/object:Gem::Requirement
225
+ requirement: !ruby/object:Gem::Requirement
161
226
  none: false
162
227
  requirements:
163
228
  - - ! '>='
@@ -165,10 +230,15 @@ dependencies:
165
230
  version: '0'
166
231
  type: :runtime
167
232
  prerelease: false
168
- version_requirements: *70269360775220
233
+ version_requirements: !ruby/object:Gem::Requirement
234
+ none: false
235
+ requirements:
236
+ - - ! '>='
237
+ - !ruby/object:Gem::Version
238
+ version: '0'
169
239
  - !ruby/object:Gem::Dependency
170
240
  name: activesupport
171
- requirement: &70269360774760 !ruby/object:Gem::Requirement
241
+ requirement: !ruby/object:Gem::Requirement
172
242
  none: false
173
243
  requirements:
174
244
  - - ! '>='
@@ -176,10 +246,15 @@ dependencies:
176
246
  version: '0'
177
247
  type: :runtime
178
248
  prerelease: false
179
- version_requirements: *70269360774760
249
+ version_requirements: !ruby/object:Gem::Requirement
250
+ none: false
251
+ requirements:
252
+ - - ! '>='
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
180
255
  - !ruby/object:Gem::Dependency
181
256
  name: bunny
182
- requirement: &70269360774320 !ruby/object:Gem::Requirement
257
+ requirement: !ruby/object:Gem::Requirement
183
258
  none: false
184
259
  requirements:
185
260
  - - ! '>='
@@ -187,7 +262,12 @@ dependencies:
187
262
  version: '0'
188
263
  type: :runtime
189
264
  prerelease: false
190
- version_requirements: *70269360774320
265
+ version_requirements: !ruby/object:Gem::Requirement
266
+ none: false
267
+ requirements:
268
+ - - ! '>='
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
191
271
  description: Development tools for working with Pebblebed
192
272
  email:
193
273
  - katrina@bengler.no
@@ -247,15 +327,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
247
327
  - - ! '>='
248
328
  - !ruby/object:Gem::Version
249
329
  version: '0'
330
+ segments:
331
+ - 0
332
+ hash: -4488871030272884545
250
333
  required_rubygems_version: !ruby/object:Gem::Requirement
251
334
  none: false
252
335
  requirements:
253
336
  - - ! '>='
254
337
  - !ruby/object:Gem::Version
255
338
  version: '0'
339
+ segments:
340
+ - 0
341
+ hash: -4488871030272884545
256
342
  requirements: []
257
343
  rubyforge_project: pebblebed
258
- rubygems_version: 1.8.15
344
+ rubygems_version: 1.8.25
259
345
  signing_key:
260
346
  specification_version: 3
261
347
  summary: Development tools for working with Pebblebed
@@ -274,4 +360,3 @@ test_files:
274
360
  - spec/sinatra_spec.rb
275
361
  - spec/spec_helper.rb
276
362
  - spec/uid_spec.rb
277
- has_rdoc: