oa-basic 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +34 -0
- data/lib/omniauth/basic.rb +6 -3
- data/lib/omniauth/strategies/gowalla.rb +3 -1
- data/lib/omniauth/strategies/http_basic.rb +2 -2
- metadata +124 -39
- data/lib/omniauth/strategies/basecamp.rb +0 -53
- data/lib/omniauth/strategies/campfire.rb +0 -45
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
= OmniAuth::Basic
|
2
|
+
|
3
|
+
OmniAuth stratgies for APIs that have HTTP Basic authentication (such as Campfire and Basecamp).
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
To get just HTTP Basic functionality:
|
8
|
+
|
9
|
+
gem install oa-basic
|
10
|
+
|
11
|
+
For the full auth suite:
|
12
|
+
|
13
|
+
gem install omniauth
|
14
|
+
|
15
|
+
== Stand-Alone Example
|
16
|
+
|
17
|
+
Use the strategy as a middleware in your application:
|
18
|
+
|
19
|
+
require 'omniauth/basic'
|
20
|
+
|
21
|
+
use OmniAuth::Strategies::Campfire
|
22
|
+
|
23
|
+
Then simply direct users to '/auth/campfire' to prompt them for their Campfire credentials. You may also pre-set the credentials by POSTing to the URL with appropriate parameters (in the case of Campfire and Basecamp, the parameters are <tt>subdomain</tt>, <tt>user</tt>, and <tt>password</tt>).
|
24
|
+
|
25
|
+
== OmniAuth Builder
|
26
|
+
|
27
|
+
If you want to allow multiple providers, use the OmniAuth Builder:
|
28
|
+
|
29
|
+
require 'omniauth/basic'
|
30
|
+
|
31
|
+
use OmniAuth::Builder do
|
32
|
+
provider :campfire
|
33
|
+
provider :basecamp
|
34
|
+
end
|
data/lib/omniauth/basic.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'omniauth/core'
|
2
|
-
require 'omniauth/strategies/http_basic'
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
autoload :HttpBasic, 'omniauth/strategies/http_basic'
|
6
|
+
# autoload :Gowalla, 'omniauth/strategies/gowalla'
|
7
|
+
end
|
8
|
+
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
# so this won't actually work at all it
|
3
3
|
# turns out.
|
4
4
|
|
5
|
+
# require 'omniauth/basic'
|
6
|
+
#
|
5
7
|
# module OmniAuth
|
6
8
|
# module Strategies
|
7
9
|
# class Gowalla < OmniAuth::Strategies::HttpBasic #:nodoc:
|
@@ -14,4 +16,4 @@
|
|
14
16
|
# end
|
15
17
|
# end
|
16
18
|
# end
|
17
|
-
# end
|
19
|
+
# end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oa-basic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Michael Bleigh
|
@@ -14,85 +15,167 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-08-16 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
24
|
requirements:
|
25
25
|
- - "="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
+
hash: 23
|
27
28
|
segments:
|
28
29
|
- 0
|
29
30
|
- 0
|
30
|
-
-
|
31
|
-
version: 0.0.
|
31
|
+
- 4
|
32
|
+
version: 0.0.4
|
33
|
+
requirement: *id001
|
34
|
+
name: oa-core
|
35
|
+
prerelease: false
|
32
36
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
37
|
- !ruby/object:Gem::Dependency
|
35
|
-
|
36
|
-
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
38
40
|
requirements:
|
39
|
-
- -
|
41
|
+
- - ~>
|
40
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 15
|
41
44
|
segments:
|
45
|
+
- 1
|
46
|
+
- 6
|
42
47
|
- 0
|
43
|
-
version:
|
48
|
+
version: 1.6.0
|
49
|
+
requirement: *id002
|
50
|
+
name: rest-client
|
51
|
+
prerelease: false
|
44
52
|
type: :runtime
|
45
|
-
version_requirements: *id002
|
46
53
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 27
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
- 0
|
63
|
+
- 2
|
64
|
+
version: 0.0.2
|
65
|
+
requirement: *id003
|
66
|
+
name: multi_json
|
48
67
|
prerelease: false
|
49
|
-
|
68
|
+
type: :runtime
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
50
72
|
requirements:
|
51
|
-
- -
|
73
|
+
- - ~>
|
52
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
53
76
|
segments:
|
54
77
|
- 1
|
78
|
+
- 4
|
55
79
|
- 2
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
version_requirements: *id003
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: webmock
|
80
|
+
version: 1.4.2
|
81
|
+
requirement: *id004
|
82
|
+
name: nokogiri
|
62
83
|
prerelease: false
|
63
|
-
|
84
|
+
type: :runtime
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
64
88
|
requirements:
|
65
89
|
- - ">="
|
66
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
67
92
|
segments:
|
68
93
|
- 0
|
69
94
|
version: "0"
|
95
|
+
requirement: *id005
|
96
|
+
name: rake
|
97
|
+
prerelease: false
|
70
98
|
type: :development
|
71
|
-
version_requirements: *id004
|
72
99
|
- !ruby/object:Gem::Dependency
|
73
|
-
|
100
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ~>
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 15
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
- 0
|
109
|
+
- 8
|
110
|
+
version: 0.0.8
|
111
|
+
requirement: *id006
|
112
|
+
name: mg
|
74
113
|
prerelease: false
|
75
|
-
|
114
|
+
type: :development
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
76
118
|
requirements:
|
77
|
-
- -
|
119
|
+
- - ~>
|
78
120
|
- !ruby/object:Gem::Version
|
121
|
+
hash: 27
|
79
122
|
segments:
|
123
|
+
- 1
|
124
|
+
- 3
|
80
125
|
- 0
|
81
|
-
version:
|
126
|
+
version: 1.3.0
|
127
|
+
requirement: *id007
|
128
|
+
name: rspec
|
129
|
+
prerelease: false
|
82
130
|
type: :development
|
83
|
-
version_requirements: *id005
|
84
131
|
- !ruby/object:Gem::Dependency
|
85
|
-
|
132
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ~>
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
hash: 19
|
138
|
+
segments:
|
139
|
+
- 1
|
140
|
+
- 3
|
141
|
+
- 4
|
142
|
+
version: 1.3.4
|
143
|
+
requirement: *id008
|
144
|
+
name: webmock
|
86
145
|
prerelease: false
|
87
|
-
|
146
|
+
type: :development
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
88
150
|
requirements:
|
89
|
-
- -
|
151
|
+
- - ~>
|
90
152
|
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
91
154
|
segments:
|
92
155
|
- 0
|
93
|
-
|
156
|
+
- 5
|
157
|
+
- 4
|
158
|
+
version: 0.5.4
|
159
|
+
requirement: *id009
|
160
|
+
name: rack-test
|
161
|
+
prerelease: false
|
162
|
+
type: :development
|
163
|
+
- !ruby/object:Gem::Dependency
|
164
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
165
|
+
none: false
|
166
|
+
requirements:
|
167
|
+
- - ~>
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
hash: 1
|
170
|
+
segments:
|
171
|
+
- 1
|
172
|
+
- 4
|
173
|
+
- 3
|
174
|
+
version: 1.4.3
|
175
|
+
requirement: *id010
|
176
|
+
name: json
|
177
|
+
prerelease: false
|
94
178
|
type: :development
|
95
|
-
version_requirements: *id006
|
96
179
|
description: HTTP Basic strategies for OmniAuth.
|
97
180
|
email: michael@intridea.com
|
98
181
|
executables: []
|
@@ -103,8 +186,6 @@ extra_rdoc_files: []
|
|
103
186
|
|
104
187
|
files:
|
105
188
|
- lib/omniauth/basic.rb
|
106
|
-
- lib/omniauth/strategies/basecamp.rb
|
107
|
-
- lib/omniauth/strategies/campfire.rb
|
108
189
|
- lib/omniauth/strategies/gowalla.rb
|
109
190
|
- lib/omniauth/strategies/http_basic.rb
|
110
191
|
- README.rdoc
|
@@ -120,23 +201,27 @@ rdoc_options: []
|
|
120
201
|
require_paths:
|
121
202
|
- lib
|
122
203
|
required_ruby_version: !ruby/object:Gem::Requirement
|
204
|
+
none: false
|
123
205
|
requirements:
|
124
206
|
- - ">="
|
125
207
|
- !ruby/object:Gem::Version
|
208
|
+
hash: 3
|
126
209
|
segments:
|
127
210
|
- 0
|
128
211
|
version: "0"
|
129
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
|
+
none: false
|
130
214
|
requirements:
|
131
215
|
- - ">="
|
132
216
|
- !ruby/object:Gem::Version
|
217
|
+
hash: 3
|
133
218
|
segments:
|
134
219
|
- 0
|
135
220
|
version: "0"
|
136
221
|
requirements: []
|
137
222
|
|
138
223
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.3.
|
224
|
+
rubygems_version: 1.3.7
|
140
225
|
signing_key:
|
141
226
|
specification_version: 3
|
142
227
|
summary: HTTP Basic strategies for OmniAuth.
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module OmniAuth
|
2
|
-
module Strategies
|
3
|
-
class Basecamp < HttpBasic
|
4
|
-
def initialize(app)
|
5
|
-
require 'json'
|
6
|
-
super(app, :basecamp, nil)
|
7
|
-
end
|
8
|
-
|
9
|
-
def endpoint
|
10
|
-
"http://#{request.params['user']}:#{request.params['password']}@#{request.params['subdomain']}.basecamphq.com/me.xml"
|
11
|
-
end
|
12
|
-
|
13
|
-
def perform_authentication(endpoint)
|
14
|
-
super(endpoint) rescue super(endpoint.sub('http','https'))
|
15
|
-
end
|
16
|
-
|
17
|
-
def auth_hash
|
18
|
-
doc = Nokogiri::XML.parse(@response.body)
|
19
|
-
OmniAuth::Utils.deep_merge(super, {
|
20
|
-
'uid' => doc.xpath('person/id').text,
|
21
|
-
'user_info' => user_info(doc),
|
22
|
-
'credentials' => {
|
23
|
-
'token' => doc.xpath('person/token').text
|
24
|
-
}
|
25
|
-
})
|
26
|
-
end
|
27
|
-
|
28
|
-
def user_info(doc)
|
29
|
-
hash = {
|
30
|
-
'nickname' => request.params['user'],
|
31
|
-
'first_name' => doc.xpath('person/first-name').text,
|
32
|
-
'last_name' => doc.xpath('person/last-name').text,
|
33
|
-
'email' => doc.xpath('person/email-address').text,
|
34
|
-
'image' => doc.xpath('person/avatar-url').text
|
35
|
-
}
|
36
|
-
|
37
|
-
hash['name'] = [hash['first_name'], hash['last_name']].join(' ').strip
|
38
|
-
|
39
|
-
hash.delete('image') if hash['image'].include?('missing/avatar.png')
|
40
|
-
|
41
|
-
hash
|
42
|
-
end
|
43
|
-
|
44
|
-
def get_credentials
|
45
|
-
OmniAuth::Form.build('Basecamp Authentication') do
|
46
|
-
text_field 'Subdomain', 'subdomain'
|
47
|
-
text_field 'Username', 'user'
|
48
|
-
password_field 'Password', 'password'
|
49
|
-
end.to_response
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module OmniAuth
|
2
|
-
module Strategies
|
3
|
-
class Campfire < HttpBasic
|
4
|
-
def initialize(app)
|
5
|
-
require 'json'
|
6
|
-
super(app, :campfire, nil)
|
7
|
-
end
|
8
|
-
|
9
|
-
def endpoint
|
10
|
-
"http://#{request.params['user']}:#{request.params['password']}@#{request.params['subdomain']}.campfirenow.com/users/me.json"
|
11
|
-
end
|
12
|
-
|
13
|
-
def perform_authentication(endpoint)
|
14
|
-
super(endpoint) rescue super(endpoint.sub('http','https'))
|
15
|
-
end
|
16
|
-
|
17
|
-
def auth_hash
|
18
|
-
user_hash = JSON.parse(@response.body)['user']
|
19
|
-
OmniAuth::Utils.deep_merge(super, {
|
20
|
-
'uid' => user_hash['id'],
|
21
|
-
'user_info' => user_info(user_hash),
|
22
|
-
'credentials' => {
|
23
|
-
'token' => user_hash['api_auth_token']
|
24
|
-
}
|
25
|
-
})
|
26
|
-
end
|
27
|
-
|
28
|
-
def user_info(hash)
|
29
|
-
{
|
30
|
-
'nickname' => request.params['user'],
|
31
|
-
'name' => hash['name'],
|
32
|
-
'email' => hash['email_address']
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
def get_credentials
|
37
|
-
OmniAuth::Form.build('Campfire Authentication') do
|
38
|
-
text_field 'Subdomain', 'subdomain'
|
39
|
-
text_field 'Username', 'user'
|
40
|
-
password_field 'Password', 'password'
|
41
|
-
end.to_response
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|