orthrus-ssh 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/orthrus/ssh.rb +1 -1
- data/lib/orthrus/ssh/rack_app.rb +8 -6
- data/test/sessions.rb +1 -1
- data/test/test_orthrus_ssh_rackapp.rb +6 -2
- metadata +3 -3
data/lib/orthrus/ssh.rb
CHANGED
data/lib/orthrus/ssh/rack_app.rb
CHANGED
@@ -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
|
37
|
+
return form :code => "unknown"
|
38
38
|
end
|
39
39
|
|
40
40
|
session, nonce = @sessions.new_session(user, pub)
|
41
41
|
|
42
|
-
nonce =
|
42
|
+
nonce = Utils.sha1_hash(nonce)
|
43
43
|
|
44
|
-
form
|
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
|
58
|
+
form :code => 'verified', :access_token => token
|
57
59
|
else
|
58
|
-
form "
|
60
|
+
form :code => "fail"
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
data/test/sessions.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 1
|
10
|
+
version: 0.6.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Evan Phoenix
|