orthrus-ssh 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ require 'orthrus/ssh/dsa'
7
7
  require 'orthrus/ssh/utils'
8
8
 
9
9
  module Orthrus::SSH
10
- VERSION = '0.6.0'
10
+ VERSION = '0.6.1'
11
11
 
12
12
  def self.load_private(path)
13
13
  data = File.read(path)
@@ -25,7 +25,7 @@ module Orthrus::SSH
25
25
  def form(body)
26
26
  [200,
27
27
  { "Content-Type" => "application/x-www-form-urlencoded" },
28
- [body]
28
+ [Rack::Utils.build_query(body)]
29
29
  ]
30
30
  end
31
31
 
@@ -34,14 +34,14 @@ module Orthrus::SSH
34
34
  id = req.params["id"]
35
35
 
36
36
  unless pub = @sessions.find_key(user, id)
37
- return form("code=unknown")
37
+ return form :code => "unknown"
38
38
  end
39
39
 
40
40
  session, nonce = @sessions.new_session(user, pub)
41
41
 
42
- nonce = Rack::Utils.escape Utils.sha1_hash(nonce)
42
+ nonce = Utils.sha1_hash(nonce)
43
43
 
44
- form "code=check&session_id=#{session}&nonce=#{nonce}"
44
+ form :code => 'check', :session_id => session, :nonce => nonce
45
45
  end
46
46
 
47
47
  def verify(req)
@@ -52,10 +52,12 @@ module Orthrus::SSH
52
52
 
53
53
  sig = req.params['sig']
54
54
 
55
+ token = @sessions.new_access_token(id)
56
+
55
57
  if pub.verify(sig, nonce, true)
56
- form "code=verified&access_token=1"
58
+ form :code => 'verified', :access_token => token
57
59
  else
58
- form "code=fail"
60
+ form :code => "fail"
59
61
  end
60
62
  end
61
63
  end
@@ -21,7 +21,7 @@ class OrthrusTestSessions
21
21
  ["secret", @pub]
22
22
  end
23
23
 
24
- def access_token
24
+ def new_access_token(session_id)
25
25
  1
26
26
  end
27
27
  end
@@ -34,7 +34,8 @@ class TestOrthrusSSHRackApp < MiniTest::Unit::TestCase
34
34
  assert_equal "application/x-www-form-urlencoded",
35
35
  headers["Content-Type"]
36
36
 
37
- assert_equal "code=unknown", body[0]
37
+ params = Rack::Utils.parse_query body[0]
38
+ assert_equal "unknown", params['code']
38
39
  end
39
40
 
40
41
  def test_call_requests_signature
@@ -79,6 +80,9 @@ class TestOrthrusSSHRackApp < MiniTest::Unit::TestCase
79
80
 
80
81
  code, headers, body = @app.call(env)
81
82
 
82
- assert_equal ["code=verified&access_token=1"], body
83
+ params = Rack::Utils.parse_query body.first
84
+
85
+ assert_equal "verified", params['code']
86
+ assert_equal "1", params["access_token"]
83
87
  end
84
88
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orthrus-ssh
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 1
10
+ version: 0.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Evan Phoenix