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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39544527d815f0c0032864468dd6412ea1826501
4
- data.tar.gz: b79057a6d1e46b5f0a4b5c0a18777aefb34cfbb0
3
+ metadata.gz: cfd49decb782a0ac013cf5e3a1caa6e830213b56
4
+ data.tar.gz: e8c54559048fc551dc6565e79760ec25397040c8
5
5
  SHA512:
6
- metadata.gz: f294d9ec18aa3d6c05b71059fc66d61a07dbfd81e8e72b3ed2126b3e55b7f7fe30bea44e066a59c9e52f49ffe87ca9013e82aa520e28d63a8eef2de3f535f11e
7
- data.tar.gz: c5fbce85a957f05bc55f672ea76fe9d78b27604e6c1b1ba2f5173bced7b5ab3bd94e1e1d54f8ad12c8d7d4ac269aa4b97f073917610f617544ffb6ecf3b0334e
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) do
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
 
@@ -1,3 +1,3 @@
1
1
  module Bowtie
2
- VERSION = '1.0.12'
2
+ VERSION = '1.0.13'
3
3
  end
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.12
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 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll