doorkeeper 1.4.2 → 2.0.0.alpha1

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.

Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +3 -0
  3. data/CHANGELOG.md +18 -11
  4. data/Gemfile +7 -7
  5. data/README.md +20 -41
  6. data/app/controllers/doorkeeper/application_controller.rb +1 -7
  7. data/app/controllers/doorkeeper/applications_controller.rb +4 -5
  8. data/app/controllers/doorkeeper/tokens_controller.rb +2 -2
  9. data/app/helpers/doorkeeper/{form_errors_helper.rb → dashboard_helper.rb} +5 -1
  10. data/app/views/doorkeeper/applications/_delete_form.html.erb +1 -1
  11. data/app/views/doorkeeper/applications/_form.html.erb +1 -1
  12. data/app/views/doorkeeper/applications/index.html.erb +1 -1
  13. data/config/locales/en.yml +3 -3
  14. data/lib/doorkeeper.rb +15 -6
  15. data/lib/doorkeeper/config.rb +18 -24
  16. data/lib/doorkeeper/engine.rb +1 -6
  17. data/lib/doorkeeper/generators/doorkeeper/mongo_mapper/indexes_generator.rb +12 -0
  18. data/lib/{generators/doorkeeper → doorkeeper/generators/doorkeeper/mongo_mapper}/templates/indexes.rb +0 -0
  19. data/lib/doorkeeper/models/access_grant_mixin.rb +36 -0
  20. data/lib/doorkeeper/models/access_token_mixin.rb +121 -0
  21. data/lib/doorkeeper/models/application_mixin.rb +42 -0
  22. data/lib/doorkeeper/models/{accessible.rb → concerns/accessible.rb} +0 -0
  23. data/lib/doorkeeper/models/{expirable.rb → concerns/expirable.rb} +6 -5
  24. data/lib/doorkeeper/models/{ownership.rb → concerns/ownership.rb} +7 -7
  25. data/lib/doorkeeper/models/{revocable.rb → concerns/revocable.rb} +1 -1
  26. data/lib/doorkeeper/models/concerns/scopes.rb +17 -0
  27. data/lib/doorkeeper/oauth/authorization/token.rb +6 -6
  28. data/lib/doorkeeper/oauth/client.rb +1 -1
  29. data/lib/doorkeeper/oauth/password_access_token_request.rb +3 -3
  30. data/lib/doorkeeper/oauth/refresh_token_request.rb +6 -6
  31. data/lib/doorkeeper/oauth/token.rb +3 -2
  32. data/lib/doorkeeper/orm/active_record.rb +17 -0
  33. data/lib/doorkeeper/orm/active_record/access_grant.rb +7 -0
  34. data/lib/doorkeeper/orm/active_record/access_token.rb +20 -0
  35. data/lib/doorkeeper/{models → orm}/active_record/application.rb +1 -3
  36. data/lib/doorkeeper/orm/mongo_mapper.rb +11 -0
  37. data/lib/doorkeeper/{models → orm}/mongo_mapper/access_grant.rb +4 -5
  38. data/lib/doorkeeper/{models → orm}/mongo_mapper/access_token.rb +5 -8
  39. data/lib/doorkeeper/{models → orm}/mongo_mapper/application.rb +3 -4
  40. data/lib/doorkeeper/orm/mongoid2.rb +11 -0
  41. data/lib/doorkeeper/{models → orm}/mongoid2/access_grant.rb +5 -3
  42. data/lib/doorkeeper/{models → orm}/mongoid2/access_token.rb +10 -13
  43. data/lib/doorkeeper/{models → orm}/mongoid2/application.rb +2 -0
  44. data/lib/doorkeeper/orm/mongoid2/concerns/scopes.rb +30 -0
  45. data/lib/doorkeeper/orm/mongoid3.rb +11 -0
  46. data/lib/doorkeeper/orm/mongoid3/access_grant.rb +22 -0
  47. data/lib/doorkeeper/orm/mongoid3/access_token.rb +36 -0
  48. data/lib/doorkeeper/{models/mongoid3_4 → orm/mongoid3}/application.rb +2 -0
  49. data/lib/doorkeeper/orm/mongoid3/concerns/scopes.rb +30 -0
  50. data/lib/doorkeeper/orm/mongoid4.rb +11 -0
  51. data/lib/doorkeeper/orm/mongoid4/access_grant.rb +22 -0
  52. data/lib/doorkeeper/orm/mongoid4/access_token.rb +36 -0
  53. data/lib/doorkeeper/orm/mongoid4/application.rb +24 -0
  54. data/lib/doorkeeper/orm/mongoid4/concerns/scopes.rb +17 -0
  55. data/lib/doorkeeper/rails/helpers.rb +63 -0
  56. data/lib/doorkeeper/rails/routes.rb +1 -12
  57. data/lib/doorkeeper/request/code.rb +0 -1
  58. data/lib/doorkeeper/request/token.rb +0 -1
  59. data/lib/doorkeeper/server.rb +1 -1
  60. data/lib/doorkeeper/version.rb +1 -1
  61. data/lib/generators/doorkeeper/templates/initializer.rb +2 -1
  62. data/spec/controllers/applications_controller_spec.rb +4 -4
  63. data/spec/controllers/protected_resources_controller_spec.rb +25 -175
  64. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +2 -2
  65. data/spec/dummy/app/controllers/metal_controller.rb +2 -2
  66. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +2 -2
  67. data/spec/dummy/config/application.rb +2 -0
  68. data/spec/lib/config_spec.rb +16 -10
  69. data/spec/lib/models/expirable_spec.rb +1 -1
  70. data/spec/lib/models/revocable_spec.rb +8 -3
  71. data/spec/lib/models/scopes_spec.rb +3 -3
  72. data/spec/lib/oauth/password_access_token_request_spec.rb +1 -1
  73. data/spec/lib/oauth/token_request_spec.rb +28 -1
  74. data/spec/lib/oauth/token_spec.rb +1 -1
  75. data/spec/models/doorkeeper/application_spec.rb +1 -1
  76. data/spec/requests/applications/applications_request_spec.rb +4 -4
  77. data/spec/requests/endpoints/authorization_spec.rb +0 -23
  78. data/spec/requests/flows/implicit_grant_spec.rb +32 -0
  79. data/spec/support/shared/controllers_shared_context.rb +2 -2
  80. metadata +40 -35
  81. data/lib/doorkeeper/doorkeeper_for.rb +0 -69
  82. data/lib/doorkeeper/helpers/filter.rb +0 -64
  83. data/lib/doorkeeper/models/access_grant.rb +0 -30
  84. data/lib/doorkeeper/models/access_token.rb +0 -106
  85. data/lib/doorkeeper/models/active_record/access_grant.rb +0 -9
  86. data/lib/doorkeeper/models/active_record/access_token.rb +0 -25
  87. data/lib/doorkeeper/models/application.rb +0 -40
  88. data/lib/doorkeeper/models/mongoid/scopes.rb +0 -15
  89. data/lib/doorkeeper/models/mongoid/version.rb +0 -15
  90. data/lib/doorkeeper/models/mongoid3_4/access_grant.rb +0 -27
  91. data/lib/doorkeeper/models/mongoid3_4/access_token.rb +0 -46
  92. data/lib/doorkeeper/models/scopes.rb +0 -21
  93. data/lib/generators/doorkeeper/mongo_mapper/indexes_generator.rb +0 -12
  94. data/script/rails +0 -5
  95. data/script/run_all +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2d7cab21593e8a332814e94eb9a6ea9dec17a4e
4
- data.tar.gz: 36510e1c2ba3eb2d251b673cd255a55658bac713
3
+ metadata.gz: d4bc922834f77e390385c6b9ff4284dc7f68cf0b
4
+ data.tar.gz: 23f9d1f65f3fe87e7c5f603d6b107230e142b79a
5
5
  SHA512:
6
- metadata.gz: fae688f8c62919746f491bf310785b8e7ae2d7af3095cb2b09fcab1bc6ac73bc8dfdb57d67c474369a27a5c1135876f98a15bd18a2feb7e7c39d62953e23a9bd
7
- data.tar.gz: 10c7f4395f915b88982a93f9bb5a6e8f5f57e6577752281b971be705707af84af2ae6ab2caf7d191a06deb3efbf4878ac66fd187e7427a14354b279e2db20c8b
6
+ metadata.gz: 494114035eb4172c2ade7e380566e5e28707348a54c71d396028dac19fd4a6746c1f5f1272e916921cda0faa8f22bec6900e3af649fc0ae720bc39671ef63b28
7
+ data.tar.gz: 0288945e46c7b2b90db5a7e75e3db6405331c1dd2830cf46f88ef2154d139530dc60f7ed587c2f2bc56078645d89a64bb7b1efeaf0ce24b2bc96807a27062170
data/.hound.yml CHANGED
@@ -4,3 +4,6 @@ LineLength:
4
4
 
5
5
  StringLiterals:
6
6
  Enabled: false
7
+
8
+ TrailingBlankLines:
9
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,16 +1,23 @@
1
1
  # Changelog
2
2
 
3
- ## master
4
-
5
- ## 1.4.2
6
-
7
- - [#576] Backported to 1.4.X branch. Filters out sensitive parameters from logs.
8
-
9
-
10
- ## 1.4.1
11
-
12
- - Fixes CSRF vulnerability
13
-
3
+ ## master (preparation for 2.0.0)
4
+
5
+ - Removes deprecated option `test_redirect_uri`. Now called
6
+ `native_redirect_uri`.
7
+ - [#446] Removes deprecated `mount Doorkeeper::Engine`. Now we use
8
+ `use_doorkeeper`.
9
+ - [#448] Removes `doorkeeper_for` helper. Now we use
10
+ `before_action :doorkeeper_authorize!`. This change didn't go through the
11
+ deprecation cycle.
12
+ - [#450] When password is invalid in Password Credentials Grant, Doorkeeper
13
+ returned 'invalid_resource_owner' instead of 'invalid_grant', as the spec
14
+ declares. Fixes #444.
15
+ - [#452] Allows `revoked_at` to be set in the future, for future expiry.
16
+ Rationale: https://github.com/doorkeeper-gem/doorkeeper/pull/452#issuecomment-51431459
17
+ - [#480] For Implicit grant flow, access tokens can now be reused. Fixes #421.
18
+ - [#491] Reworks of @jasl's #454 and #478. ORM refactor that allows doorkeeper
19
+ to be extended more easily with unsupported ORMs. It also marks the boundaries
20
+ between shared model code and ORM specifics inside of the gem.
14
21
 
15
22
  ## 1.4.0
16
23
 
data/Gemfile CHANGED
@@ -1,31 +1,31 @@
1
1
  # Defaults. For supported versions check .travis.yml
2
- ENV['rails'] ||= ENV['orm'] == "mongoid4" ? '4.0.2' : '3.2.13'
2
+ ENV['rails'] ||= ENV['orm'] == "mongoid4" ? '4.1.0' : '3.2.0'
3
3
  ENV['orm'] ||= 'active_record'
4
4
 
5
5
  source 'https://rubygems.org'
6
6
 
7
7
  # Define Rails version
8
- gem 'rails', ENV['rails']
8
+ gem 'rails', "~> #{ENV['rails']}"
9
9
 
10
- gem 'database_cleaner', '~> 1.0.0.RC1' if ENV['rails'][0] == '4'
10
+ gem 'database_cleaner' if ENV['rails'][0] == '4'
11
11
 
12
12
  case ENV['orm']
13
13
  when 'active_record'
14
14
  gem 'activerecord'
15
15
 
16
16
  when 'mongoid2'
17
- gem 'mongoid', '2.5.1'
17
+ gem 'mongoid', '~> 2'
18
18
  gem 'bson_ext', '~> 1.7'
19
19
 
20
20
  when 'mongoid3'
21
- gem 'mongoid', '3.0.10'
21
+ gem 'mongoid', '~> 3'
22
22
 
23
23
  when 'mongoid4'
24
- gem 'mongoid', '4.0.0.beta1'
24
+ gem 'mongoid', '~> 4'
25
25
  gem 'moped'
26
26
 
27
27
  when 'mongo_mapper'
28
- gem 'mongo_mapper', '0.12.0'
28
+ gem 'mongo_mapper', '~> 0.12'
29
29
  gem 'bson_ext', '~> 1.7'
30
30
 
31
31
  end
data/README.md CHANGED
@@ -1,12 +1,17 @@
1
1
  # Doorkeeper - awesome oauth provider for your Rails app.
2
2
 
3
- [![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper.png?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper)
4
- [![Dependency Status](https://gemnasium.com/applicake/doorkeeper.png?travis)](https://gemnasium.com/applicake/doorkeeper)
5
- [![Code Climate](https://codeclimate.com/github/applicake/doorkeeper.png)](https://codeclimate.com/github/applicake/doorkeeper)
6
- [![Gem Version](https://badge.fury.io/rb/doorkeeper.png)](https://rubygems.org/gems/doorkeeper)
3
+ [![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper.svg?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper)
4
+ [![Dependency Status](https://gemnasium.com/applicake/doorkeeper.svg?travis)](https://gemnasium.com/applicake/doorkeeper)
5
+ [![Code Climate](https://codeclimate.com/github/applicake/doorkeeper.svg)](https://codeclimate.com/github/applicake/doorkeeper)
6
+ [![Gem Version](https://badge.fury.io/rb/doorkeeper.svg)](https://rubygems.org/gems/doorkeeper)
7
7
 
8
8
  Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider functionality to your application.
9
9
 
10
+ ## Documentation valid for `master` branch
11
+
12
+ Please check the documentation for the version of doorkeeper you are using in:
13
+ https://github.com/doorkeeper-gem/doorkeeper/releases.
14
+
10
15
  ## Table of Contents
11
16
 
12
17
  - [Useful links](#useful-links)
@@ -164,48 +169,20 @@ authentication
164
169
 
165
170
  ## Protecting resources with OAuth (a.k.a your API endpoint)
166
171
 
167
- To protect your API with OAuth, doorkeeper only requires you to call
168
- `doorkeeper_for` helper, specifying the actions you want to protect.
169
-
170
- For example, if you have a products controller under api/v1, you can require
171
- the OAuth authentication with:
172
+ To protect your API with OAuth, you just need to setup `before_action`s
173
+ specifying the actions you want to protect. For example:
172
174
 
173
175
  ``` ruby
174
176
  class Api::V1::ProductsController < Api::V1::ApiController
175
- doorkeeper_for :all # Require access token for all actions
176
- doorkeeper_for :all, except: :index # All actions except index
177
- doorkeeper_for :index, :show # Only for index and show action
177
+ before_action :doorkeeper_authorize! # Require access token for all actions
178
178
 
179
179
  # your actions
180
180
  end
181
181
  ```
182
182
 
183
- You don't need to setup any before filter, `doorkeeper_for` will handle that
184
- for you.
185
-
186
- You can pass `if` or `unless` blocks that would specify when doorkeeper has to
187
- guard the access.
188
-
189
- ``` ruby
190
- class Api::V1::ProductsController < Api::V1::ApiController
191
- doorkeeper_for :all, :if => lambda { request.xhr? }
192
- end
193
- ```
194
-
195
- ### ActionController::Metal integration
196
-
197
- The `doorkeeper_for` filter is intended to work with ActionController::Metal
198
- too. You only need to include the required `ActionController` modules:
199
-
200
- ```ruby
201
- class MetalController < ActionController::Metal
202
- include AbstractController::Callbacks
203
- include ActionController::Head
204
- include Doorkeeper::Helpers::Filter
183
+ You can pass any option `before_action` accepts, such as `if`, `only`,
184
+ `except`, and others.
205
185
 
206
- doorkeeper_for :all
207
- end
208
- ```
209
186
 
210
187
  ### Route Constraints and other integrations
211
188
 
@@ -248,8 +225,10 @@ And in your controllers:
248
225
 
249
226
  ```ruby
250
227
  class Api::V1::ProductsController < Api::V1::ApiController
251
- doorkeeper_for :index, :show, :scopes => [:public]
252
- doorkeeper_for :update, :create, :scopes => [:admin, :write]
228
+ before_action -> { doorkeeper_authorize! :public }, only: :index
229
+ before_action only: [:create, :update, :destroy] do
230
+ doorkeeper_authorize! :admin, :write
231
+ end
253
232
  end
254
233
  ```
255
234
 
@@ -265,8 +244,8 @@ controller that returns the resource owner instance:
265
244
 
266
245
  ``` ruby
267
246
  class Api::V1::CredentialsController < Api::V1::ApiController
268
- doorkeeper_for :all
269
- respond_to :json
247
+ before_action :doorkeeper_authorize!
248
+ respond_to :json
270
249
 
271
250
  # GET /me.json
272
251
  def me
@@ -2,12 +2,6 @@ module Doorkeeper
2
2
  class ApplicationController < ActionController::Base
3
3
  include Helpers::Controller
4
4
 
5
- helper 'doorkeeper/form_errors'
6
-
7
- if ::Rails.version.to_i < 4
8
- protect_from_forgery
9
- else
10
- protect_from_forgery with: :exception
11
- end
5
+ helper 'doorkeeper/dashboard'
12
6
  end
13
7
  end
@@ -1,7 +1,6 @@
1
1
  module Doorkeeper
2
2
  class ApplicationsController < Doorkeeper::ApplicationController
3
3
  layout 'doorkeeper/admin'
4
- respond_to :html
5
4
 
6
5
  before_filter :authenticate_admin!
7
6
  before_filter :set_application, only: [:show, :edit, :update, :destroy]
@@ -18,7 +17,7 @@ module Doorkeeper
18
17
  @application = Application.new(application_params)
19
18
  if @application.save
20
19
  flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
21
- respond_with [:oauth, @application]
20
+ redirect_to oauth_application_url(@application)
22
21
  else
23
22
  render :new
24
23
  end
@@ -27,7 +26,7 @@ module Doorkeeper
27
26
  def update
28
27
  if @application.update_attributes(application_params)
29
28
  flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :update])
30
- respond_with [:oauth, @application]
29
+ redirect_to oauth_application_url(@application)
31
30
  else
32
31
  render :edit
33
32
  end
@@ -46,9 +45,9 @@ module Doorkeeper
46
45
 
47
46
  def application_params
48
47
  if params.respond_to?(:permit)
49
- params.require(:application).permit(:name, :redirect_uri)
48
+ params.require(:doorkeeper_application).permit(:name, :redirect_uri)
50
49
  else
51
- params[:application].slice(:name, :redirect_uri) rescue nil
50
+ params[:doorkeeper_application].slice(:name, :redirect_uri) rescue nil
52
51
  end
53
52
  end
54
53
  end
@@ -18,14 +18,14 @@ module Doorkeeper
18
18
  revoke_token(request.POST['token']) if request.POST['token']
19
19
  end
20
20
  # The authorization server responds with HTTP status code 200 if the
21
- # token has been revoked sucessfully or if the client submitted an invalid token
21
+ # token has been revoked successfully or if the client submitted an invalid token
22
22
  render json: {}, status: 200
23
23
  end
24
24
 
25
25
  private
26
26
 
27
27
  def revoke_token(token)
28
- token = AccessToken.authenticate(token) || AccessToken.by_refresh_token(token)
28
+ token = AccessToken.by_token(token) || AccessToken.by_refresh_token(token)
29
29
  if token && doorkeeper_token.same_credential?(token)
30
30
  token.revoke
31
31
  true
@@ -1,4 +1,4 @@
1
- module Doorkeeper::FormErrorsHelper
1
+ module Doorkeeper::DashboardHelper
2
2
  def doorkeeper_errors_for(object, method)
3
3
  if object.errors[method].present?
4
4
  object.errors[method].map do |msg|
@@ -8,4 +8,8 @@ module Doorkeeper::FormErrorsHelper
8
8
  end.reduce(&:join).html_safe
9
9
  end
10
10
  end
11
+
12
+ def doorkeeper_submit_path(application)
13
+ application.persisted? ? oauth_application_path(application) : oauth_applications_path
14
+ end
11
15
  end
@@ -1,5 +1,5 @@
1
1
  <%- submit_btn_css ||= 'btn btn-link' %>
2
- <%= form_tag [:oauth, application] do %>
2
+ <%= form_tag oauth_application_path(application) do %>
3
3
  <input type="hidden" name="_method" value="delete">
4
4
  <%= submit_tag 'Destroy', onclick: "return confirm('Are you sure?')", class: submit_btn_css %>
5
5
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= form_for [:oauth, application], html: {class: 'form-horizontal', role: 'form'} do |f| %>
1
+ <%= form_for application, url: doorkeeper_submit_path(application), html: {class: 'form-horizontal', role: 'form'} do |f| %>
2
2
  <% if application.errors.any? %>
3
3
  <div class="alert alert-danger" data-alert><p>Whoops! Check your form for possible errors</p></div>
4
4
  <% end %>
@@ -16,7 +16,7 @@
16
16
  <tbody>
17
17
  <% @applications.each do |application| %>
18
18
  <tr id="application_<%= application.id %>">
19
- <td><%= link_to application.name, [:oauth, application] %></td>
19
+ <td><%= link_to application.name, oauth_application_path(application) %></td>
20
20
  <td><%= application.redirect_uri %></td>
21
21
  <td><%= link_to 'Edit', edit_oauth_application_path(application), class: 'btn btn-link' %></td>
22
22
  <td><%= render 'delete_form', application: application %></td>
@@ -2,7 +2,7 @@ en:
2
2
  activerecord:
3
3
  errors:
4
4
  models:
5
- application:
5
+ doorkeeper/application:
6
6
  attributes:
7
7
  redirect_uri:
8
8
  fragment_present: 'cannot contain a fragment.'
@@ -11,7 +11,7 @@ en:
11
11
  mongoid:
12
12
  errors:
13
13
  models:
14
- application:
14
+ doorkeeper/application:
15
15
  attributes:
16
16
  redirect_uri:
17
17
  fragment_present: 'cannot contain a fragment.'
@@ -20,7 +20,7 @@ en:
20
20
  mongo_mapper:
21
21
  errors:
22
22
  models:
23
- application:
23
+ doorkeeper/application:
24
24
  attributes:
25
25
  redirect_uri:
26
26
  fragment_present: 'cannot contain a fragment.'
data/lib/doorkeeper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'doorkeeper/version'
2
2
  require 'doorkeeper/engine'
3
3
  require 'doorkeeper/config'
4
- require 'doorkeeper/doorkeeper_for'
5
4
 
6
5
  require 'doorkeeper/errors'
7
6
  require 'doorkeeper/server'
@@ -33,15 +32,25 @@ require 'doorkeeper/oauth/token'
33
32
  require 'doorkeeper/oauth/invalid_token_response'
34
33
  require 'doorkeeper/oauth/forbidden_token_response'
35
34
 
36
- require 'doorkeeper/models/scopes'
37
- require 'doorkeeper/models/expirable'
38
- require 'doorkeeper/models/revocable'
39
- require 'doorkeeper/models/accessible'
35
+ require 'doorkeeper/models/concerns/scopes'
36
+ require 'doorkeeper/models/concerns/expirable'
37
+ require 'doorkeeper/models/concerns/revocable'
38
+ require 'doorkeeper/models/concerns/accessible'
39
+
40
+ require 'doorkeeper/models/access_grant_mixin'
41
+ require 'doorkeeper/models/access_token_mixin'
42
+ require 'doorkeeper/models/application_mixin'
40
43
 
41
- require 'doorkeeper/helpers/filter'
42
44
  require 'doorkeeper/helpers/controller'
43
45
 
44
46
  require 'doorkeeper/rails/routes'
47
+ require 'doorkeeper/rails/helpers'
48
+
49
+ require 'doorkeeper/orm/active_record'
50
+ require 'doorkeeper/orm/mongo_mapper'
51
+ require 'doorkeeper/orm/mongoid2'
52
+ require 'doorkeeper/orm/mongoid3'
53
+ require 'doorkeeper/orm/mongoid4'
45
54
 
46
55
  module Doorkeeper
47
56
  def self.configured?
@@ -15,26 +15,28 @@ module Doorkeeper
15
15
  @config || (fail MissingConfiguration.new)
16
16
  end
17
17
 
18
- def self.orm_model_dir
19
- case configuration.orm
20
- when :mongoid3, :mongoid4
21
- 'mongoid3_4'
18
+ def self.enable_orm
19
+ class_name = "doorkeeper/orm/#{configuration.orm}".classify
20
+ class_name.constantize.initialize_models!
21
+ rescue NameError => e
22
+ if e.instance_of?(NameError)
23
+ fail e, "ORM adapter not found (#{configuration.orm})", <<-error_msg
24
+ [doorkeeper] ORM adapter not found (#{configuration.orm}), or there was an error
25
+ trying to load it.
26
+
27
+ You probably need to add the related gem for this adapter to work with
28
+ doorkeeper.
29
+
30
+ If you are working on the adapter itself, double check that the constant exists,
31
+ and that your `initialize_models!` method doesn't raise any errors.\n
32
+ error_msg
22
33
  else
23
- configuration.orm
34
+ raise e
24
35
  end
25
36
  end
26
37
 
27
- def self.enable_orm
28
- require "doorkeeper/models/#{orm_model_dir}/access_grant"
29
- require "doorkeeper/models/#{orm_model_dir}/access_token"
30
- require "doorkeeper/models/#{orm_model_dir}/application"
31
- require 'doorkeeper/models/access_grant'
32
- require 'doorkeeper/models/access_token'
33
- require 'doorkeeper/models/application'
34
- end
35
-
36
38
  def self.setup_application_owner
37
- require File.join(File.dirname(__FILE__), 'models', 'ownership')
39
+ require File.join(File.dirname(__FILE__), 'models', 'concerns', 'ownership')
38
40
  Application.send :include, Models::Ownership
39
41
  end
40
42
 
@@ -85,14 +87,6 @@ module Doorkeeper
85
87
  def reuse_access_token
86
88
  @config.instance_variable_set("@reuse_access_token", true)
87
89
  end
88
-
89
- def test_redirect_uri(uri)
90
- warn <<-TEXT
91
- DEPRECATION: test_redirect_uri has renamed to native_redirect_uri. use "native_redirect_uri '#{uri}'".
92
- TEXT
93
-
94
- @config.instance_variable_set('@native_redirect_uri', uri)
95
- end
96
90
  end
97
91
 
98
92
  module Option
@@ -233,7 +227,7 @@ module Doorkeeper
233
227
  @token_grant_types ||= calculate_token_grant_types
234
228
  end
235
229
 
236
- private
230
+ private
237
231
 
238
232
  # Determines what values are acceptable for 'response_type' param in
239
233
  # authorization request endpoint, and return them as an array of strings.
@@ -1,17 +1,12 @@
1
1
  module Doorkeeper
2
2
  class Engine < Rails::Engine
3
- initializer "doorkeeper.params.filter" do |app|
4
- app.config.filter_parameters += [:client_secret, :code, :token]
5
- end
6
-
7
3
  initializer 'doorkeeper.routes' do
8
- Doorkeeper::Rails::Routes.warn_if_using_mount_method!
9
4
  Doorkeeper::Rails::Routes.install!
10
5
  end
11
6
 
12
7
  initializer 'doorkeeper.helpers' do
13
8
  ActiveSupport.on_load(:action_controller) do
14
- include Doorkeeper::Helpers::Filter
9
+ include Doorkeeper::Rails::Helpers
15
10
  end
16
11
  end
17
12
  end