omniauth-devpost 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/Gemfile +8 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +13 -0
- data/lib/omniauth/strategies/devpost.rb +63 -0
- data/lib/omniauth-devpost/version.rb +5 -0
- data/lib/omniauth-devpost.rb +7 -0
- data/omniauth-devpost.gemspec +22 -0
- data/spec/omniauth/strategies/devpost_spec.rb +362 -0
- data/spec/spec_helper.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6cffa0603342e24acd9961652e4f0cc6df3501ca
|
4
|
+
data.tar.gz: 200fb44dfec674893f7aab5ea5689e6fa2da69df
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 10ab9bfc9abe8cacf474fee5fe9a854584d8964652cdcd99be37436a4db13a78e57792200efe1110984dc726658a70a284799e88f946d7b4c41e469fd1f02a1a
|
7
|
+
data.tar.gz: 6a570c02de3198abbee74d5e33587cfd84444f2e0ff0b6b3a48fe287707f72ee635cd811062e41322156bb0eac1e5a5326d84624ad60df7b9954d2d038af24a1
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Ross Kaffenberger
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Omniauth::Devpost
|
2
|
+
|
3
|
+
Use this gem to authenticate against the (future) Devpost user api.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'omniauth-devpost'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install omniauth-devpost
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
The Devpost OAuth protocol is supported but not yet publicly available.
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'omniauth'
|
2
|
+
require 'omniauth-oauth2'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Devpost < OmniAuth::Strategies::OAuth2
|
7
|
+
DEFAULT_SCOPE = "user"
|
8
|
+
OMNIAUTH_PROVIDER_SITE = ENV.fetch('OMNIAUTH_PROVIDER_SITE') { 'https://api.devpost.com' }
|
9
|
+
OMNIAUTH_AUTHORIZE_URL = ENV.fetch('OMNIAUTH_AUTHORIZE_URL') { 'https://oauth.devpost.com/oauth/authorize' }
|
10
|
+
OMNIAUTH_TOKEN_URL = ENV.fetch('OMNIAUTH_TOKEN_URL') { 'https://oauth.devpost.com/oauth/token' }
|
11
|
+
|
12
|
+
option :name, "devpost"
|
13
|
+
|
14
|
+
option :client_options, {
|
15
|
+
:site => OMNIAUTH_PROVIDER_SITE,
|
16
|
+
:authorize_url => OMNIAUTH_AUTHORIZE_URL,
|
17
|
+
:token_url => OMNIAUTH_TOKEN_URL
|
18
|
+
}
|
19
|
+
|
20
|
+
option :authorize_options, [:scope]
|
21
|
+
|
22
|
+
# For more info, see https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema
|
23
|
+
|
24
|
+
uid { raw_info['id'] }
|
25
|
+
|
26
|
+
info do
|
27
|
+
prune!({
|
28
|
+
'nickname' => raw_info['screen_name'],
|
29
|
+
'email' => raw_info['email'],
|
30
|
+
'location' => raw_info['location'],
|
31
|
+
'first_name' => raw_info['first_name'],
|
32
|
+
'last_name' => raw_info['last_name']
|
33
|
+
})
|
34
|
+
end
|
35
|
+
|
36
|
+
extra do
|
37
|
+
prune!({
|
38
|
+
'raw_info' => raw_info
|
39
|
+
})
|
40
|
+
end
|
41
|
+
|
42
|
+
def raw_info
|
43
|
+
@raw_info ||= raw_credentials_json["user"]
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
def raw_credentials_json
|
49
|
+
@raw_credentials_json ||= begin
|
50
|
+
access_token.options[:mode] = :query
|
51
|
+
access_token.get('/user/credentials').parsed
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def prune!(hash)
|
56
|
+
hash.delete_if do |_, value|
|
57
|
+
prune!(value) if value.is_a?(Hash)
|
58
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-devpost/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Ross Kaffenberger"]
|
6
|
+
gem.email = ["rosskaff@gmail.com"]
|
7
|
+
gem.description = %q{Official OmniAuth strategy for Devpost.}
|
8
|
+
gem.summary = %q{Official OmniAuth strategy for Devpost.}
|
9
|
+
gem.homepage = "https://github.com/challengepost/omniauth-devpost"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
14
|
+
gem.name = "omniauth-devpost"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Omniauth::Devpost::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.1'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
end
|
@@ -0,0 +1,362 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-devpost'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
describe OmniAuth::Strategies::Devpost do
|
6
|
+
before do
|
7
|
+
@request = double('Request')
|
8
|
+
allow(@request).to receive(:params) { {} }
|
9
|
+
allow(@request).to receive(:cookies) { {} }
|
10
|
+
allow(@request).to receive(:env) { {} }
|
11
|
+
allow(@request).to receive(:scheme) { 'http' }
|
12
|
+
|
13
|
+
@app_id = '123'
|
14
|
+
@app_secret = '53cr3tz'
|
15
|
+
end
|
16
|
+
|
17
|
+
subject do
|
18
|
+
args = [@app_id, @app_secret, @options].compact
|
19
|
+
OmniAuth::Strategies::Devpost.new(nil, *args).tap do |strategy|
|
20
|
+
allow(strategy).to receive(:request) { @request }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it { should be_a(OmniAuth::Strategies::OAuth2) }
|
25
|
+
|
26
|
+
describe '#client' do
|
27
|
+
it 'has correct Facebook site' do
|
28
|
+
expect(subject.client.site).to eq('https://api.devpost.com')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'has correct authorize url' do
|
32
|
+
expect(subject.client.options[:authorize_url]).to eq('https://oauth.devpost.com/oauth/authorize')
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'has correct token url' do
|
36
|
+
expect(subject.client.options[:token_url]).to eq('https://oauth.devpost.com/oauth/token')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#callback_url' do
|
41
|
+
|
42
|
+
it "returns the default callback url" do
|
43
|
+
url_base = 'http://auth.request.com'
|
44
|
+
allow(@request).to receive(:url) { "#{url_base}/some/page" }
|
45
|
+
allow(subject).to receive(:script_name) { '' } # as not to depend on Rack env
|
46
|
+
expect(subject.callback_url).to eq("#{url_base}/auth/devpost/callback")
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns path from callback_path option" do
|
50
|
+
url_base = 'http://auth.request.com'
|
51
|
+
@options = { :callback_path => "/auth/CP/done"}
|
52
|
+
allow(@request).to receive(:url) { "#{url_base}/some/page" }
|
53
|
+
allow(subject).to receive(:script_name) { '' } # as not to depend on Rack env
|
54
|
+
expect(subject.callback_url).to eq("#{url_base}/auth/CP/done")
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#uid' do
|
60
|
+
before :each do
|
61
|
+
allow(subject).to receive(:raw_info) { { 'id' => '123' } }
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'returns the id from raw_info' do
|
65
|
+
expect(subject.uid).to eq('123')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#info' do
|
70
|
+
context 'when optional data is not present in raw info' do
|
71
|
+
before :each do
|
72
|
+
|
73
|
+
allow(subject).to receive(:raw_info) { {} }
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'has no email key' do
|
77
|
+
expect(subject.info).to_not have_key('email')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'has no nickname key' do
|
81
|
+
expect(subject.info).to_not have_key('nickname')
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'has no first name key' do
|
85
|
+
expect(subject.info).to_not have_key('first_name')
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'has no last name key' do
|
89
|
+
expect(subject.info).to_not have_key('last_name')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'has no location key' do
|
93
|
+
expect(subject.info).to_not have_key('location')
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when optional data is present in raw info' do
|
99
|
+
before :each do
|
100
|
+
@raw_info ||= { 'screen_name' => 'fredsmith' }
|
101
|
+
allow(subject).to receive(:raw_info) { @raw_info }
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'returns the name' do
|
105
|
+
expect(subject.info['nickname']).to eq('fredsmith')
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'returns the email' do
|
109
|
+
@raw_info['email'] = 'fred@smith.com'
|
110
|
+
expect(subject.info['email']).to eq('fred@smith.com')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'returns the username as nickname' do
|
114
|
+
@raw_info['screen_name'] = 'fredsmith'
|
115
|
+
expect(subject.info['nickname']).to eq('fredsmith')
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'returns the first name' do
|
119
|
+
@raw_info['first_name'] = 'Fred'
|
120
|
+
expect(subject.info['first_name']).to eq('Fred')
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'returns the last name' do
|
124
|
+
@raw_info['last_name'] = 'Smith'
|
125
|
+
expect(subject.info['last_name']).to eq('Smith')
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'returns the location name as location' do
|
129
|
+
@raw_info['location'] = 'Palo Alto, California'
|
130
|
+
expect(subject.info['location']).to eq('Palo Alto, California')
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#raw_info' do
|
138
|
+
before :each do
|
139
|
+
@access_token = double('OAuth2::AccessToken', :options => {})
|
140
|
+
allow(subject).to receive(:access_token) { @access_token }
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'performs a GET to /user/credentials' do
|
144
|
+
allow(@access_token).to receive(:get) { @access_token.as_null_object }
|
145
|
+
expect(@access_token).to receive(:get).with('/user/credentials')
|
146
|
+
subject.raw_info
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'returns a Hash' do
|
150
|
+
allow(@access_token).to receive(:get).with('/user/credentials') do
|
151
|
+
raw_response = double('Faraday::Response')
|
152
|
+
allow(raw_response).to receive(:body) { '{ "user" : { "ohai": "thar" } }' }
|
153
|
+
allow(raw_response).to receive(:status) { 200 }
|
154
|
+
allow(raw_response).to receive(:headers) { { 'Content-Type' => 'application/json' } }
|
155
|
+
OAuth2::Response.new(raw_response)
|
156
|
+
end
|
157
|
+
expect(subject.raw_info).to be_a(Hash)
|
158
|
+
expect(subject.raw_info['ohai']).to eq('thar')
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
# describe '#credentials' do
|
165
|
+
# before :each do
|
166
|
+
# @access_token = double('OAuth2::AccessToken')
|
167
|
+
# @access_token.stub(:token)
|
168
|
+
# @access_token.stub(:expires?)
|
169
|
+
# @access_token.stub(:expires_at)
|
170
|
+
# @access_token.stub(:refresh_token)
|
171
|
+
# subject.stub(:access_token) { @access_token }
|
172
|
+
# end
|
173
|
+
|
174
|
+
# it 'returns a Hash' do
|
175
|
+
# subject.credentials.should be_a(Hash)
|
176
|
+
# end
|
177
|
+
|
178
|
+
# it 'returns the token' do
|
179
|
+
# @access_token.stub(:token) { '123' }
|
180
|
+
# subject.credentials['token'].should eq('123')
|
181
|
+
# end
|
182
|
+
|
183
|
+
# it 'returns the expiry status' do
|
184
|
+
# @access_token.stub(:expires?) { true }
|
185
|
+
# subject.credentials['expires'].should eq(true)
|
186
|
+
|
187
|
+
# @access_token.stub(:expires?) { false }
|
188
|
+
# subject.credentials['expires'].should eq(false)
|
189
|
+
# end
|
190
|
+
|
191
|
+
# it 'returns the refresh token and expiry time when expiring' do
|
192
|
+
# ten_mins_from_now = (Time.now + 600).to_i
|
193
|
+
# @access_token.stub(:expires?) { true }
|
194
|
+
# @access_token.stub(:refresh_token) { '321' }
|
195
|
+
# @access_token.stub(:expires_at) { ten_mins_from_now }
|
196
|
+
# subject.credentials['refresh_token'].should eq('321')
|
197
|
+
# subject.credentials['expires_at'].should eq(ten_mins_from_now)
|
198
|
+
# end
|
199
|
+
|
200
|
+
# it 'does not return the refresh token when it is nil and expiring' do
|
201
|
+
# @access_token.stub(:expires?) { true }
|
202
|
+
# @access_token.stub(:refresh_token) { nil }
|
203
|
+
# subject.credentials['refresh_token'].should be_nil
|
204
|
+
# subject.credentials.should_not have_key('refresh_token')
|
205
|
+
# end
|
206
|
+
|
207
|
+
# it 'does not return the refresh token when not expiring' do
|
208
|
+
# @access_token.stub(:expires?) { false }
|
209
|
+
# @access_token.stub(:refresh_token) { 'XXX' }
|
210
|
+
# subject.credentials['refresh_token'].should be_nil
|
211
|
+
# subject.credentials.should_not have_key('refresh_token')
|
212
|
+
# end
|
213
|
+
# end
|
214
|
+
|
215
|
+
# describe '#extra' do
|
216
|
+
# before :each do
|
217
|
+
# @raw_info = { 'name' => 'Fred Smith' }
|
218
|
+
# subject.stub(:raw_info) { @raw_info }
|
219
|
+
# end
|
220
|
+
|
221
|
+
# it 'returns a Hash' do
|
222
|
+
# subject.extra.should be_a(Hash)
|
223
|
+
# end
|
224
|
+
|
225
|
+
# it 'contains raw info' do
|
226
|
+
# subject.extra.should eq({ 'raw_info' => @raw_info })
|
227
|
+
# end
|
228
|
+
# end
|
229
|
+
|
230
|
+
# describe '#signed_request' do
|
231
|
+
# context 'cookie/param not present' do
|
232
|
+
# it 'is nil' do
|
233
|
+
# subject.send(:signed_request).should be_nil
|
234
|
+
# end
|
235
|
+
# end
|
236
|
+
|
237
|
+
# context 'cookie present' do
|
238
|
+
# before :each do
|
239
|
+
# @payload = {
|
240
|
+
# 'algorithm' => 'HMAC-SHA256',
|
241
|
+
# 'code' => 'm4c0d3z',
|
242
|
+
# 'issued_at' => Time.now.to_i,
|
243
|
+
# 'user_id' => '123456'
|
244
|
+
# }
|
245
|
+
|
246
|
+
# @request.stub(:cookies) do
|
247
|
+
# { "fbsr_#{@client_id}" => signed_request(@payload, @client_secret) }
|
248
|
+
# end
|
249
|
+
# end
|
250
|
+
|
251
|
+
# it 'parses the access code out from the cookie' do
|
252
|
+
# subject.send(:signed_request).should eq(@payload)
|
253
|
+
# end
|
254
|
+
# end
|
255
|
+
|
256
|
+
# context 'param present' do
|
257
|
+
# before :each do
|
258
|
+
# @payload = {
|
259
|
+
# 'algorithm' => 'HMAC-SHA256',
|
260
|
+
# 'oauth_token' => 'XXX',
|
261
|
+
# 'issued_at' => Time.now.to_i,
|
262
|
+
# 'user_id' => '123456'
|
263
|
+
# }
|
264
|
+
|
265
|
+
# @request.stub(:params) do
|
266
|
+
# { 'signed_request' => signed_request(@payload, @client_secret) }
|
267
|
+
# end
|
268
|
+
# end
|
269
|
+
|
270
|
+
# it 'parses the access code out from the param' do
|
271
|
+
# subject.send(:signed_request).should eq(@payload)
|
272
|
+
# end
|
273
|
+
# end
|
274
|
+
|
275
|
+
# context 'cookie + param present' do
|
276
|
+
# before :each do
|
277
|
+
# @payload_from_cookie = {
|
278
|
+
# 'algorithm' => 'HMAC-SHA256',
|
279
|
+
# 'from' => 'cookie'
|
280
|
+
# }
|
281
|
+
|
282
|
+
# @request.stub(:cookies) do
|
283
|
+
# { "fbsr_#{@client_id}" => signed_request(@payload_from_cookie, @client_secret) }
|
284
|
+
# end
|
285
|
+
|
286
|
+
# @payload_from_param = {
|
287
|
+
# 'algorithm' => 'HMAC-SHA256',
|
288
|
+
# 'from' => 'param'
|
289
|
+
# }
|
290
|
+
|
291
|
+
# @request.stub(:params) do
|
292
|
+
# { 'signed_request' => signed_request(@payload_from_param, @client_secret) }
|
293
|
+
# end
|
294
|
+
# end
|
295
|
+
|
296
|
+
# it 'picks param over cookie' do
|
297
|
+
# subject.send(:signed_request).should eq(@payload_from_param)
|
298
|
+
# end
|
299
|
+
# end
|
300
|
+
# end
|
301
|
+
|
302
|
+
# describe '#request_phase' do
|
303
|
+
# describe 'params contain a signed request with an access token' do
|
304
|
+
# before do
|
305
|
+
# payload = {
|
306
|
+
# 'algorithm' => 'HMAC-SHA256',
|
307
|
+
# 'oauth_token' => 'm4c0d3z'
|
308
|
+
# }
|
309
|
+
# @raw_signed_request = signed_request(payload, @client_secret)
|
310
|
+
# @request.stub(:params) do
|
311
|
+
# { "signed_request" => @raw_signed_request }
|
312
|
+
# end
|
313
|
+
|
314
|
+
# subject.stub(:callback_url) { '/' }
|
315
|
+
# end
|
316
|
+
|
317
|
+
# it 'redirects to callback passing along signed request' do
|
318
|
+
# subject.should_receive(:redirect).with("/?signed_request=#{Rack::Utils.escape(@raw_signed_request)}").once
|
319
|
+
# subject.request_phase
|
320
|
+
# end
|
321
|
+
# end
|
322
|
+
# end
|
323
|
+
|
324
|
+
# describe '#build_access_token' do
|
325
|
+
# describe 'params contain a signed request with an access token' do
|
326
|
+
# before do
|
327
|
+
# @payload = {
|
328
|
+
# 'algorithm' => 'HMAC-SHA256',
|
329
|
+
# 'oauth_token' => 'm4c0d3z'
|
330
|
+
# }
|
331
|
+
# @raw_signed_request = signed_request(@payload, @client_secret)
|
332
|
+
# @request.stub(:params) do
|
333
|
+
# { "signed_request" => @raw_signed_request }
|
334
|
+
# end
|
335
|
+
|
336
|
+
# subject.stub(:callback_url) { '/' }
|
337
|
+
# end
|
338
|
+
|
339
|
+
# it 'returns a new access token from the signed request' do
|
340
|
+
# result = subject.build_access_token
|
341
|
+
# result.should be_an_instance_of(::OAuth2::AccessToken)
|
342
|
+
# result.token.should eq(@payload['oauth_token'])
|
343
|
+
# end
|
344
|
+
# end
|
345
|
+
# end
|
346
|
+
|
347
|
+
# private
|
348
|
+
|
349
|
+
# def signed_request(payload, secret)
|
350
|
+
# encoded_payload = base64_encode_url(MultiJson.encode(payload))
|
351
|
+
# encoded_signature = base64_encode_url(signature(encoded_payload, secret))
|
352
|
+
# [encoded_signature, encoded_payload].join('.')
|
353
|
+
# end
|
354
|
+
|
355
|
+
# def base64_encode_url(value)
|
356
|
+
# Base64.encode64(value).tr('+/', '-_').gsub(/\n/, '')
|
357
|
+
# end
|
358
|
+
|
359
|
+
# def signature(payload, secret, algorithm = OpenSSL::Digest::SHA256.new)
|
360
|
+
# OpenSSL::HMAC.digest(algorithm, secret, payload)
|
361
|
+
# end
|
362
|
+
# end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-devpost
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ross Kaffenberger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Official OmniAuth strategy for Devpost.
|
56
|
+
email:
|
57
|
+
- rosskaff@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/omniauth-devpost.rb
|
69
|
+
- lib/omniauth-devpost/version.rb
|
70
|
+
- lib/omniauth/strategies/devpost.rb
|
71
|
+
- omniauth-devpost.gemspec
|
72
|
+
- spec/omniauth/strategies/devpost_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
homepage: https://github.com/challengepost/omniauth-devpost
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Official OmniAuth strategy for Devpost.
|
97
|
+
test_files:
|
98
|
+
- spec/omniauth/strategies/devpost_spec.rb
|
99
|
+
- spec/spec_helper.rb
|