perf_check 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/perf_check/server.rb +23 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8364ffc19692621c05b33890106f93f7def8f61a
|
4
|
+
data.tar.gz: d5c7127cf7a61c842c95140984c0eabb6217da0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1792332330ace057e55cfdf97e178bf10275d2c855b782814e21a8d8eb3f634dfdbde0d2e1295196c157f5d036c67cc8ede4ca89e9a85b0999bb4954ea7a3642
|
7
|
+
data.tar.gz: 4ffdc73593a60a3085a87b28e2003b72a398b8104e87af6fc504f372ab04a5053df508d5b91aebd6952be5a78bfd72fabe9219c019c5d55108b2075214a813ce
|
data/lib/perf_check/server.rb
CHANGED
@@ -10,6 +10,29 @@ class PerfCheck
|
|
10
10
|
define_method(:login, &block)
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.authorization_action(method, login_route, &block)
|
14
|
+
Rails.application.reload_routes!
|
15
|
+
p = Rails.application.routes.recognize_path(login_route, :method => method)
|
16
|
+
controller = "#{p[:controller]}_controller".classify.constantize
|
17
|
+
action = p[:action]
|
18
|
+
|
19
|
+
controller.send(:define_method, :get_perf_check_session, &block)
|
20
|
+
controller.send(:define_method, action) do
|
21
|
+
get_perf_check_session(params[:login], params[:route])
|
22
|
+
render :nothing => true
|
23
|
+
end
|
24
|
+
|
25
|
+
authorization do |login, route|
|
26
|
+
http = Net::HTTP.new(host, port)
|
27
|
+
if method == :post
|
28
|
+
response = http.post(login_route, "login=#{login}")
|
29
|
+
elsif method == :get
|
30
|
+
response = http.get(login_route+"?login=#{login}")
|
31
|
+
end
|
32
|
+
response['Set-Cookie']
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
13
36
|
def self.sign_cookie_data(key, data, opts={})
|
14
37
|
opts[:serializer] ||= Marshal
|
15
38
|
secret = Rails.application.config.secret_token
|