omniauth-redbooth 1.0.0 → 1.0.1.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +2 -0
- data/CHANGELOG.md +38 -0
- data/lib/omniauth/strategies/redbooth.rb +14 -42
- data/lib/omniauth-redbooth/version.rb +1 -1
- data/omniauth-redbooth.gemspec +15 -2
- data/spec/omniauth/strategies/redbooth_spec.rb +82 -66
- data/spec/spec_helper.rb +1 -0
- metadata +45 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf62604b882c484c140a9251fe42e6d757e2c1ee
|
4
|
+
data.tar.gz: a02d5e72917911eac03a8adc6298247b625dcad8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cd0585183d94ed193857eb67f9c7b565399a4e1c95292cb4b32d3cace5bc9f0b94bc1036edef93690c5dea25a743fe45a167353d00bbb94b80400bcb7781b22
|
7
|
+
data.tar.gz: 2c8a2086570a5ec790a089bb80a36c8d429de9f3a894026f8eaea1c071e199e3be46378481db9add55f19f049604e5be0bf0fc89e9d28e2eeb9132c8293af797
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [Unreleased]
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Test on ruby 2.1 and 2.2 too.
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- cleaned up the code a bit.
|
12
|
+
- cleaned up specs a bit and updated to RSpec 3.
|
13
|
+
- Use debugger gem on ruby 1.9.x or less and byebug on 2.x
|
14
|
+
|
15
|
+
### Deprecated
|
16
|
+
### Removed
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- changed omniauth-oauth2 dependency to 1.x up to 1.3.1 since [this change][1]
|
21
|
+
in omniauth-oauth2 1.4 breaks the strategy.
|
22
|
+
- Stop dealing with SCRIPT_NAME since it was breaking stuff
|
23
|
+
|
24
|
+
### Security
|
25
|
+
|
26
|
+
## [1.0.0] - 2015-11-18
|
27
|
+
|
28
|
+
### Changed
|
29
|
+
- omniauth-oauth2 dependency to ~> 1.2
|
30
|
+
|
31
|
+
## Previous changes
|
32
|
+
|
33
|
+
Undocumented. Please review git commits history.
|
34
|
+
|
35
|
+
[Unreleased]: https://github.com/redbooth/omniauth-redbooth/compare/v1.0.1...HEAD
|
36
|
+
[1.0.0]: https://github.com/redbooth/omniauth-redbooth/compare/v0.3.2...v1.0.0
|
37
|
+
|
38
|
+
[1]: https://github.com/intridea/omniauth-oauth2/issues/81
|
@@ -2,62 +2,34 @@ require 'omniauth-oauth2'
|
|
2
2
|
|
3
3
|
module OmniAuth
|
4
4
|
module Strategies
|
5
|
+
# @see https://redbooth.com/api/api-docs/
|
5
6
|
class Redbooth < OmniAuth::Strategies::OAuth2
|
6
|
-
|
7
|
-
option :name, 'redbooth'
|
7
|
+
REDBOOTH_URL = 'https://redbooth.com'.freeze
|
8
8
|
|
9
|
+
option :name, 'redbooth'
|
9
10
|
option :provider_ignores_state, true
|
11
|
+
option :client_options,
|
12
|
+
site: "#{REDBOOTH_URL}/api/3",
|
13
|
+
authorize_url: "#{REDBOOTH_URL}/oauth2/authorize",
|
14
|
+
token_url: "#{REDBOOTH_URL}/oauth2/token"
|
15
|
+
option :authorize_params, response_type: 'code'
|
10
16
|
|
11
|
-
|
12
|
-
# initializing your consumer from the OAuth gem.
|
13
|
-
option :client_options, {
|
14
|
-
site: 'https://redbooth.com/api/3',
|
15
|
-
authorize_url: 'https://redbooth.com/oauth2/authorize',
|
16
|
-
token_url: 'https://redbooth.com/oauth2/token'
|
17
|
-
}
|
18
|
-
|
19
|
-
option :authorize_params, {
|
20
|
-
response_type: 'code'
|
21
|
-
}
|
22
|
-
|
23
|
-
# These are called after authentication has succeeded. If
|
24
|
-
# possible, you should try to set the UID without making
|
25
|
-
# additional calls (if the user id is returned with the token
|
26
|
-
# or as a URI parameter). This may not be possible with all
|
27
|
-
# providers.
|
28
|
-
uid{ raw_info['id'] }
|
17
|
+
uid { raw_info['id'] }
|
29
18
|
|
30
19
|
info do
|
31
20
|
{
|
32
|
-
:
|
33
|
-
:
|
21
|
+
name: "#{raw_info['first_name']} #{raw_info['last_name']}",
|
22
|
+
email: raw_info['email']
|
34
23
|
}
|
35
24
|
end
|
36
25
|
|
37
26
|
extra do
|
38
|
-
{
|
39
|
-
'raw_info' => raw_info
|
40
|
-
}
|
27
|
+
{ 'raw_info' => raw_info }
|
41
28
|
end
|
42
29
|
|
43
30
|
def raw_info
|
44
|
-
@raw_info ||=
|
45
|
-
|
46
|
-
|
47
|
-
# Override OmniAuth's `request` method and make sure that
|
48
|
-
# `request.url` is properly defined when `PATH_INFO` doesn't
|
49
|
-
# start with a slash.
|
50
|
-
#
|
51
|
-
# This is needed because when mounting an engine on the root,
|
52
|
-
# the `path_prefix` cannot start with a slash. Because of that
|
53
|
-
# `request.url` becomes host:portpath (notice the lack of a slash).
|
54
|
-
#
|
55
|
-
# This code sets the `SCRIPT_NAME` environment variable to a slash
|
56
|
-
# if it's empty (meaning that it's the root) and then calls
|
57
|
-
# the parent code which instantiates a request.
|
58
|
-
def request
|
59
|
-
@env['SCRIPT_NAME'] = '/' if @env['SCRIPT_NAME'] == ''
|
60
|
-
super
|
31
|
+
@raw_info ||=
|
32
|
+
access_token.get("#{options[:client_options][:site]}/me").parsed
|
61
33
|
end
|
62
34
|
end
|
63
35
|
end
|
data/omniauth-redbooth.gemspec
CHANGED
@@ -13,8 +13,15 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.require_paths = ['lib']
|
14
14
|
gem.version = OmniAuth::Redbooth::VERSION
|
15
15
|
|
16
|
-
|
17
|
-
gem
|
16
|
+
# Using 1.3.x branch since 1.4 added a non backward compatible change which
|
17
|
+
# prevents this gem from working.
|
18
|
+
#
|
19
|
+
# The issue is documented here:
|
20
|
+
# https://github.com/intridea/omniauth-oauth2/issues/81
|
21
|
+
gem.add_dependency 'omniauth-oauth2', '>= 1.0', '<= 1.3.1'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
gem.add_development_dependency 'rspec-its', '~> 1.2'
|
18
25
|
gem.add_development_dependency 'rack-test', '~> 0.6'
|
19
26
|
gem.add_development_dependency 'simplecov', '~> 0.10'
|
20
27
|
gem.add_development_dependency 'webmock', '~> 1.22'
|
@@ -25,4 +32,10 @@ Gem::Specification.new do |gem|
|
|
25
32
|
gem.add_development_dependency 'growl', '~> 1.0'
|
26
33
|
gem.add_development_dependency 'sinatra', '~> 1.4'
|
27
34
|
gem.add_development_dependency 'rake', '~> 10.4'
|
35
|
+
|
36
|
+
if Gem.ruby_version < Gem::Version.new('2.0.0')
|
37
|
+
gem.add_development_dependency 'debugger'
|
38
|
+
else
|
39
|
+
gem.add_development_dependency 'byebug'
|
40
|
+
end
|
28
41
|
end
|
@@ -1,102 +1,118 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe OmniAuth::Strategies::Redbooth do
|
3
|
+
RSpec.describe OmniAuth::Strategies::Redbooth do
|
4
4
|
let(:app) do
|
5
|
-
|
6
|
-
[200, {}, ["Hello."]]
|
7
|
-
end
|
5
|
+
->(_env) { [200, {}, ['Hello.']] }
|
8
6
|
end
|
9
|
-
let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
|
10
|
-
let(:fresh_strategy){ Class.new(OmniAuth::Strategies::Redbooth) }
|
11
7
|
|
12
|
-
let(:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
end
|
18
|
-
end
|
8
|
+
let(:app_id) { '_app_id_' }
|
9
|
+
let(:app_secret) { '_app_secret_' }
|
10
|
+
let(:request) { double(params: {}, cookies: {}, env: {}) }
|
11
|
+
let(:options) { Hash.new }
|
19
12
|
|
20
|
-
|
13
|
+
let(:strategy) { described_class.new(app, app_id, app_secret, options) }
|
21
14
|
|
22
|
-
before
|
23
|
-
OmniAuth.config.test_mode = true
|
24
|
-
end
|
15
|
+
before { allow(strategy).to receive(:request) { request } }
|
25
16
|
|
26
|
-
|
17
|
+
around do |example|
|
18
|
+
OmniAuth.config.test_mode = true
|
19
|
+
example.run
|
27
20
|
OmniAuth.config.test_mode = false
|
28
21
|
end
|
29
22
|
|
30
|
-
describe '#
|
23
|
+
describe '#client' do
|
24
|
+
let(:example_site) { 'https://example.com' }
|
25
|
+
subject { strategy.client }
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
end
|
27
|
+
context 'with the default config' do
|
28
|
+
its(:site) { is_expected.to eq('https://redbooth.com/api/3') }
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
end
|
30
|
+
describe 'the client options' do
|
31
|
+
subject { strategy.client.options }
|
39
32
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
its([:authorize_url]) do
|
34
|
+
is_expected.to eq('https://redbooth.com/oauth2/authorize')
|
35
|
+
end
|
36
|
+
its([:token_url]) do
|
37
|
+
is_expected.to eq('https://redbooth.com/oauth2/token')
|
38
|
+
end
|
44
39
|
end
|
40
|
+
end
|
45
41
|
|
46
|
-
|
47
|
-
|
48
|
-
subject.client.options[:authorize_url].should == 'https://example.com'
|
49
|
-
end
|
42
|
+
context 'changing default :site' do
|
43
|
+
let(:options) { { client_options: { site: example_site } } }
|
50
44
|
|
51
|
-
|
52
|
-
@options = {:client_options => {'token_url' => 'https://example.com'}}
|
53
|
-
subject.client.options[:token_url].should == 'https://example.com'
|
54
|
-
end
|
45
|
+
its(:site) { is_expected.to eq(example_site) }
|
55
46
|
end
|
56
|
-
end
|
57
47
|
|
58
|
-
|
48
|
+
context 'changing default :authorize_url' do
|
49
|
+
subject { strategy.client.options }
|
50
|
+
let(:options) { { client_options: { authorize_url: example_site } } }
|
59
51
|
|
60
|
-
|
61
|
-
@options = {:authorize_params => {:request_visible_actions => 'something', :foo => 'bar', :baz => 'zip'}, :bad => 'not_included'}
|
62
|
-
subject.authorize_params['request_visible_actions'].should eq('something')
|
63
|
-
subject.authorize_params['foo'].should eq('bar')
|
64
|
-
subject.authorize_params['baz'].should eq('zip')
|
65
|
-
subject.authorize_params['bad'].should eq(nil)
|
52
|
+
its([:authorize_url]) { is_expected.to eq(example_site) }
|
66
53
|
end
|
67
54
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
55
|
+
context 'changing default :token_url' do
|
56
|
+
subject { strategy.client.options }
|
57
|
+
let(:options) { { client_options: { token_url: example_site } } }
|
72
58
|
|
73
|
-
|
74
|
-
expect(subject.authorize_params).to include('state')
|
75
|
-
subject.session['omniauth.state'].should_not be_empty
|
59
|
+
its([:token_url]) { is_expected.to eq(example_site) }
|
76
60
|
end
|
77
61
|
end
|
78
62
|
|
79
|
-
describe '
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
63
|
+
describe ':authorize_params' do
|
64
|
+
let(:options) do
|
65
|
+
{
|
66
|
+
authorize_params: {
|
67
|
+
request_visible_actions: 'something',
|
68
|
+
foo: 'bar',
|
69
|
+
baz: 'zip'
|
70
|
+
},
|
71
|
+
bad: 'not_included'
|
72
|
+
}
|
84
73
|
end
|
74
|
+
|
75
|
+
subject { strategy.authorize_params }
|
76
|
+
|
77
|
+
its([:request_visible_actions]) { is_expected.to eq('something') }
|
78
|
+
its([:foo]) { is_expected.to eq('bar') }
|
79
|
+
its([:baz]) { is_expected.to eq('zip') }
|
80
|
+
its([:bad]) { is_expected.to be_nil }
|
81
|
+
its([:response_type]) { is_expected.to eq('code') }
|
82
|
+
it { is_expected.to include(:state) }
|
85
83
|
end
|
86
84
|
|
87
|
-
describe
|
88
|
-
|
89
|
-
|
90
|
-
subject.token_params['scope'].should eq('bar')
|
91
|
-
subject.token_params['foo'].should eq('baz')
|
92
|
-
subject.token_params['bad'].should eq(nil)
|
85
|
+
describe ':token_params' do
|
86
|
+
let(:options) do
|
87
|
+
{ token_params: { foo: 'bar', baz: 'zip' } }
|
93
88
|
end
|
89
|
+
|
90
|
+
subject { strategy.token_params }
|
91
|
+
|
92
|
+
its([:foo]) { is_expected.to eq('bar') }
|
93
|
+
its([:baz]) { is_expected.to eq('zip') }
|
94
94
|
end
|
95
95
|
|
96
|
-
describe '
|
97
|
-
|
98
|
-
|
96
|
+
describe ':token_options' do
|
97
|
+
let(:options) do
|
98
|
+
{
|
99
|
+
token_options: [:scope, :foo],
|
100
|
+
scope: 'bar',
|
101
|
+
foo: 'baz',
|
102
|
+
bad: 'not_included'
|
103
|
+
}
|
99
104
|
end
|
105
|
+
|
106
|
+
subject { strategy.token_params }
|
107
|
+
|
108
|
+
its([:scope]) { is_expected.to eq('bar') }
|
109
|
+
its([:foo]) { is_expected.to eq('baz') }
|
110
|
+
its([:bad]) { is_expected.to be_nil }
|
100
111
|
end
|
101
112
|
|
113
|
+
describe '#callback_path' do
|
114
|
+
subject { strategy.callback_path }
|
115
|
+
|
116
|
+
it { is_expected.to eq('/auth/redbooth/callback') }
|
117
|
+
end
|
102
118
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-redbooth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andres Bravo
|
@@ -10,36 +10,56 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-11-
|
13
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: omniauth-oauth2
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
21
|
+
version: '1.0'
|
22
|
+
- - "<="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.3.1
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
requirements:
|
26
|
-
- - "
|
29
|
+
- - ">="
|
27
30
|
- !ruby/object:Gem::Version
|
28
|
-
version: '1.
|
31
|
+
version: '1.0'
|
32
|
+
- - "<="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.3.1
|
29
35
|
- !ruby/object:Gem::Dependency
|
30
36
|
name: rspec
|
31
37
|
requirement: !ruby/object:Gem::Requirement
|
32
38
|
requirements:
|
33
39
|
- - "~>"
|
34
40
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
41
|
+
version: '3.0'
|
42
|
+
type: :development
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec-its
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.2'
|
36
56
|
type: :development
|
37
57
|
prerelease: false
|
38
58
|
version_requirements: !ruby/object:Gem::Requirement
|
39
59
|
requirements:
|
40
60
|
- - "~>"
|
41
61
|
- !ruby/object:Gem::Version
|
42
|
-
version: '2
|
62
|
+
version: '1.2'
|
43
63
|
- !ruby/object:Gem::Dependency
|
44
64
|
name: rack-test
|
45
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,6 +200,20 @@ dependencies:
|
|
180
200
|
- - "~>"
|
181
201
|
- !ruby/object:Gem::Version
|
182
202
|
version: '10.4'
|
203
|
+
- !ruby/object:Gem::Dependency
|
204
|
+
name: byebug
|
205
|
+
requirement: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
type: :development
|
211
|
+
prerelease: false
|
212
|
+
version_requirements: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
183
217
|
description: Official OmniAuth strategy for Redbooth.com.
|
184
218
|
email:
|
185
219
|
- support@redbooth.com
|
@@ -190,6 +224,7 @@ files:
|
|
190
224
|
- ".gitignore"
|
191
225
|
- ".rspec"
|
192
226
|
- ".travis.yml"
|
227
|
+
- CHANGELOG.md
|
193
228
|
- Gemfile
|
194
229
|
- Guardfile
|
195
230
|
- LICENSE
|
@@ -216,9 +251,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
251
|
version: '0'
|
217
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
253
|
requirements:
|
219
|
-
- - "
|
254
|
+
- - ">"
|
220
255
|
- !ruby/object:Gem::Version
|
221
|
-
version:
|
256
|
+
version: 1.3.1
|
222
257
|
requirements: []
|
223
258
|
rubyforge_project:
|
224
259
|
rubygems_version: 2.4.5.1
|