bowtie-io 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bowtie/middleware/policy_check.rb +22 -3
- data/lib/bowtie/middleware/session.rb +7 -0
- data/lib/bowtie/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfd49decb782a0ac013cf5e3a1caa6e830213b56
|
4
|
+
data.tar.gz: e8c54559048fc551dc6565e79760ec25397040c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f5e8d98c4e108e8992d0b4d5570aac8f4963bd8f190a7c68e601bea6553b34b15eeaae3a2cf328eeaa582622b0276d2583d8d7eb8a00ee2bc0cefe72e0b67b7
|
7
|
+
data.tar.gz: 8091b463eedab36f9c01dc5167f6a48f19fa4c540d0dbb81c901b3296c3adf239f2b7ac8e936bf63da46522b43f49eb9c776ae859f2e6ef06efb5955a200b863
|
@@ -48,6 +48,7 @@ module Bowtie::Middleware
|
|
48
48
|
CONFIG_PLANS_KEY = 'plans'
|
49
49
|
CONFIG_PATH_KEY = 'path'
|
50
50
|
CONFIG_PROFILE_KEY = 'profile'
|
51
|
+
CONFIG_STATUS_KEY = 'status'
|
51
52
|
|
52
53
|
def branch; 'development' end
|
53
54
|
|
@@ -102,6 +103,7 @@ module Bowtie::Middleware
|
|
102
103
|
methods = methods_from_permitted_section_config(config)
|
103
104
|
plans = plans_from_permitted_section_config(config)
|
104
105
|
profile_restrictions = profile_restrictions_from_permitted_section_config(config)
|
106
|
+
status = status_from_permitted_section_config(config)
|
105
107
|
|
106
108
|
records = []
|
107
109
|
|
@@ -112,7 +114,8 @@ module Bowtie::Middleware
|
|
112
114
|
method,
|
113
115
|
plan,
|
114
116
|
policy_path.length,
|
115
|
-
profile_restrictions
|
117
|
+
profile_restrictions,
|
118
|
+
status)
|
116
119
|
end
|
117
120
|
end
|
118
121
|
|
@@ -153,6 +156,15 @@ module Bowtie::Middleware
|
|
153
156
|
_profile_restrictions_config = config[CONFIG_PROFILE_KEY]
|
154
157
|
end
|
155
158
|
|
159
|
+
def status_from_permitted_section_config(config)
|
160
|
+
status_config = config[CONFIG_STATUS_KEY]
|
161
|
+
|
162
|
+
if status_config.nil? || status_config == '*'
|
163
|
+
nil
|
164
|
+
else
|
165
|
+
status_config
|
166
|
+
end
|
167
|
+
end
|
156
168
|
end
|
157
169
|
|
158
170
|
Policy = Struct.new(:branch,
|
@@ -160,7 +172,8 @@ module Bowtie::Middleware
|
|
160
172
|
:request_method,
|
161
173
|
:plan,
|
162
174
|
:weight,
|
163
|
-
:profile_restrictions
|
175
|
+
:profile_restrictions,
|
176
|
+
:status) do
|
164
177
|
class << self
|
165
178
|
attr_reader :all
|
166
179
|
|
@@ -196,7 +209,8 @@ module Bowtie::Middleware
|
|
196
209
|
def permits?(rack_request)
|
197
210
|
request_method_permitted?(rack_request) &&
|
198
211
|
plan_permitted?(rack_request) &&
|
199
|
-
profile_permitted?(rack_request)
|
212
|
+
profile_permitted?(rack_request) &&
|
213
|
+
status_permitted?(rack_request)
|
200
214
|
end
|
201
215
|
|
202
216
|
private
|
@@ -233,6 +247,11 @@ module Bowtie::Middleware
|
|
233
247
|
end
|
234
248
|
end
|
235
249
|
|
250
|
+
def status_permitted?(rack_request)
|
251
|
+
status.nil? ||
|
252
|
+
(rack_request.env['rack.session']['user']['status'] rescue nil) == status
|
253
|
+
end
|
254
|
+
|
236
255
|
def user_profile(rack_request, scope)
|
237
256
|
user_id = rack_request.env['rack.session']['user']['id'] rescue nil
|
238
257
|
return nil if user_id.nil?
|
@@ -8,6 +8,13 @@ module Bowtie::Middleware
|
|
8
8
|
status, headers, response = @app.call(env)
|
9
9
|
|
10
10
|
if headers['X-Bowtie-Client-Session']
|
11
|
+
rr = Rack::Request.new(env)
|
12
|
+
|
13
|
+
open "/Users/james/Documents/src/bowtie-lite/tmp.txt", "a" do |f|
|
14
|
+
f << "Path: #{rr.path} / Headers: #{headers.inspect}\n"
|
15
|
+
end
|
16
|
+
|
17
|
+
|
11
18
|
env['rack.session']['user'] = JSON.parse(headers['X-Bowtie-Client-Session'])
|
12
19
|
end
|
13
20
|
|
data/lib/bowtie/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bowtie-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Kassemi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|