omniauth-raven 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/omniauth/raven/version.rb +1 -1
- data/lib/omniauth/strategies/raven.rb +26 -30
- metadata +1 -1
@@ -3,28 +3,6 @@ require 'omniauth'
|
|
3
3
|
module OmniAuth
|
4
4
|
module Strategies
|
5
5
|
|
6
|
-
# Two new methods are added to the Standard CGI class.
|
7
|
-
class CGI
|
8
|
-
# Perhaps not a great place for this, but rfc3339 is an internet standard ....
|
9
|
-
# Takes a string with a time encoded according to rfc3339 and returns a Time object.
|
10
|
-
def timeforRFC3339( rfc3339 )
|
11
|
-
year = rfc3339[ 0..3 ].to_i
|
12
|
-
month = rfc3339[ 4..5 ].to_i
|
13
|
-
day = rfc3339[ 6..7 ].to_i
|
14
|
-
hour = rfc3339[ 9..10 ].to_i
|
15
|
-
minute = rfc3339[ 11..12 ].to_i
|
16
|
-
second = rfc3339[ 13..14 ].to_i
|
17
|
-
return Time.gm( year, month, day, hour, minute, second)
|
18
|
-
end
|
19
|
-
|
20
|
-
def escape(string)
|
21
|
-
string.gsub(/([^ a-zA-Z0-9_.-]+)/) do
|
22
|
-
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
23
|
-
end.tr(' ', '+')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
6
|
class Raven
|
29
7
|
include OmniAuth::Strategy
|
30
8
|
|
@@ -49,14 +27,14 @@ module OmniAuth
|
|
49
27
|
params = session['request_id'] = rand( 999999 ).to_s
|
50
28
|
|
51
29
|
auth_url = options[:raven_opt][:url] <<
|
52
|
-
"?ver=" <<
|
53
|
-
";url=" <<
|
54
|
-
";desc=" <<
|
55
|
-
";msg=" <<
|
56
|
-
";iact=" <<
|
57
|
-
";aauth=" <<
|
58
|
-
";params=" <<
|
59
|
-
";fail=" <<
|
30
|
+
"?ver=" << uriescape(options[:raven_opt][:version]) <<
|
31
|
+
";url=" << uriescape(callback_path) <<
|
32
|
+
";desc=" << uriescape(options[:raven_opt][:desc]) <<
|
33
|
+
";msg=" << uriescape(options[:raven_opt][:msg]) <<
|
34
|
+
";iact=" << uriescape(options[:raven_opt][:iact]) <<
|
35
|
+
";aauth=" << uriescape(options[:raven_opt][:aauth]) <<
|
36
|
+
";params=" << uriescape(params) <<
|
37
|
+
";fail=" << uriescape(options[:raven_opt][:fail])
|
60
38
|
|
61
39
|
return redirect auth_url
|
62
40
|
end
|
@@ -82,6 +60,24 @@ module OmniAuth
|
|
82
60
|
options[:fields][:name] = @name
|
83
61
|
options[:fields][:email] = @email
|
84
62
|
}
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def timeforRFC3339( rfc3339 )
|
67
|
+
year = rfc3339[ 0..3 ].to_i
|
68
|
+
month = rfc3339[ 4..5 ].to_i
|
69
|
+
day = rfc3339[ 6..7 ].to_i
|
70
|
+
hour = rfc3339[ 9..10 ].to_i
|
71
|
+
minute = rfc3339[ 11..12 ].to_i
|
72
|
+
second = rfc3339[ 13..14 ].to_i
|
73
|
+
return Time.gm( year, month, day, hour, minute, second)
|
74
|
+
end
|
75
|
+
|
76
|
+
def uriescape(string)
|
77
|
+
string.gsub(/([^ a-zA-Z0-9_.-]+)/) do
|
78
|
+
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
79
|
+
end.tr(' ', '+')
|
80
|
+
end
|
85
81
|
end
|
86
82
|
end
|
87
83
|
end
|