doorkeeper 4.0.0.rc3 → 4.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of doorkeeper might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CONTRIBUTING.md +2 -0
- data/Gemfile +4 -0
- data/NEWS.md +11 -1
- data/README.md +14 -20
- data/Rakefile +1 -1
- data/app/controllers/doorkeeper/application_metal_controller.rb +1 -1
- data/app/controllers/doorkeeper/tokens_controller.rb +1 -1
- data/app/helpers/doorkeeper/dashboard_helper.rb +13 -11
- data/doorkeeper.gemspec +1 -1
- data/lib/doorkeeper.rb +1 -1
- data/lib/doorkeeper/config.rb +6 -23
- data/lib/doorkeeper/helpers/controller.rb +1 -1
- data/lib/doorkeeper/models/access_grant_mixin.rb +2 -2
- data/lib/doorkeeper/models/access_token_mixin.rb +19 -15
- data/lib/doorkeeper/models/application_mixin.rb +3 -3
- data/lib/doorkeeper/models/concerns/ownership.rb +1 -1
- data/lib/doorkeeper/models/concerns/revocable.rb +1 -1
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -1
- data/lib/doorkeeper/oauth/client_credentials_request.rb +4 -3
- data/lib/doorkeeper/oauth/code_response.rb +13 -14
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +2 -1
- data/lib/doorkeeper/oauth/password_access_token_request.rb +6 -10
- data/lib/doorkeeper/oauth/refresh_token_request.rb +1 -1
- data/lib/doorkeeper/oauth/scopes.rb +2 -2
- data/lib/doorkeeper/oauth/token.rb +3 -4
- data/lib/doorkeeper/oauth/token_response.rb +1 -1
- data/lib/doorkeeper/orm/active_record.rb +0 -16
- data/lib/doorkeeper/orm/active_record/access_token.rb +8 -0
- data/lib/doorkeeper/orm/active_record/application.rb +2 -7
- data/lib/doorkeeper/rails/helpers.rb +1 -1
- data/lib/doorkeeper/rails/routes.rb +2 -1
- data/lib/doorkeeper/rails/routes/mapper.rb +1 -1
- data/lib/doorkeeper/request/password.rb +11 -1
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +1 -1
- data/lib/generators/doorkeeper/templates/migration.rb +2 -2
- data/spec/controllers/protected_resources_controller_spec.rb +10 -10
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +2 -2
- data/spec/dummy/app/controllers/home_controller.rb +1 -1
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +2 -2
- data/spec/dummy/config/environments/test.rb +0 -3
- data/spec/lib/config_spec.rb +1 -1
- data/spec/lib/oauth/authorization_code_request_spec.rb +1 -1
- data/spec/lib/oauth/password_access_token_request_spec.rb +5 -5
- data/spec/lib/oauth/refresh_token_request_spec.rb +14 -8
- data/spec/models/doorkeeper/access_token_spec.rb +18 -1
- data/spec/models/doorkeeper/application_spec.rb +1 -9
- data/spec/requests/flows/password_spec.rb +26 -5
- data/spec/requests/flows/refresh_token_spec.rb +2 -2
- data/spec/spec_helper_integration.rb +3 -0
- data/spec/support/helpers/model_helper.rb +27 -5
- data/spec/support/http_method_shim.rb +24 -0
- data/spec/support/shared/models_shared_examples.rb +1 -1
- metadata +4 -4
- data/lib/generators/doorkeeper/application_scopes_generator.rb +0 -34
- data/lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb +0 -5
@@ -7,9 +7,6 @@ Dummy::Application.configure do
|
|
7
7
|
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
|
-
# Configure static asset server for tests with Cache-Control for performance
|
11
|
-
config.static_cache_control = 'public, max-age=3600'
|
12
|
-
|
13
10
|
# Do not eager load code on boot. This avoids loading your whole application
|
14
11
|
# just for the purpose of running a single test. If you are using a tool that
|
15
12
|
# preloads Rails for running tests, you may have to set it to true.
|
data/spec/lib/config_spec.rb
CHANGED
@@ -149,7 +149,7 @@ describe Doorkeeper, 'configuration' do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
describe '
|
152
|
+
describe 'access_token_methods' do
|
153
153
|
it 'has defaults order' do
|
154
154
|
expect(subject.access_token_methods).to eq([:from_bearer_authorization, :from_access_token_param, :from_bearer_param])
|
155
155
|
end
|
@@ -18,7 +18,7 @@ module Doorkeeper::OAuth
|
|
18
18
|
it 'issues a new token for the client' do
|
19
19
|
expect do
|
20
20
|
subject.authorize
|
21
|
-
end.to change { client.access_tokens.count }.by(1)
|
21
|
+
end.to change { client.reload.access_tokens.count }.by(1)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "issues the token with same grant's scopes" do
|
@@ -11,23 +11,22 @@ module Doorkeeper::OAuth
|
|
11
11
|
custom_access_token_expires_in: ->(_app) { nil }
|
12
12
|
)
|
13
13
|
end
|
14
|
-
let(:credentials) { Client::Credentials.new(client.uid, client.secret) }
|
15
14
|
let(:client) { FactoryGirl.create(:application) }
|
16
15
|
let(:owner) { double :owner, id: 99 }
|
17
16
|
|
18
17
|
subject do
|
19
|
-
PasswordAccessTokenRequest.new(server,
|
18
|
+
PasswordAccessTokenRequest.new(server, client, owner)
|
20
19
|
end
|
21
20
|
|
22
21
|
it 'issues a new token for the client' do
|
23
22
|
expect do
|
24
23
|
subject.authorize
|
25
|
-
end.to change { client.access_tokens.count }.by(1)
|
24
|
+
end.to change { client.reload.access_tokens.count }.by(1)
|
26
25
|
end
|
27
26
|
|
28
27
|
it 'issues a new token without a client' do
|
29
28
|
expect do
|
30
|
-
subject.
|
29
|
+
subject.client = nil
|
31
30
|
subject.authorize
|
32
31
|
end.to change { Doorkeeper::AccessToken.count }.by(1)
|
33
32
|
end
|
@@ -35,6 +34,7 @@ module Doorkeeper::OAuth
|
|
35
34
|
it 'does not issue a new token with an invalid client' do
|
36
35
|
expect do
|
37
36
|
subject.client = nil
|
37
|
+
subject.parameters = { client_id: 'bad_id' }
|
38
38
|
subject.authorize
|
39
39
|
end.to_not change { Doorkeeper::AccessToken.count }
|
40
40
|
|
@@ -48,7 +48,7 @@ module Doorkeeper::OAuth
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'optionally accepts the client' do
|
51
|
-
subject.
|
51
|
+
subject.client = nil
|
52
52
|
expect(subject).to be_valid
|
53
53
|
end
|
54
54
|
|
@@ -2,11 +2,13 @@ require 'spec_helper_integration'
|
|
2
2
|
|
3
3
|
module Doorkeeper::OAuth
|
4
4
|
describe RefreshTokenRequest do
|
5
|
+
before do
|
6
|
+
allow(Doorkeeper::AccessToken).to receive(:refresh_token_revoked_on_use?).and_return(false)
|
7
|
+
end
|
5
8
|
let(:server) do
|
6
9
|
double :server,
|
7
10
|
access_token_expires_in: 2.minutes,
|
8
|
-
custom_access_token_expires_in: -> (_oauth_client) { nil }
|
9
|
-
refresh_token_revoked_on_use?: false
|
11
|
+
custom_access_token_expires_in: -> (_oauth_client) { nil }
|
10
12
|
end
|
11
13
|
let(:refresh_token) do
|
12
14
|
FactoryGirl.create(:access_token, use_refresh_token: true)
|
@@ -17,15 +19,16 @@ module Doorkeeper::OAuth
|
|
17
19
|
subject { RefreshTokenRequest.new server, refresh_token, credentials }
|
18
20
|
|
19
21
|
it 'issues a new token for the client' do
|
20
|
-
expect { subject.authorize }.to change { client.access_tokens.count }.by(1)
|
22
|
+
expect { subject.authorize }.to change { client.reload.access_tokens.count }.by(1)
|
21
23
|
expect(client.reload.access_tokens.last.expires_in).to eq(120)
|
22
24
|
end
|
23
25
|
|
24
26
|
it 'issues a new token for the client with custom expires_in' do
|
25
27
|
server = double :server,
|
26
28
|
access_token_expires_in: 2.minutes,
|
27
|
-
custom_access_token_expires_in: ->(_oauth_client) { 1234 }
|
28
|
-
|
29
|
+
custom_access_token_expires_in: ->(_oauth_client) { 1234 }
|
30
|
+
|
31
|
+
allow(Doorkeeper::AccessToken).to receive(:refresh_token_revoked_on_use?).and_return(false)
|
29
32
|
|
30
33
|
RefreshTokenRequest.new(server, refresh_token, credentials).authorize
|
31
34
|
|
@@ -71,12 +74,15 @@ module Doorkeeper::OAuth
|
|
71
74
|
let(:server) do
|
72
75
|
double :server,
|
73
76
|
access_token_expires_in: 2.minutes,
|
74
|
-
custom_access_token_expires_in: ->(_oauth_client) { 1234 }
|
75
|
-
|
77
|
+
custom_access_token_expires_in: ->(_oauth_client) { 1234 }
|
78
|
+
end
|
79
|
+
|
80
|
+
before do
|
81
|
+
allow(Doorkeeper::AccessToken).to receive(:refresh_token_revoked_on_use?).and_return(true)
|
76
82
|
end
|
77
83
|
|
78
84
|
it 'issues a new token for the client' do
|
79
|
-
expect { subject.authorize }.to change { client.access_tokens.count }.by(1)
|
85
|
+
expect { subject.authorize }.to change { client.reload.access_tokens.count }.by(1)
|
80
86
|
end
|
81
87
|
|
82
88
|
it 'does not revoke the previous token' do
|
@@ -106,6 +106,23 @@ module Doorkeeper
|
|
106
106
|
expect(token.token).to eq 'custom_generator_token_7200'
|
107
107
|
end
|
108
108
|
|
109
|
+
it 'allows the custom generator to access the created time' do
|
110
|
+
module CustomGeneratorArgs
|
111
|
+
def self.generate(opts = {})
|
112
|
+
"custom_generator_token_#{opts[:created_at].to_i}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
Doorkeeper.configure do
|
117
|
+
orm DOORKEEPER_ORM
|
118
|
+
access_token_generator "Doorkeeper::CustomGeneratorArgs"
|
119
|
+
end
|
120
|
+
|
121
|
+
token = FactoryGirl.create :access_token
|
122
|
+
created_at = token.created_at
|
123
|
+
expect(token.token).to eq "custom_generator_token_#{created_at.to_i}"
|
124
|
+
end
|
125
|
+
|
109
126
|
it 'raises an error if the custom object does not support generate' do
|
110
127
|
module NoGenerate
|
111
128
|
end
|
@@ -154,7 +171,7 @@ module Doorkeeper
|
|
154
171
|
expect do
|
155
172
|
token2.refresh_token = token1.refresh_token
|
156
173
|
token2.save(validate: false)
|
157
|
-
end.to raise_error(
|
174
|
+
end.to raise_error(uniqueness_error)
|
158
175
|
end
|
159
176
|
end
|
160
177
|
|
@@ -90,7 +90,7 @@ module Doorkeeper
|
|
90
90
|
app1 = FactoryGirl.create(:application)
|
91
91
|
app2 = FactoryGirl.create(:application)
|
92
92
|
app2.uid = app1.uid
|
93
|
-
expect { app2.save!(validate: false) }.to raise_error(
|
93
|
+
expect { app2.save!(validate: false) }.to raise_error(uniqueness_error)
|
94
94
|
end
|
95
95
|
|
96
96
|
it 'generate secret on create' do
|
@@ -166,14 +166,6 @@ module Doorkeeper
|
|
166
166
|
FactoryGirl.create(:access_token, resource_owner_id: resource_owner.id, application: application)
|
167
167
|
expect(Application.authorized_for(resource_owner)).to eq([application])
|
168
168
|
end
|
169
|
-
|
170
|
-
it 'should fail to mass assign a new application', if: ::Rails::VERSION::MAJOR < 4 do
|
171
|
-
mass_assign = { name: 'Something',
|
172
|
-
redirect_uri: 'http://somewhere.com/something',
|
173
|
-
uid: 123,
|
174
|
-
secret: 'something' }
|
175
|
-
expect(Application.create(mass_assign).uid).not_to eq(123)
|
176
|
-
end
|
177
169
|
end
|
178
170
|
|
179
171
|
describe :authenticate do
|
@@ -24,14 +24,26 @@ describe 'Resource Owner Password Credentials Flow' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'with valid user credentials' do
|
27
|
-
it 'should issue new token' do
|
27
|
+
it 'should issue new token with confidential client' do
|
28
28
|
expect do
|
29
29
|
post password_token_endpoint_url(client: @client, resource_owner: @resource_owner)
|
30
30
|
end.to change { Doorkeeper::AccessToken.count }.by(1)
|
31
31
|
|
32
32
|
token = Doorkeeper::AccessToken.first
|
33
33
|
|
34
|
-
|
34
|
+
expect(token.application_id).to eq @client.id
|
35
|
+
should_have_json 'access_token', token.token
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should issue new token with public client (only client_id present)' do
|
39
|
+
expect do
|
40
|
+
post password_token_endpoint_url(client_id: @client.uid, resource_owner: @resource_owner)
|
41
|
+
end.to change { Doorkeeper::AccessToken.count }.by(1)
|
42
|
+
|
43
|
+
token = Doorkeeper::AccessToken.first
|
44
|
+
|
45
|
+
expect(token.application_id).to eq @client.id
|
46
|
+
should_have_json 'access_token', token.token
|
35
47
|
end
|
36
48
|
|
37
49
|
it 'should issue new token without client credentials' do
|
@@ -41,7 +53,8 @@ describe 'Resource Owner Password Credentials Flow' do
|
|
41
53
|
|
42
54
|
token = Doorkeeper::AccessToken.first
|
43
55
|
|
44
|
-
|
56
|
+
expect(token.application_id).to be_nil
|
57
|
+
should_have_json 'access_token', token.token
|
45
58
|
end
|
46
59
|
|
47
60
|
it 'should issue a refresh token if enabled' do
|
@@ -51,7 +64,7 @@ describe 'Resource Owner Password Credentials Flow' do
|
|
51
64
|
|
52
65
|
token = Doorkeeper::AccessToken.first
|
53
66
|
|
54
|
-
should_have_json 'refresh_token',
|
67
|
+
should_have_json 'refresh_token', token.refresh_token
|
55
68
|
end
|
56
69
|
|
57
70
|
it 'should return the same token if it is still accessible' do
|
@@ -82,7 +95,7 @@ describe 'Resource Owner Password Credentials Flow' do
|
|
82
95
|
end
|
83
96
|
end
|
84
97
|
|
85
|
-
context 'with invalid client credentials' do
|
98
|
+
context 'with invalid confidential client credentials' do
|
86
99
|
it 'should not issue new token with bad client credentials' do
|
87
100
|
expect do
|
88
101
|
post password_token_endpoint_url(client_id: @client.uid,
|
@@ -91,4 +104,12 @@ describe 'Resource Owner Password Credentials Flow' do
|
|
91
104
|
end.to_not change { Doorkeeper::AccessToken.count }
|
92
105
|
end
|
93
106
|
end
|
107
|
+
|
108
|
+
context 'with invalid public client id' do
|
109
|
+
it 'should not issue new token with bad client id' do
|
110
|
+
expect do
|
111
|
+
post password_token_endpoint_url(client_id: 'bad_id', resource_owner: @resource_owner)
|
112
|
+
end.to_not change { Doorkeeper::AccessToken.count }
|
113
|
+
end
|
114
|
+
end
|
94
115
|
end
|
@@ -70,7 +70,7 @@ describe 'Refresh Token Flow' do
|
|
70
70
|
|
71
71
|
context "refresh_token revoked on refresh_token request" do
|
72
72
|
before do
|
73
|
-
|
73
|
+
allow(Doorkeeper::AccessToken).to receive(:refresh_token_revoked_on_use?).and_return(false)
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'client request a token with refresh token' do
|
@@ -152,7 +152,7 @@ describe 'Refresh Token Flow' do
|
|
152
152
|
|
153
153
|
context "refresh_token revoked on refresh_token request" do
|
154
154
|
before do
|
155
|
-
|
155
|
+
allow(Doorkeeper::AccessToken).to receive(:refresh_token_revoked_on_use?).and_return(false)
|
156
156
|
end
|
157
157
|
|
158
158
|
it 'client request a token after creating another token with the same user' do
|
@@ -35,6 +35,9 @@ ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')
|
|
35
35
|
|
36
36
|
Dir["#{File.dirname(__FILE__)}/support/{dependencies,helpers,shared}/*.rb"].each { |f| require f }
|
37
37
|
|
38
|
+
# Remove after dropping support of Rails 4.2
|
39
|
+
require "#{File.dirname(__FILE__)}/support/http_method_shim.rb"
|
40
|
+
|
38
41
|
RSpec.configure do |config|
|
39
42
|
config.infer_spec_type_from_file_location!
|
40
43
|
config.mock_with :rspec
|
@@ -13,14 +13,20 @@ module ModelHelper
|
|
13
13
|
|
14
14
|
def access_grant_should_exist_for(client, resource_owner)
|
15
15
|
grant = Doorkeeper::AccessGrant.first
|
16
|
-
|
17
|
-
grant.
|
16
|
+
|
17
|
+
expect(grant.application).to have_attributes(id: client.id).
|
18
|
+
and(be_instance_of(Doorkeeper::Application))
|
19
|
+
|
20
|
+
expect(grant.resource_owner_id).to eq(resource_owner.id)
|
18
21
|
end
|
19
22
|
|
20
23
|
def access_token_should_exist_for(client, resource_owner)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
token = Doorkeeper::AccessToken.first
|
25
|
+
|
26
|
+
expect(token.application).to have_attributes(id: client.id).
|
27
|
+
and(be_instance_of(Doorkeeper::Application))
|
28
|
+
|
29
|
+
expect(token.resource_owner_id).to eq(resource_owner.id)
|
24
30
|
end
|
25
31
|
|
26
32
|
def access_grant_should_not_exist
|
@@ -40,6 +46,22 @@ module ModelHelper
|
|
40
46
|
grant = Doorkeeper::AccessToken.last
|
41
47
|
expect(grant.scopes).to eq(Doorkeeper::OAuth::Scopes.from_array(args))
|
42
48
|
end
|
49
|
+
|
50
|
+
def uniqueness_error
|
51
|
+
case DOORKEEPER_ORM
|
52
|
+
when :active_record
|
53
|
+
ActiveRecord::RecordNotUnique
|
54
|
+
when :sequel
|
55
|
+
error_classes = [Sequel::UniqueConstraintViolation, Sequel::ValidationFailed]
|
56
|
+
proc { |error| expect(error.class).to be_in(error_classes) }
|
57
|
+
when :mongo_mapper
|
58
|
+
MongoMapper::DocumentNotValid
|
59
|
+
when /mongoid/
|
60
|
+
Mongoid::Errors::Validations
|
61
|
+
else
|
62
|
+
raise "'#{DOORKEEPER_ORM}' ORM is not supported!"
|
63
|
+
end
|
64
|
+
end
|
43
65
|
end
|
44
66
|
|
45
67
|
RSpec.configuration.send :include, ModelHelper
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Rails 5 deprecates calling HTTP action methods with positional arguments
|
2
|
+
# in favor of keyword arguments. However, the keyword argument form is only
|
3
|
+
# supported in Rails 5+. Since we support back to 4, we need some sort of shim
|
4
|
+
# to avoid super noisy deprecations when running tests.
|
5
|
+
module HTTPMethodShim
|
6
|
+
def get(path, params = nil, headers = nil)
|
7
|
+
super(path, params: params, headers: headers)
|
8
|
+
end
|
9
|
+
|
10
|
+
def post(path, params = nil, headers = nil)
|
11
|
+
super(path, params: params, headers: headers)
|
12
|
+
end
|
13
|
+
|
14
|
+
def put(path, params = nil, headers = nil)
|
15
|
+
super(path, params: params, headers: headers)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if ::Rails::VERSION::MAJOR >= 5
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.include HTTPMethodShim, type: :controller
|
22
|
+
config.include HTTPMethodShim, type: :request
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Elias Philipp
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -230,14 +230,12 @@ files:
|
|
230
230
|
- lib/doorkeeper/validations.rb
|
231
231
|
- lib/doorkeeper/version.rb
|
232
232
|
- lib/generators/doorkeeper/application_owner_generator.rb
|
233
|
-
- lib/generators/doorkeeper/application_scopes_generator.rb
|
234
233
|
- lib/generators/doorkeeper/install_generator.rb
|
235
234
|
- lib/generators/doorkeeper/migration_generator.rb
|
236
235
|
- lib/generators/doorkeeper/previous_refresh_token_generator.rb
|
237
236
|
- lib/generators/doorkeeper/templates/README
|
238
237
|
- lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb
|
239
238
|
- lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb
|
240
|
-
- lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb
|
241
239
|
- lib/generators/doorkeeper/templates/initializer.rb
|
242
240
|
- lib/generators/doorkeeper/templates/migration.rb
|
243
241
|
- lib/generators/doorkeeper/views_generator.rb
|
@@ -354,6 +352,7 @@ files:
|
|
354
352
|
- spec/support/helpers/model_helper.rb
|
355
353
|
- spec/support/helpers/request_spec_helper.rb
|
356
354
|
- spec/support/helpers/url_helper.rb
|
355
|
+
- spec/support/http_method_shim.rb
|
357
356
|
- spec/support/orm/active_record.rb
|
358
357
|
- spec/support/shared/controllers_shared_context.rb
|
359
358
|
- spec/support/shared/models_shared_examples.rb
|
@@ -497,6 +496,7 @@ test_files:
|
|
497
496
|
- spec/support/helpers/model_helper.rb
|
498
497
|
- spec/support/helpers/request_spec_helper.rb
|
499
498
|
- spec/support/helpers/url_helper.rb
|
499
|
+
- spec/support/http_method_shim.rb
|
500
500
|
- spec/support/orm/active_record.rb
|
501
501
|
- spec/support/shared/controllers_shared_context.rb
|
502
502
|
- spec/support/shared/models_shared_examples.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'rails/generators/active_record'
|
2
|
-
|
3
|
-
class Doorkeeper::ApplicationScopesGenerator < Rails::Generators::Base
|
4
|
-
include Rails::Generators::Migration
|
5
|
-
source_root File.expand_path('../templates', __FILE__)
|
6
|
-
desc 'Copies ActiveRecord migrations to handle upgrade to doorkeeper 2'
|
7
|
-
|
8
|
-
def self.next_migration_number(path)
|
9
|
-
ActiveRecord::Generators::Base.next_migration_number(path)
|
10
|
-
end
|
11
|
-
|
12
|
-
def application_scopes
|
13
|
-
if oauth_applications_exists? && !scopes_column_exists?
|
14
|
-
migration_template(
|
15
|
-
'add_scopes_to_oauth_applications.rb',
|
16
|
-
'db/migrate/add_scopes_to_oauth_applications.rb'
|
17
|
-
)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def scopes_column_exists?
|
24
|
-
ActiveRecord::Base.connection.column_exists?(
|
25
|
-
:oauth_applications,
|
26
|
-
:scopes
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Might be running this before install
|
31
|
-
def oauth_applications_exists?
|
32
|
-
ActiveRecord::Base.connection.table_exists? :oauth_applications
|
33
|
-
end
|
34
|
-
end
|