oa-core 0.2.0.beta1 → 0.2.0.beta2
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/LICENSE +19 -0
- data/lib/omniauth/builder.rb +2 -2
- data/lib/omniauth/core.rb +21 -6
- data/lib/omniauth/strategy.rb +32 -9
- metadata +33 -43
- data/CHANGELOG.rdoc +0 -3
- data/LICENSE.rdoc +0 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/lib/omniauth/builder.rb
CHANGED
data/lib/omniauth/core.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'rack'
|
2
2
|
require 'singleton'
|
3
|
-
require 'omniauth/form'
|
4
3
|
|
5
4
|
module OmniAuth
|
6
|
-
|
7
5
|
autoload :Builder, 'omniauth/builder'
|
8
6
|
autoload :Strategy, 'omniauth/strategy'
|
9
7
|
autoload :Test, 'omniauth/test'
|
8
|
+
autoload :Form, 'omniauth/form'
|
10
9
|
|
11
10
|
module Strategies
|
12
11
|
autoload :Password, 'omniauth/strategies/password'
|
@@ -25,7 +24,18 @@ module OmniAuth
|
|
25
24
|
new_path = "#{OmniAuth.config.path_prefix}/failure?message=#{message_key}"
|
26
25
|
[302, {'Location' => "#{new_path}", 'Content-Type'=> 'text/html'}, []]
|
27
26
|
end,
|
28
|
-
:form_css => Form::DEFAULT_CSS
|
27
|
+
:form_css => Form::DEFAULT_CSS,
|
28
|
+
:test_mode => false,
|
29
|
+
:mock_auth => {
|
30
|
+
:default => {
|
31
|
+
'uid' => '1234',
|
32
|
+
'user_info' => {
|
33
|
+
'name' => 'Bob Example',
|
34
|
+
'email' => 'bob@example.com',
|
35
|
+
'nickname' => 'bob'
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
29
39
|
}
|
30
40
|
|
31
41
|
def self.defaults
|
@@ -45,9 +55,9 @@ module OmniAuth
|
|
45
55
|
end
|
46
56
|
|
47
57
|
attr_writer :on_failure
|
48
|
-
attr_accessor :path_prefix, :form_css
|
58
|
+
attr_accessor :path_prefix, :form_css, :test_mode, :mock_auth, :full_host
|
49
59
|
end
|
50
|
-
|
60
|
+
|
51
61
|
def self.config
|
52
62
|
Configuration.instance
|
53
63
|
end
|
@@ -56,6 +66,10 @@ module OmniAuth
|
|
56
66
|
yield config
|
57
67
|
end
|
58
68
|
|
69
|
+
def self.mock_auth_for(provider)
|
70
|
+
config.mock_auth[provider.to_sym] || config.mock_auth[:default]
|
71
|
+
end
|
72
|
+
|
59
73
|
module Utils
|
60
74
|
CAMELIZE_SPECIAL = {
|
61
75
|
'oauth' => 'OAuth',
|
@@ -65,7 +79,8 @@ module OmniAuth
|
|
65
79
|
'github' => 'GitHub',
|
66
80
|
'tripit' => 'TripIt',
|
67
81
|
'soundcloud' => 'SoundCloud',
|
68
|
-
'smugmug' => 'SmugMug'
|
82
|
+
'smugmug' => 'SmugMug',
|
83
|
+
'cas' => 'CAS'
|
69
84
|
}
|
70
85
|
|
71
86
|
module_function
|
data/lib/omniauth/strategy.rb
CHANGED
@@ -25,6 +25,8 @@ module OmniAuth
|
|
25
25
|
|
26
26
|
def call!(env)
|
27
27
|
@env = env
|
28
|
+
return mock_call!(env) if OmniAuth.config.test_mode
|
29
|
+
|
28
30
|
if request.path == request_path
|
29
31
|
status, headers, body = *call_app!
|
30
32
|
@response = Rack::Response.new(body, status, headers)
|
@@ -39,6 +41,17 @@ module OmniAuth
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
44
|
+
|
45
|
+
def mock_call!(env)
|
46
|
+
if request.path == request_path
|
47
|
+
redirect callback_path
|
48
|
+
elsif request.path == callback_path
|
49
|
+
@env['omniauth.auth'] = OmniAuth.mock_auth_for(name.to_sym)
|
50
|
+
call_app!
|
51
|
+
else
|
52
|
+
call_app!
|
53
|
+
end
|
54
|
+
end
|
42
55
|
|
43
56
|
def request_phase
|
44
57
|
raise NotImplementedError
|
@@ -46,7 +59,8 @@ module OmniAuth
|
|
46
59
|
|
47
60
|
def callback_phase
|
48
61
|
@env['omniauth.auth'] = auth_hash
|
49
|
-
|
62
|
+
|
63
|
+
call_app!
|
50
64
|
end
|
51
65
|
|
52
66
|
def path_prefix
|
@@ -60,11 +74,13 @@ module OmniAuth
|
|
60
74
|
def callback_path
|
61
75
|
options[:callback_path] || "#{path_prefix}/#{name}/callback"
|
62
76
|
end
|
77
|
+
|
78
|
+
def query_string
|
79
|
+
request.query_string.empty? ? "" : "?#{request.query_string}"
|
80
|
+
end
|
63
81
|
|
64
82
|
def call_app!
|
65
|
-
|
66
|
-
@env['rack.auth'] = env['omniauth.auth'] if env.key?('omniauth.auth')
|
67
|
-
@env['rack.auth.error'] = env['omniauth.error'] if env.key?('omniauth.error')
|
83
|
+
@env['omniauth.strategy'] = self
|
68
84
|
|
69
85
|
@app.call(@env)
|
70
86
|
end
|
@@ -77,14 +93,21 @@ module OmniAuth
|
|
77
93
|
end
|
78
94
|
|
79
95
|
def full_host
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
96
|
+
case OmniAuth.config.full_host
|
97
|
+
when String
|
98
|
+
OmniAuth.config.full_host
|
99
|
+
when Proc
|
100
|
+
OmniAuth.config.full_host.call(env)
|
101
|
+
else
|
102
|
+
uri = URI.parse(request.url)
|
103
|
+
uri.path = ''
|
104
|
+
uri.query = nil
|
105
|
+
uri.to_s
|
106
|
+
end
|
84
107
|
end
|
85
108
|
|
86
109
|
def callback_url
|
87
|
-
full_host + callback_path
|
110
|
+
full_host + callback_path + query_string
|
88
111
|
end
|
89
112
|
|
90
113
|
def session
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oa-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -1848230051
|
5
4
|
prerelease: true
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 2
|
9
8
|
- 0
|
10
|
-
-
|
11
|
-
version: 0.2.0.
|
9
|
+
- beta2
|
10
|
+
version: 0.2.0.beta2
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Michael Bleigh
|
@@ -16,118 +15,111 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date:
|
18
|
+
date: 2011-01-14 00:00:00 -06:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
22
|
+
name: rack
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
none: false
|
25
25
|
requirements:
|
26
26
|
- - ~>
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 13
|
29
28
|
segments:
|
30
29
|
- 1
|
31
30
|
- 1
|
32
31
|
version: "1.1"
|
33
|
-
requirement: *id001
|
34
|
-
name: rack
|
35
|
-
prerelease: false
|
36
32
|
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
37
35
|
- !ruby/object:Gem::Dependency
|
38
|
-
|
36
|
+
name: rake
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
40
39
|
requirements:
|
41
40
|
- - ">="
|
42
41
|
- !ruby/object:Gem::Version
|
43
|
-
hash: 3
|
44
42
|
segments:
|
45
43
|
- 0
|
46
44
|
version: "0"
|
47
|
-
requirement: *id002
|
48
|
-
name: rake
|
49
|
-
prerelease: false
|
50
45
|
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id002
|
51
48
|
- !ruby/object:Gem::Dependency
|
52
|
-
|
49
|
+
name: mg
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
51
|
none: false
|
54
52
|
requirements:
|
55
53
|
- - ~>
|
56
54
|
- !ruby/object:Gem::Version
|
57
|
-
hash: 15
|
58
55
|
segments:
|
59
56
|
- 0
|
60
57
|
- 0
|
61
58
|
- 8
|
62
59
|
version: 0.0.8
|
63
|
-
requirement: *id003
|
64
|
-
name: mg
|
65
|
-
prerelease: false
|
66
60
|
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: *id003
|
67
63
|
- !ruby/object:Gem::Dependency
|
68
|
-
|
64
|
+
name: rspec
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
66
|
none: false
|
70
67
|
requirements:
|
71
68
|
- - ~>
|
72
69
|
- !ruby/object:Gem::Version
|
73
|
-
hash: 27
|
74
70
|
segments:
|
75
71
|
- 1
|
76
72
|
- 3
|
77
73
|
- 0
|
78
74
|
version: 1.3.0
|
79
|
-
requirement: *id004
|
80
|
-
name: rspec
|
81
|
-
prerelease: false
|
82
75
|
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: *id004
|
83
78
|
- !ruby/object:Gem::Dependency
|
84
|
-
|
79
|
+
name: webmock
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
81
|
none: false
|
86
82
|
requirements:
|
87
83
|
- - ~>
|
88
84
|
- !ruby/object:Gem::Version
|
89
|
-
hash: 19
|
90
85
|
segments:
|
91
86
|
- 1
|
92
87
|
- 3
|
93
88
|
- 4
|
94
89
|
version: 1.3.4
|
95
|
-
requirement: *id005
|
96
|
-
name: webmock
|
97
|
-
prerelease: false
|
98
90
|
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id005
|
99
93
|
- !ruby/object:Gem::Dependency
|
100
|
-
|
94
|
+
name: rack-test
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
96
|
none: false
|
102
97
|
requirements:
|
103
98
|
- - ~>
|
104
99
|
- !ruby/object:Gem::Version
|
105
|
-
hash: 3
|
106
100
|
segments:
|
107
101
|
- 0
|
108
102
|
- 5
|
109
103
|
- 4
|
110
104
|
version: 0.5.4
|
111
|
-
requirement: *id006
|
112
|
-
name: rack-test
|
113
|
-
prerelease: false
|
114
105
|
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: *id006
|
115
108
|
- !ruby/object:Gem::Dependency
|
116
|
-
|
109
|
+
name: json
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
117
111
|
none: false
|
118
112
|
requirements:
|
119
113
|
- - ~>
|
120
114
|
- !ruby/object:Gem::Version
|
121
|
-
hash: 1
|
122
115
|
segments:
|
123
116
|
- 1
|
124
117
|
- 4
|
125
118
|
- 3
|
126
119
|
version: 1.4.3
|
127
|
-
requirement: *id007
|
128
|
-
name: json
|
129
|
-
prerelease: false
|
130
120
|
type: :development
|
121
|
+
prerelease: false
|
122
|
+
version_requirements: *id007
|
131
123
|
description: HTTP Basic strategies for OmniAuth.
|
132
124
|
email: michael@intridea.com
|
133
125
|
executables: []
|
@@ -146,8 +138,7 @@ files:
|
|
146
138
|
- lib/omniauth/test/strategy_macros.rb
|
147
139
|
- lib/omniauth/test/strategy_test_case.rb
|
148
140
|
- lib/omniauth/test.rb
|
149
|
-
- LICENSE
|
150
|
-
- CHANGELOG.rdoc
|
141
|
+
- LICENSE
|
151
142
|
has_rdoc: true
|
152
143
|
homepage: http://github.com/intridea/omniauth
|
153
144
|
licenses: []
|
@@ -162,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
153
|
requirements:
|
163
154
|
- - ">="
|
164
155
|
- !ruby/object:Gem::Version
|
165
|
-
hash:
|
156
|
+
hash: -3598036848001495885
|
166
157
|
segments:
|
167
158
|
- 0
|
168
159
|
version: "0"
|
@@ -171,7 +162,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
162
|
requirements:
|
172
163
|
- - ">"
|
173
164
|
- !ruby/object:Gem::Version
|
174
|
-
hash: 25
|
175
165
|
segments:
|
176
166
|
- 1
|
177
167
|
- 3
|
data/CHANGELOG.rdoc
DELETED
data/LICENSE.rdoc
DELETED
File without changes
|