smaak 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/smaak/server.rb +13 -0
- data/lib/smaak/version.rb +1 -1
- data/spec/lib/smaak/server_spec.rb +4 -0
- data/spec/mock/request.rb +7 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 370b07c7c8bfe5c6caf037448b53bb00a0e5c918
|
4
|
+
data.tar.gz: 5f0718164645d022edf1e7ef63f87221e3e3d516
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74611f1024e751f9bb487be398e64b336f2923396324da44876431ae66fa321155ae11830323d8af546695ca2c74ae143292666cd8356b84544116e198c3ce34
|
7
|
+
data.tar.gz: a114ec44df9ad2dfa0e0497c24e505caad714bf435c43b7d554bca3012d1883eb81d07af50132bc86d37ab8459726439bd79dafb7a2cac77df5717c7118a3025
|
data/.gitignore
CHANGED
data/lib/smaak/server.rb
CHANGED
@@ -22,6 +22,19 @@ module Smaak
|
|
22
22
|
false
|
23
23
|
end
|
24
24
|
|
25
|
+
def get_signed_auth_message_from_request(request)
|
26
|
+
authorization = request.env['HTTP_AUTHORIZATION']
|
27
|
+
auth_body = JSON.parse(authorization)
|
28
|
+
message = auth_body['message']
|
29
|
+
signature = auth_body['signature']
|
30
|
+
return message, Base64.decode64(signature)
|
31
|
+
end
|
32
|
+
|
33
|
+
def verify_signed_request(request)
|
34
|
+
auth_message, signature = get_signed_auth_message_from_request(request)
|
35
|
+
verify_auth_message(auth_message, signature)
|
36
|
+
end
|
37
|
+
|
25
38
|
def verify_auth_message(auth_message, signature)
|
26
39
|
return false if not auth_message_unique?(auth_message)
|
27
40
|
identity = auth_message.identity
|
data/lib/smaak/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require './spec/spec_helper.rb'
|
2
2
|
require 'smaak'
|
3
|
+
require 'mock/request.rb'
|
3
4
|
|
4
5
|
describe Smaak::Server do
|
5
6
|
before :all do
|
@@ -88,4 +89,7 @@ describe Smaak::Server do
|
|
88
89
|
expect(@iut.verify_auth_message(@message, @signature)).to eq(false)
|
89
90
|
end
|
90
91
|
end
|
92
|
+
|
93
|
+
context "when asked to get the message and signature from a signed auth request" do
|
94
|
+
end
|
91
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smaak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernst van Graan
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- spec/lib/smaak/client_spec.rb
|
149
149
|
- spec/lib/smaak/server_spec.rb
|
150
150
|
- spec/lib/smaak_spec.rb
|
151
|
+
- spec/mock/request.rb
|
151
152
|
- spec/spec_helper.rb
|
152
153
|
homepage: ''
|
153
154
|
licenses:
|
@@ -183,4 +184,5 @@ test_files:
|
|
183
184
|
- spec/lib/smaak/client_spec.rb
|
184
185
|
- spec/lib/smaak/server_spec.rb
|
185
186
|
- spec/lib/smaak_spec.rb
|
187
|
+
- spec/mock/request.rb
|
186
188
|
- spec/spec_helper.rb
|