doorkeeper 4.2.6 → 4.3.0

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 (120) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +19 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +17 -0
  4. data/.gitignore +1 -1
  5. data/.hound.yml +2 -13
  6. data/.rubocop.yml +13 -0
  7. data/.travis.yml +13 -5
  8. data/Appraisals +6 -2
  9. data/CODE_OF_CONDUCT.md +46 -0
  10. data/Gemfile +1 -1
  11. data/NEWS.md +24 -0
  12. data/README.md +39 -9
  13. data/SECURITY.md +13 -0
  14. data/app/controllers/doorkeeper/application_controller.rb +1 -5
  15. data/app/controllers/doorkeeper/applications_controller.rb +14 -1
  16. data/app/controllers/doorkeeper/tokens_controller.rb +13 -1
  17. data/app/helpers/doorkeeper/dashboard_helper.rb +4 -2
  18. data/app/validators/redirect_uri_validator.rb +12 -2
  19. data/app/views/doorkeeper/applications/_form.html.erb +1 -1
  20. data/app/views/doorkeeper/authorized_applications/index.html.erb +0 -1
  21. data/config/locales/en.yml +3 -5
  22. data/doorkeeper.gemspec +4 -3
  23. data/gemfiles/rails_4_2.gemfile +6 -4
  24. data/gemfiles/rails_5_0.gemfile +4 -4
  25. data/gemfiles/rails_5_1.gemfile +6 -7
  26. data/gemfiles/rails_5_2.gemfile +12 -0
  27. data/gemfiles/rails_master.gemfile +14 -0
  28. data/lib/doorkeeper.rb +1 -0
  29. data/lib/doorkeeper/config.rb +55 -55
  30. data/lib/doorkeeper/engine.rb +3 -3
  31. data/lib/doorkeeper/grape/helpers.rb +13 -8
  32. data/lib/doorkeeper/helpers/controller.rb +8 -4
  33. data/lib/doorkeeper/models/access_token_mixin.rb +14 -7
  34. data/lib/doorkeeper/models/application_mixin.rb +11 -6
  35. data/lib/doorkeeper/models/concerns/expirable.rb +7 -5
  36. data/lib/doorkeeper/oauth/authorization/token.rb +22 -18
  37. data/lib/doorkeeper/oauth/authorization_code_request.rb +6 -1
  38. data/lib/doorkeeper/oauth/base_request.rb +5 -5
  39. data/lib/doorkeeper/oauth/client.rb +2 -2
  40. data/lib/doorkeeper/oauth/client/credentials.rb +2 -2
  41. data/lib/doorkeeper/oauth/error.rb +2 -2
  42. data/lib/doorkeeper/oauth/error_response.rb +1 -2
  43. data/lib/doorkeeper/oauth/forbidden_token_response.rb +1 -1
  44. data/lib/doorkeeper/oauth/invalid_token_response.rb +2 -3
  45. data/lib/doorkeeper/oauth/password_access_token_request.rb +1 -0
  46. data/lib/doorkeeper/oauth/refresh_token_request.rb +1 -0
  47. data/lib/doorkeeper/oauth/scopes.rb +18 -8
  48. data/lib/doorkeeper/oauth/token.rb +1 -1
  49. data/lib/doorkeeper/oauth/token_introspection.rb +128 -0
  50. data/lib/doorkeeper/orm/active_record.rb +20 -8
  51. data/lib/doorkeeper/orm/active_record/access_grant.rb +1 -1
  52. data/lib/doorkeeper/orm/active_record/access_token.rb +1 -23
  53. data/lib/doorkeeper/orm/active_record/application.rb +1 -1
  54. data/lib/doorkeeper/orm/active_record/base_record.rb +11 -0
  55. data/lib/doorkeeper/rails/helpers.rb +5 -6
  56. data/lib/doorkeeper/rails/routes.rb +9 -7
  57. data/lib/doorkeeper/request.rb +7 -1
  58. data/lib/doorkeeper/validations.rb +3 -2
  59. data/lib/doorkeeper/version.rb +13 -1
  60. data/lib/generators/doorkeeper/application_owner_generator.rb +11 -2
  61. data/lib/generators/doorkeeper/migration_generator.rb +13 -1
  62. data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +7 -1
  63. data/lib/generators/doorkeeper/templates/{add_owner_to_application_migration.rb → add_owner_to_application_migration.rb.erb} +1 -1
  64. data/lib/generators/doorkeeper/templates/{add_previous_refresh_token_to_access_tokens.rb → add_previous_refresh_token_to_access_tokens.rb.erb} +1 -1
  65. data/lib/generators/doorkeeper/templates/initializer.rb +19 -3
  66. data/lib/generators/doorkeeper/templates/{migration.rb → migration.rb.erb} +1 -1
  67. data/spec/controllers/applications_controller_spec.rb +15 -4
  68. data/spec/controllers/authorizations_controller_spec.rb +5 -5
  69. data/spec/controllers/protected_resources_controller_spec.rb +28 -19
  70. data/spec/controllers/token_info_controller_spec.rb +17 -13
  71. data/spec/controllers/tokens_controller_spec.rb +138 -4
  72. data/spec/dummy/config/initializers/doorkeeper.rb +1 -1
  73. data/spec/dummy/config/initializers/{active_record_belongs_to_required_by_default.rb → new_framework_defaults.rb} +1 -1
  74. data/spec/dummy/config/initializers/secret_token.rb +0 -1
  75. data/spec/factories.rb +1 -1
  76. data/spec/generators/application_owner_generator_spec.rb +24 -5
  77. data/spec/generators/migration_generator_spec.rb +24 -3
  78. data/spec/generators/previous_refresh_token_generator_spec.rb +57 -0
  79. data/spec/grape/grape_integration_spec.rb +135 -0
  80. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +1 -1
  81. data/spec/lib/config_spec.rb +115 -12
  82. data/spec/lib/models/revocable_spec.rb +2 -2
  83. data/spec/lib/oauth/authorization_code_request_spec.rb +39 -11
  84. data/spec/lib/oauth/base_request_spec.rb +2 -7
  85. data/spec/lib/oauth/client_credentials/creator_spec.rb +1 -1
  86. data/spec/lib/oauth/client_credentials_integration_spec.rb +1 -1
  87. data/spec/lib/oauth/client_credentials_request_spec.rb +1 -0
  88. data/spec/lib/oauth/code_request_spec.rb +1 -3
  89. data/spec/lib/oauth/helpers/uri_checker_spec.rb +5 -0
  90. data/spec/lib/oauth/invalid_token_response_spec.rb +1 -1
  91. data/spec/lib/oauth/password_access_token_request_spec.rb +9 -3
  92. data/spec/lib/oauth/refresh_token_request_spec.rb +19 -7
  93. data/spec/lib/oauth/scopes_spec.rb +28 -1
  94. data/spec/lib/oauth/token_request_spec.rb +6 -8
  95. data/spec/lib/server_spec.rb +10 -0
  96. data/spec/models/doorkeeper/access_grant_spec.rb +1 -1
  97. data/spec/models/doorkeeper/access_token_spec.rb +72 -48
  98. data/spec/models/doorkeeper/application_spec.rb +51 -18
  99. data/spec/requests/applications/applications_request_spec.rb +5 -5
  100. data/spec/requests/endpoints/token_spec.rb +8 -1
  101. data/spec/requests/flows/authorization_code_spec.rb +1 -0
  102. data/spec/requests/flows/client_credentials_spec.rb +1 -1
  103. data/spec/requests/flows/implicit_grant_errors_spec.rb +2 -2
  104. data/spec/requests/flows/refresh_token_spec.rb +4 -4
  105. data/spec/requests/flows/revoke_token_spec.rb +15 -15
  106. data/spec/requests/protected_resources/metal_spec.rb +1 -1
  107. data/spec/requests/protected_resources/private_api_spec.rb +1 -1
  108. data/spec/routing/custom_controller_routes_spec.rb +4 -0
  109. data/spec/routing/default_routes_spec.rb +5 -1
  110. data/spec/spec_helper_integration.rb +15 -4
  111. data/spec/support/dependencies/factory_girl.rb +2 -2
  112. data/spec/support/helpers/access_token_request_helper.rb +1 -1
  113. data/spec/support/helpers/model_helper.rb +9 -4
  114. data/spec/support/helpers/request_spec_helper.rb +7 -3
  115. data/spec/support/helpers/url_helper.rb +8 -8
  116. data/spec/support/shared/controllers_shared_context.rb +2 -6
  117. data/spec/support/shared/models_shared_examples.rb +4 -4
  118. data/spec/validators/redirect_uri_validator_spec.rb +51 -6
  119. data/spec/version/version_spec.rb +15 -0
  120. metadata +42 -13
@@ -1,22 +1,34 @@
1
+ require 'active_support/lazy_load_hooks'
2
+
1
3
  module Doorkeeper
2
4
  module Orm
3
5
  module ActiveRecord
4
6
  def self.initialize_models!
5
- require 'doorkeeper/orm/active_record/access_grant'
6
- require 'doorkeeper/orm/active_record/access_token'
7
- require 'doorkeeper/orm/active_record/application'
7
+ lazy_load do
8
+ require 'doorkeeper/orm/active_record/base_record'
9
+ require 'doorkeeper/orm/active_record/access_grant'
10
+ require 'doorkeeper/orm/active_record/access_token'
11
+ require 'doorkeeper/orm/active_record/application'
8
12
 
9
- if Doorkeeper.configuration.active_record_options[:establish_connection]
10
- [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application].each do |c|
11
- c.send :establish_connection, Doorkeeper.configuration.active_record_options[:establish_connection]
13
+ if Doorkeeper.configuration.active_record_options[:establish_connection]
14
+ [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application].each do |model|
15
+ options = Doorkeeper.configuration.active_record_options[:establish_connection]
16
+ model.establish_connection(options)
17
+ end
12
18
  end
13
19
  end
14
20
  end
15
21
 
16
22
  def self.initialize_application_owner!
17
- require 'doorkeeper/models/concerns/ownership'
23
+ lazy_load do
24
+ require 'doorkeeper/models/concerns/ownership'
25
+
26
+ Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
27
+ end
28
+ end
18
29
 
19
- Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
30
+ def self.lazy_load(&block)
31
+ ActiveSupport.on_load(:active_record, {}, &block)
20
32
  end
21
33
  end
22
34
  end
@@ -1,5 +1,5 @@
1
1
  module Doorkeeper
2
- class AccessGrant < ActiveRecord::Base
2
+ class AccessGrant < BaseRecord
3
3
  self.table_name = "#{table_name_prefix}oauth_access_grants#{table_name_suffix}".to_sym
4
4
 
5
5
  include AccessGrantMixin
@@ -1,21 +1,9 @@
1
1
  module Doorkeeper
2
- class AccessToken < ActiveRecord::Base
2
+ class AccessToken < BaseRecord
3
3
  self.table_name = "#{table_name_prefix}oauth_access_tokens#{table_name_suffix}".to_sym
4
4
 
5
5
  include AccessTokenMixin
6
6
 
7
- # Deletes all the Access Tokens created for the specific
8
- # Application and Resource Owner.
9
- #
10
- # @param application_id [Integer] Application ID
11
- # @param resource_owner [ActiveRecord::Base] Resource Owner model instance
12
- #
13
- def self.delete_all_for(application_id, resource_owner)
14
- where(application_id: application_id,
15
- resource_owner_id: resource_owner.id).delete_all
16
- end
17
- private_class_method :delete_all_for
18
-
19
7
  # Searches for not revoked Access Tokens associated with the
20
8
  # specific Resource Owner.
21
9
  #
@@ -29,18 +17,8 @@ module Doorkeeper
29
17
  where(resource_owner_id: resource_owner.id, revoked_at: nil)
30
18
  end
31
19
 
32
- # ORM-specific order method.
33
- def self.order_method
34
- :order
35
- end
36
-
37
20
  def self.refresh_token_revoked_on_use?
38
21
  column_names.include?('previous_refresh_token')
39
22
  end
40
-
41
- # ORM-specific DESC order for `:created_at` column.
42
- def self.created_at_desc
43
- 'created_at desc'
44
- end
45
23
  end
46
24
  end
@@ -1,5 +1,5 @@
1
1
  module Doorkeeper
2
- class Application < ActiveRecord::Base
2
+ class Application < BaseRecord
3
3
  self.table_name = "#{table_name_prefix}oauth_applications#{table_name_suffix}".to_sym
4
4
 
5
5
  include ApplicationMixin
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doorkeeper
4
+ class BaseRecord < ActiveRecord::Base
5
+ self.abstract_class = true
6
+
7
+ def self.ordered_by(attribute, direction = :asc)
8
+ order(attribute => direction)
9
+ end
10
+ end
11
+ end
@@ -9,11 +9,9 @@ module Doorkeeper
9
9
  end
10
10
  end
11
11
 
12
- def doorkeeper_unauthorized_render_options(error: nil)
13
- end
12
+ def doorkeeper_unauthorized_render_options(**); end
14
13
 
15
- def doorkeeper_forbidden_render_options(error: nil)
16
- end
14
+ def doorkeeper_forbidden_render_options(**); end
17
15
 
18
16
  def valid_doorkeeper_token?
19
17
  doorkeeper_token && doorkeeper_token.acceptable?(@_doorkeeper_scopes)
@@ -23,14 +21,15 @@ module Doorkeeper
23
21
 
24
22
  def doorkeeper_render_error
25
23
  error = doorkeeper_error
26
- headers.merge! error.headers.reject { |k| "Content-Type" == k }
24
+ headers.merge!(error.headers.reject { |k| k == "Content-Type" })
27
25
  doorkeeper_render_error_with(error)
28
26
  end
29
27
 
30
28
  def doorkeeper_render_error_with(error)
31
29
  options = doorkeeper_render_options(error) || {}
32
30
  status = doorkeeper_status_for_error(
33
- error, options.delete(:respond_not_found_when_forbidden))
31
+ error, options.delete(:respond_not_found_when_forbidden)
32
+ )
34
33
  if options.blank?
35
34
  head status
36
35
  else
@@ -5,7 +5,6 @@ module Doorkeeper
5
5
  module Rails
6
6
  class Routes # :nodoc:
7
7
  module Helper
8
- # TODO: options hash is not being used
9
8
  def use_doorkeeper(options = {}, &block)
10
9
  Doorkeeper::Rails::Routes.new(self, &block).generate_routes!(options)
11
10
  end
@@ -27,6 +26,7 @@ module Doorkeeper
27
26
  map_route(:authorizations, :authorization_routes)
28
27
  map_route(:tokens, :token_routes)
29
28
  map_route(:tokens, :revoke_routes)
29
+ map_route(:tokens, :introspect_routes)
30
30
  map_route(:applications, :application_routes)
31
31
  map_route(:authorized_applications, :authorized_applications_routes)
32
32
  map_route(:token_info, :token_info_routes)
@@ -36,20 +36,18 @@ module Doorkeeper
36
36
  private
37
37
 
38
38
  def map_route(name, method)
39
- unless @mapping.skipped?(name)
40
- send method, @mapping[name]
41
- end
39
+ send(method, @mapping[name]) unless @mapping.skipped?(name)
42
40
  end
43
41
 
44
42
  def authorization_routes(mapping)
45
43
  routes.resource(
46
44
  :authorization,
47
45
  path: 'authorize',
48
- only: [:create, :destroy],
46
+ only: %i[create destroy],
49
47
  as: mapping[:as],
50
48
  controller: mapping[:controllers]
51
49
  ) do
52
- routes.get '/:code', action: :show, on: :member
50
+ routes.get '/native', action: :show, on: :member
53
51
  routes.get '/', action: :new, on: :member
54
52
  end
55
53
  end
@@ -67,6 +65,10 @@ module Doorkeeper
67
65
  routes.post 'revoke', controller: mapping[:controllers], action: :revoke
68
66
  end
69
67
 
68
+ def introspect_routes(mapping)
69
+ routes.post 'introspect', controller: mapping[:controllers], action: :introspect
70
+ end
71
+
70
72
  def token_info_routes(mapping)
71
73
  routes.resource(
72
74
  :token_info,
@@ -81,7 +83,7 @@ module Doorkeeper
81
83
  end
82
84
 
83
85
  def authorized_applications_routes(mapping)
84
- routes.resources :authorized_applications, only: [:index, :destroy], controller: mapping[:controllers]
86
+ routes.resources :authorized_applications, only: %i[index destroy], controller: mapping[:controllers]
85
87
  end
86
88
  end
87
89
  end
@@ -24,7 +24,7 @@ module Doorkeeper
24
24
  def get_strategy(grant_or_request_type, available)
25
25
  fail Errors::MissingRequestStrategy unless grant_or_request_type.present?
26
26
  fail NameError unless available.include?(grant_or_request_type.to_s)
27
- "Doorkeeper::Request::#{grant_or_request_type.to_s.camelize}".constantize
27
+ strategy_class(grant_or_request_type)
28
28
  end
29
29
 
30
30
  def authorization_response_types
@@ -36,5 +36,11 @@ module Doorkeeper
36
36
  Doorkeeper.configuration.token_grant_types
37
37
  end
38
38
  private_class_method :token_grant_types
39
+
40
+ def strategy_class(grant_or_request_type)
41
+ strategy_class_name = grant_or_request_type.to_s.tr(' ', '_').camelize
42
+ "Doorkeeper::Request::#{strategy_class_name}".constantize
43
+ end
44
+ private_class_method :strategy_class
39
45
  end
40
46
  end
@@ -6,9 +6,10 @@ module Doorkeeper
6
6
 
7
7
  def validate
8
8
  @error = nil
9
+
9
10
  self.class.validations.each do |validation|
11
+ @error = validation[:options][:error] unless send("validate_#{validation[:attribute]}")
10
12
  break if @error
11
- @error = validation.last unless send("validate_#{validation.first}")
12
13
  end
13
14
  end
14
15
 
@@ -19,7 +20,7 @@ module Doorkeeper
19
20
 
20
21
  module ClassMethods
21
22
  def validate(attribute, options = {})
22
- validations << [attribute, options[:error]]
23
+ validations << { attribute: attribute, options: options }
23
24
  end
24
25
 
25
26
  def validations
@@ -1,3 +1,15 @@
1
1
  module Doorkeeper
2
- VERSION = "4.2.6".freeze
2
+ def self.gem_version
3
+ Gem::Version.new VERSION::STRING
4
+ end
5
+
6
+ module VERSION
7
+ # Semantic versioning
8
+ MAJOR = 4
9
+ MINOR = 3
10
+ TINY = 0
11
+
12
+ # Full version number
13
+ STRING = [MAJOR, MINOR, TINY].compact.join('.')
14
+ end
3
15
  end
@@ -7,12 +7,21 @@ class Doorkeeper::ApplicationOwnerGenerator < Rails::Generators::Base
7
7
 
8
8
  def application_owner
9
9
  migration_template(
10
- 'add_owner_to_application_migration.rb',
11
- 'db/migrate/add_owner_to_application.rb'
10
+ 'add_owner_to_application_migration.rb.erb',
11
+ 'db/migrate/add_owner_to_application.rb',
12
+ migration_version: migration_version
12
13
  )
13
14
  end
14
15
 
15
16
  def self.next_migration_number(dirname)
16
17
  ActiveRecord::Generators::Base.next_migration_number(dirname)
17
18
  end
19
+
20
+ private
21
+
22
+ def migration_version
23
+ if ActiveRecord::VERSION::MAJOR >= 5
24
+ "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
25
+ end
26
+ end
18
27
  end
@@ -6,10 +6,22 @@ class Doorkeeper::MigrationGenerator < ::Rails::Generators::Base
6
6
  desc 'Installs Doorkeeper migration file.'
7
7
 
8
8
  def install
9
- migration_template 'migration.rb', 'db/migrate/create_doorkeeper_tables.rb'
9
+ migration_template(
10
+ 'migration.rb.erb',
11
+ 'db/migrate/create_doorkeeper_tables.rb',
12
+ migration_version: migration_version
13
+ )
10
14
  end
11
15
 
12
16
  def self.next_migration_number(dirname)
13
17
  ActiveRecord::Generators::Base.next_migration_number(dirname)
14
18
  end
19
+
20
+ private
21
+
22
+ def migration_version
23
+ if ActiveRecord::VERSION::MAJOR >= 5
24
+ "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
25
+ end
26
+ end
15
27
  end
@@ -12,7 +12,7 @@ class Doorkeeper::PreviousRefreshTokenGenerator < Rails::Generators::Base
12
12
  def previous_refresh_token
13
13
  if no_previous_refresh_token_column?
14
14
  migration_template(
15
- 'add_previous_refresh_token_to_access_tokens.rb',
15
+ 'add_previous_refresh_token_to_access_tokens.rb.erb',
16
16
  'db/migrate/add_previous_refresh_token_to_access_tokens.rb'
17
17
  )
18
18
  end
@@ -20,6 +20,12 @@ class Doorkeeper::PreviousRefreshTokenGenerator < Rails::Generators::Base
20
20
 
21
21
  private
22
22
 
23
+ def migration_version
24
+ if ActiveRecord::VERSION::MAJOR >= 5
25
+ "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
26
+ end
27
+ end
28
+
23
29
  def no_previous_refresh_token_column?
24
30
  !ActiveRecord::Base.connection.column_exists?(
25
31
  :oauth_access_tokens,
@@ -1,4 +1,4 @@
1
- class AddOwnerToApplication < ActiveRecord::Migration
1
+ class AddOwnerToApplication < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  add_column :oauth_applications, :owner_id, :integer, null: true
4
4
  add_column :oauth_applications, :owner_type, :string, null: true
@@ -1,4 +1,4 @@
1
- class AddPreviousRefreshTokenToAccessTokens < ActiveRecord::Migration
1
+ class AddPreviousRefreshTokenToAccessTokens < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  add_column(
4
4
  :oauth_access_tokens,
@@ -60,13 +60,15 @@ Doorkeeper.configure do
60
60
  # Change the way client credentials are retrieved from the request object.
61
61
  # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
62
62
  # falls back to the `:client_id` and `:client_secret` params from the `params` object.
63
- # Check out the wiki for more information on customization
63
+ # Check out https://github.com/doorkeeper-gem/doorkeeper/wiki/Changing-how-clients-are-authenticated
64
+ # for more information on customization
64
65
  # client_credentials :from_basic, :from_params
65
66
 
66
67
  # Change the way access token is authenticated from the request object.
67
68
  # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
68
69
  # falls back to the `:access_token` or `:bearer_token` params from the `params` object.
69
- # Check out the wiki for more information on customization
70
+ # Check out https://github.com/doorkeeper-gem/doorkeeper/wiki/Changing-how-clients-are-authenticated
71
+ # for more information on customization
70
72
  # access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
71
73
 
72
74
  # Change the native redirect uri for client apps
@@ -80,7 +82,21 @@ Doorkeeper.configure do
80
82
  # by default in non-development environments). OAuth2 delegates security in
81
83
  # communication to the HTTPS protocol so it is wise to keep this enabled.
82
84
  #
85
+ # Callable objects such as proc, lambda, block or any object that responds to
86
+ # #call can be used in order to allow conditional checks (to allow non-SSL
87
+ # redirects to localhost for example).
88
+ #
83
89
  # force_ssl_in_redirect_uri !Rails.env.development?
90
+ #
91
+ # force_ssl_in_redirect_uri { |uri| uri.host != 'localhost' }
92
+
93
+ # Specify what redirect URI's you want to block during creation. Any redirect
94
+ # URI is whitelisted by default.
95
+ #
96
+ # You can use this option in order to forbid URI's with 'javascript' scheme
97
+ # for example.
98
+ #
99
+ # forbid_redirect_uri { |uri| uri.scheme.to_s.downcase == 'javascript' }
84
100
 
85
101
  # Specify what grant flows are enabled in array of Strings. The valid
86
102
  # strings and the flows they enable are:
@@ -98,7 +114,7 @@ Doorkeeper.configure do
98
114
  # http://tools.ietf.org/html/rfc6819#section-4.4.2
99
115
  # http://tools.ietf.org/html/rfc6819#section-4.4.3
100
116
  #
101
- # grant_flows %w(authorization_code client_credentials)
117
+ # grant_flows %w[authorization_code client_credentials]
102
118
 
103
119
  # Under some circumstances you might want to have applications auto-approved,
104
120
  # so that the user skips the authorization step.
@@ -1,4 +1,4 @@
1
- class CreateDoorkeeperTables < ActiveRecord::Migration
1
+ class CreateDoorkeeperTables < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  create_table :oauth_applications do |t|
4
4
  t.string :name, null: false
@@ -19,13 +19,24 @@ module Doorkeeper
19
19
  post :create, doorkeeper_application: {
20
20
  name: 'Example',
21
21
  redirect_uri: 'https://example.com' }
22
- end.to_not change { Doorkeeper::Application.count }
22
+ end.not_to change { Doorkeeper::Application.count }
23
23
  end
24
24
  end
25
25
 
26
26
  context 'when admin is authenticated' do
27
+ render_views
28
+
27
29
  before do
28
- allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(arg) { true })
30
+ allow(Doorkeeper.configuration).to receive(:authenticate_admin).and_return(->(*) { true })
31
+ end
32
+
33
+ it 'sorts applications by created_at' do
34
+ first_application = FactoryBot.create(:application)
35
+ second_application = FactoryBot.create(:application)
36
+ expect(Doorkeeper::Application).to receive(:ordered_by).and_call_original
37
+ get :index
38
+ expect(response.body).to have_selector("tbody tr:first-child#application_#{first_application.id}")
39
+ expect(response.body).to have_selector("tbody tr:last-child#application_#{second_application.id}")
29
40
  end
30
41
 
31
42
  it 'creates application' do
@@ -38,7 +49,7 @@ module Doorkeeper
38
49
  end
39
50
 
40
51
  it 'does not allow mass assignment of uid or secret' do
41
- application = FactoryGirl.create(:application)
52
+ application = FactoryBot.create(:application)
42
53
  put :update, id: application.id, doorkeeper_application: {
43
54
  uid: '1A2B3C4D',
44
55
  secret: '1A2B3C4D' }
@@ -47,7 +58,7 @@ module Doorkeeper
47
58
  end
48
59
 
49
60
  it 'updates application' do
50
- application = FactoryGirl.create(:application)
61
+ application = FactoryBot.create(:application)
51
62
  put :update, id: application.id, doorkeeper_application: {
52
63
  name: 'Example',
53
64
  redirect_uri: 'https://example.com' }