libgss 0.7.2 → 0.7.3
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/libgss/http_client_with_signature_key.rb +14 -6
- data/lib/libgss/network.rb +9 -0
- data/lib/libgss/version.rb +1 -1
- data/spec/libgss/network_spec.rb +41 -1
- data/spec/spec_helper.rb +12 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d53665633c09d8a6f5ca84777c9de59b69f26ca0
|
4
|
+
data.tar.gz: 099b87fa95d54caac1aadb658a9aed566073d185
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48963d4fe7b7a7f02629fa5a0a92cef7030f6c9ebd8651624b0efa7203aba63f798417f91cebe0003cde45a4d7a1537bf73a317593564ec82dfcb1ffda1047cb
|
7
|
+
data.tar.gz: cf7df2a141e586bf514a485cc1a2e135572067e1413ce86b1fcd6a1c1bd5dd32983ae3924cda5bc58fb1db87c7f81e6efac33a45007d9d6ee5b7f9c8d76676d8
|
data/Gemfile.lock
CHANGED
@@ -22,9 +22,13 @@ module Libgss
|
|
22
22
|
headers = {
|
23
23
|
"oauth_consumer_key" => network.consumer_key || "",
|
24
24
|
"oauth_token" => network.auth_token,
|
25
|
-
"oauth_nonce" => oauth_nonce,
|
26
|
-
"oauth_timestamp" => oauth_timestamp,
|
27
25
|
}
|
26
|
+
unless @network.ignore_oauth_nonce
|
27
|
+
headers.update({
|
28
|
+
"oauth_nonce" => oauth_nonce,
|
29
|
+
"oauth_timestamp" => oauth_timestamp,
|
30
|
+
})
|
31
|
+
end
|
28
32
|
oauth_params = {
|
29
33
|
"body" => body,
|
30
34
|
"oauth_signature_method" => "HMAC-SHA1"
|
@@ -56,9 +60,13 @@ module Libgss
|
|
56
60
|
headers = {
|
57
61
|
"oauth_consumer_key" => network.consumer_key || "",
|
58
62
|
"oauth_token" => network.auth_token,
|
59
|
-
"oauth_nonce" => oauth_nonce,
|
60
|
-
"oauth_timestamp" => oauth_timestamp,
|
61
63
|
}
|
64
|
+
unless @network.ignore_oauth_nonce
|
65
|
+
headers.update({
|
66
|
+
"oauth_nonce" => oauth_nonce,
|
67
|
+
"oauth_timestamp" => oauth_timestamp,
|
68
|
+
})
|
69
|
+
end
|
62
70
|
oauth_params = {
|
63
71
|
"body" => '',
|
64
72
|
"oauth_signature_method" => "HMAC-SHA1"
|
@@ -109,11 +117,11 @@ module Libgss
|
|
109
117
|
end
|
110
118
|
|
111
119
|
def oauth_nonce
|
112
|
-
SecureRandom.uuid.to_s
|
120
|
+
@network.oauth_nonce || SecureRandom.uuid.to_s
|
113
121
|
end
|
114
122
|
|
115
123
|
def oauth_timestamp
|
116
|
-
Time.now.utc.to_i
|
124
|
+
@network.oauth_timestamp || Time.now.utc.to_i
|
117
125
|
end
|
118
126
|
|
119
127
|
class Signature
|
data/lib/libgss/network.rb
CHANGED
@@ -25,6 +25,9 @@ module Libgss
|
|
25
25
|
|
26
26
|
attr_accessor :consumer_secret
|
27
27
|
attr_accessor :consumer_key
|
28
|
+
attr_accessor :ignore_oauth_nonce
|
29
|
+
attr_accessor :oauth_nonce
|
30
|
+
attr_accessor :oauth_timestamp
|
28
31
|
|
29
32
|
attr_accessor :api_version
|
30
33
|
attr_accessor :platform
|
@@ -49,6 +52,9 @@ module Libgss
|
|
49
52
|
# @option options [String] :platform 接続先のGSSサーバの認証のプラットフォーム。デフォルトは"fontana"。
|
50
53
|
# @option options [String] :player_id 接続に使用するプレイヤのID
|
51
54
|
# @option options [String] :consumer_secret GSSサーバとクライアントの間で行う署名の検証に使用される文字列。
|
55
|
+
# @option options [Boolean] :ignore_oauth_nonce OAuth認証時にoauth_nonceとoauth_timestampを使用しないかどうか。
|
56
|
+
# @option options [String] :oauth_nonce OAuth認証のoauth_nonceパラメータ
|
57
|
+
# @option options [Integer] :oauth_timestamp OAuth認証のoauth_timestampパラメータ
|
52
58
|
# @option options [Boolean] :ssl_disabled SSLを無効にするかどうか。
|
53
59
|
# @option options [Boolean] :ignore_signature_key シグネチャキーによる署名を行うかどうか
|
54
60
|
# @option options [Integer] :device_type_cd GSS/fontanaに登録されたデバイス種別
|
@@ -71,6 +77,9 @@ module Libgss
|
|
71
77
|
|
72
78
|
@consumer_secret = options[:consumer_secret] || ENV["CONSUMER_SECRET"]
|
73
79
|
@ignore_signature_key = !!options[:ignore_signature_key]
|
80
|
+
@ignore_oauth_nonce = !!options[:ignore_oauth_nonce]
|
81
|
+
@oauth_nonce = options[:oauth_nonce] || nil
|
82
|
+
@oauth_timestamp = options[:oauth_timestamp] || nil
|
74
83
|
|
75
84
|
@device_type_cd = options[:device_type_cd]
|
76
85
|
@client_version = options[:client_version]
|
data/lib/libgss/version.rb
CHANGED
data/spec/libgss/network_spec.rb
CHANGED
@@ -19,6 +19,9 @@ describe Libgss::Network do
|
|
19
19
|
network.player_id.should_not == nil
|
20
20
|
network.auth_token.should_not == nil
|
21
21
|
network.signature_key.should_not == nil
|
22
|
+
network.ignore_oauth_nonce.should == false
|
23
|
+
network.oauth_nonce.should == nil
|
24
|
+
network.oauth_timestamp.should == nil
|
22
25
|
res.should == true
|
23
26
|
end
|
24
27
|
end
|
@@ -63,7 +66,6 @@ describe Libgss::Network do
|
|
63
66
|
it_should_behave_like "Libgss::Network#login success",
|
64
67
|
Proc.new{ network.player_id = nil },
|
65
68
|
Proc.new{ network.player_id.should_not == nil }
|
66
|
-
|
67
69
|
end
|
68
70
|
|
69
71
|
context "failure with unregistered (maybe invalid) player_id" do
|
@@ -184,4 +186,42 @@ describe Libgss::Network do
|
|
184
186
|
end
|
185
187
|
end
|
186
188
|
|
189
|
+
describe "with oauth options" do
|
190
|
+
|
191
|
+
def spec_with_network_options(opts={}, &block)
|
192
|
+
r = new_network_with_options(opts).tap(&:login).new_action_request
|
193
|
+
r.server_time
|
194
|
+
r.send_request do |outputs|
|
195
|
+
outputs.length.should == 1
|
196
|
+
result = outputs.first['result']
|
197
|
+
yield(result) if block_given?
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context "success" do
|
202
|
+
it "with ignore_oauth_nonce" do
|
203
|
+
spec_with_network_options({ignore_oauth_nonce: true})
|
204
|
+
end
|
205
|
+
it "with oauth_nonce" do
|
206
|
+
spec_with_network_options({oauth_nonce: UUID.new.generate})
|
207
|
+
end
|
208
|
+
it "with oauth_timestamp" do
|
209
|
+
time = Time.now
|
210
|
+
spec_with_network_options({oauth_timestamp: time.to_i})
|
211
|
+
end
|
212
|
+
end
|
213
|
+
context "401 error" do
|
214
|
+
it "with empty oauth_nonce" do
|
215
|
+
proc{
|
216
|
+
spec_with_network_options({oauth_nonce: ''})
|
217
|
+
}.should raise_error(::Libgss::ActionRequest::Error)
|
218
|
+
end
|
219
|
+
it "with old oauth_timestamp" do
|
220
|
+
time = Time.local(2013,7,1,12,0,0)
|
221
|
+
proc{
|
222
|
+
spec_with_network_options({oauth_timestamp: time.to_i})
|
223
|
+
}.should raise_error(::Libgss::ActionRequest::Error)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
187
227
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -21,3 +21,15 @@ def new_network(url = "http://localhost:4000", player_id = "1000001")
|
|
21
21
|
}
|
22
22
|
Libgss::Network.new(url, opts)
|
23
23
|
end
|
24
|
+
|
25
|
+
def new_network_with_options(opts={}, url = "http://localhost:4000", player_id = "1000001")
|
26
|
+
config = YAML.load_file(File.expand_path("../../fontana_sample/config/app_garden.yml", __FILE__))
|
27
|
+
opts = {
|
28
|
+
device_type_cd: 1,
|
29
|
+
client_version: "2013073101",
|
30
|
+
consumer_secret: config["consumer_secret"],
|
31
|
+
player_id: player_id,
|
32
|
+
# ssl_disabled: true,
|
33
|
+
}.update(opts)
|
34
|
+
Libgss::Network.new(url, opts)
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libgss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -209,4 +209,3 @@ test_files:
|
|
209
209
|
- spec/protected_assets/Icon.png
|
210
210
|
- spec/public_assets/Default.png
|
211
211
|
- spec/spec_helper.rb
|
212
|
-
has_rdoc:
|