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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b213ebcf6f507b5c7ecd8b92bc4ea8c5d38a9f1f
4
- data.tar.gz: 951d7a6c199366cabbc88d386f7e05adcfbb3fe7
3
+ metadata.gz: 370b07c7c8bfe5c6caf037448b53bb00a0e5c918
4
+ data.tar.gz: 5f0718164645d022edf1e7ef63f87221e3e3d516
5
5
  SHA512:
6
- metadata.gz: 2022526d04a845e57d9d8837ed3105ae31c17d7e5fbab4ac2a5cc154c6c733f82c174ad958fae1beed1b4e38f36a5bac16f889f687b391cbd000301f1e99ad2f
7
- data.tar.gz: 43307e566b241328de13db9a69d07cdd3ae1ce697d25ab18c4cc884941772d82d1d4cdb44a25c7f6930e838cf8741ecd2d61fbe9fff099891446004acfe27130
6
+ metadata.gz: 74611f1024e751f9bb487be398e64b336f2923396324da44876431ae66fa321155ae11830323d8af546695ca2c74ae143292666cd8356b84544116e198c3ce34
7
+ data.tar.gz: a114ec44df9ad2dfa0e0497c24e505caad714bf435c43b7d554bca3012d1883eb81d07af50132bc86d37ab8459726439bd79dafb7a2cac77df5717c7118a3025
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  coverage
2
2
  Gemfile.lock
3
3
  *swp
4
+ *gem
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,3 +1,3 @@
1
1
  module Smaak
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
@@ -0,0 +1,7 @@
1
+ class Request
2
+ attr_accessor :env
3
+
4
+ def initialize(env)
5
+ @env = env
6
+ end
7
+ 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.1
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