oauth2-core 0.1.1 → 0.1.2
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/oauth2/attributes.rb +2 -1
- data/lib/oauth2/headers/authorization.rb +20 -7
- metadata +3 -3
data/lib/oauth2/attributes.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'oauth2/attributes'
|
2
|
+
require 'active_support/ordered_hash'
|
2
3
|
|
3
4
|
module OAuth2
|
4
5
|
|
@@ -44,10 +45,19 @@ module OAuth2
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def attributes
|
47
|
-
|
48
|
+
hash = ActiveSupport::OrderedHash.new
|
49
|
+
Attributes.each do |attribute|
|
48
50
|
hash[attribute] = instance_variable_get("@#{attribute}")
|
49
|
-
hash
|
50
51
|
end
|
52
|
+
hash
|
53
|
+
end
|
54
|
+
|
55
|
+
def to_s
|
56
|
+
attrs = attributes.collect do |key, value|
|
57
|
+
%{#{key}="#{value}"} if value
|
58
|
+
end.compact
|
59
|
+
|
60
|
+
"Token " + attrs.join(",\n ")
|
51
61
|
end
|
52
62
|
|
53
63
|
class << self
|
@@ -55,18 +65,21 @@ module OAuth2
|
|
55
65
|
# This method does what it is named after. Give it a String and it
|
56
66
|
# returns a Hash. The header specification can be found on:
|
57
67
|
# http://tools.ietf.org/html/draft-hammer-oauth2-00#section-5.1
|
58
|
-
# TODO:
|
59
|
-
def parse(string
|
60
|
-
header = new
|
68
|
+
# TODO: Verify that token is the first attribute.
|
69
|
+
def parse(string)
|
70
|
+
header = new
|
61
71
|
|
62
72
|
string.strip!
|
63
73
|
|
64
74
|
type, tuples = string[0..4], string[5..-1].split("\n")
|
65
75
|
|
66
|
-
|
76
|
+
unless type == "Token"
|
77
|
+
header.errors << :format_invalid
|
78
|
+
return header
|
79
|
+
end
|
67
80
|
|
68
81
|
tuples.map! { |tuple| tuple.strip! }
|
69
|
-
|
82
|
+
|
70
83
|
tuples.each do |tuple|
|
71
84
|
unless tuple =~ /\s*(.+)="(.+)"/
|
72
85
|
header.errors << :format_invalid
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexander Flatter
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-08 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|