mojodna-oauth 0.3.1.3 → 0.3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/oauth/cli.rb +32 -7
- data/lib/oauth/helper.rb +2 -0
- data/lib/oauth/request_proxy/base.rb +41 -24
- data/lib/oauth/version.rb +1 -1
- data/oauth.gemspec +2 -2
- metadata +2 -2
data/lib/oauth/cli.rb
CHANGED
@@ -53,14 +53,34 @@ module OAuth
|
|
53
53
|
|
54
54
|
if verbose?
|
55
55
|
stdout.puts "Method: #{request.method}"
|
56
|
-
stdout.puts "
|
57
|
-
stdout.puts "Normalized params: #{request.normalized_parameters}"
|
56
|
+
stdout.puts "URI: #{request.uri}"
|
57
|
+
stdout.puts "Normalized params: #{request.normalized_parameters}" unless options[:xmpp]
|
58
58
|
stdout.puts "Signature base string: #{request.signature_base_string}"
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
|
60
|
+
if options[:xmpp]
|
61
|
+
stdout.puts
|
62
|
+
stdout.puts "XMPP Stanza:"
|
63
|
+
stdout.puts <<-EOS
|
64
|
+
<oauth xmlns='urn:xmpp:tmp:oauth'>
|
65
|
+
<oauth_consumer_key>#{request.oauth_consumer_key}</oauth_consumer_key>
|
66
|
+
<oauth_token>#{request.oauth_token}</oauth_token>
|
67
|
+
<oauth_signature_method>#{request.oauth_signature_method}</oauth_signature_method>
|
68
|
+
<oauth_signature>#{request.oauth_signature}</oauth_signature>
|
69
|
+
<oauth_timestamp>#{request.oauth_timestamp}</oauth_timestamp>
|
70
|
+
<oauth_nonce>#{request.oauth_nonce}</oauth_nonce>
|
71
|
+
<oauth_version>#{request.oauth_version}</oauth_version>
|
72
|
+
</oauth>
|
73
|
+
EOS
|
74
|
+
stdout.puts
|
75
|
+
stdout.puts "Note: You may want to use bare JIDs in your URI."
|
76
|
+
stdout.puts
|
77
|
+
else
|
78
|
+
stdout.puts "OAuth Request URI: #{request.signed_uri}"
|
79
|
+
stdout.puts "Request URI: #{request.signed_uri(false)}"
|
80
|
+
stdout.puts "Authorization header: #{request.oauth_header(:realm => options[:realm])}"
|
81
|
+
end
|
82
|
+
stdout.puts "Signature: #{request.oauth_signature}"
|
83
|
+
stdout.puts "Escaped signature: #{OAuth::Helper.escape(request.oauth_signature)}"
|
64
84
|
else
|
65
85
|
stdout.puts signature
|
66
86
|
end
|
@@ -140,6 +160,11 @@ module OAuth
|
|
140
160
|
options[:oauth_version] = nil
|
141
161
|
end
|
142
162
|
|
163
|
+
opts.on("--xmpp", "Generate XMPP stanzas.") do
|
164
|
+
options[:xmpp] = true
|
165
|
+
options[:method] ||= "iq"
|
166
|
+
end
|
167
|
+
|
143
168
|
opts.on("-v", "--verbose", "Be verbose.") do
|
144
169
|
options[:verbose] = true
|
145
170
|
end
|
data/lib/oauth/helper.rb
CHANGED
@@ -16,14 +16,52 @@ module OAuth::RequestProxy
|
|
16
16
|
@options = options
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
## OAuth parameters
|
20
|
+
|
21
|
+
def oauth_consumer_key
|
22
|
+
parameters['oauth_consumer_key']
|
23
|
+
end
|
24
|
+
|
25
|
+
def oauth_nonce
|
26
|
+
parameters['oauth_nonce']
|
27
|
+
end
|
28
|
+
|
29
|
+
def oauth_signature
|
30
|
+
# TODO can this be nil?
|
31
|
+
parameters['oauth_signature'] || ""
|
32
|
+
end
|
33
|
+
|
34
|
+
def oauth_signature_method
|
35
|
+
case parameters['oauth_signature_method']
|
36
|
+
when Array
|
37
|
+
parameters['oauth_signature_method'].first
|
38
|
+
else
|
39
|
+
parameters['oauth_signature_method']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def oauth_timestamp
|
44
|
+
parameters['oauth_timestamp']
|
45
|
+
end
|
46
|
+
|
47
|
+
def oauth_token
|
20
48
|
parameters['oauth_token']
|
21
49
|
end
|
22
50
|
|
23
|
-
def
|
24
|
-
parameters[
|
51
|
+
def oauth_version
|
52
|
+
parameters["oauth_version"]
|
25
53
|
end
|
26
54
|
|
55
|
+
# TODO deprecate these
|
56
|
+
alias_method :consumer_key, :oauth_consumer_key
|
57
|
+
alias_method :token, :oauth_token
|
58
|
+
alias_method :nonce, :oauth_nonce
|
59
|
+
alias_method :timestamp, :oauth_timestamp
|
60
|
+
alias_method :signature, :oauth_signature
|
61
|
+
alias_method :signature_method, :oauth_signature_method
|
62
|
+
|
63
|
+
## Parameter accessors
|
64
|
+
|
27
65
|
def parameters
|
28
66
|
raise NotImplementedError, "Must be implemented by subclasses"
|
29
67
|
end
|
@@ -40,27 +78,6 @@ module OAuth::RequestProxy
|
|
40
78
|
parameters.reject { |k,v| OAuth::PARAMETERS.include?(k) }
|
41
79
|
end
|
42
80
|
|
43
|
-
def nonce
|
44
|
-
parameters['oauth_nonce']
|
45
|
-
end
|
46
|
-
|
47
|
-
def timestamp
|
48
|
-
parameters['oauth_timestamp']
|
49
|
-
end
|
50
|
-
|
51
|
-
def signature_method
|
52
|
-
case parameters['oauth_signature_method']
|
53
|
-
when Array
|
54
|
-
parameters['oauth_signature_method'].first
|
55
|
-
else
|
56
|
-
parameters['oauth_signature_method']
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def signature
|
61
|
-
parameters['oauth_signature'] || ""
|
62
|
-
end
|
63
|
-
|
64
81
|
# See 9.1.2 in specs
|
65
82
|
def normalized_uri
|
66
83
|
u = URI.parse(uri)
|
data/lib/oauth/version.rb
CHANGED
data/oauth.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{oauth}
|
5
|
-
s.version = "0.3.1.
|
5
|
+
s.version = "0.3.1.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons"]
|
9
|
-
s.date = %q{2009-02-
|
9
|
+
s.date = %q{2009-02-05}
|
10
10
|
s.default_executable = %q{oauth}
|
11
11
|
s.description = %q{OAuth Core Ruby implementation}
|
12
12
|
s.email = %q{pelleb@gmail.com}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojodna-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.1.
|
4
|
+
version: 0.3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pelle Braendgaard
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2009-02-
|
17
|
+
date: 2009-02-05 00:00:00 -08:00
|
18
18
|
default_executable: oauth
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|