doorkeeper 5.2.0.rc2 → 5.2.0.rc3

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +1 -1
  3. data/CHANGELOG.md +15 -2
  4. data/Gemfile +1 -1
  5. data/README.md +9 -1
  6. data/app/controllers/doorkeeper/application_metal_controller.rb +1 -1
  7. data/app/controllers/doorkeeper/authorizations_controller.rb +11 -9
  8. data/config/locales/en.yml +5 -1
  9. data/doorkeeper.gemspec +8 -0
  10. data/gemfiles/rails_6_0.gemfile +1 -1
  11. data/lib/doorkeeper.rb +1 -0
  12. data/lib/doorkeeper/config.rb +41 -2
  13. data/lib/doorkeeper/errors.rb +13 -18
  14. data/lib/doorkeeper/helpers/controller.rb +6 -2
  15. data/lib/doorkeeper/oauth/authorization/code.rb +1 -5
  16. data/lib/doorkeeper/oauth/authorization_code_request.rb +18 -9
  17. data/lib/doorkeeper/oauth/base_request.rb +2 -0
  18. data/lib/doorkeeper/oauth/client_credentials/validation.rb +8 -0
  19. data/lib/doorkeeper/oauth/code_request.rb +5 -11
  20. data/lib/doorkeeper/oauth/invalid_request_response.rb +43 -0
  21. data/lib/doorkeeper/oauth/password_access_token_request.rb +7 -2
  22. data/lib/doorkeeper/oauth/pre_authorization.rb +70 -37
  23. data/lib/doorkeeper/oauth/refresh_token_request.rb +5 -2
  24. data/lib/doorkeeper/oauth/token_introspection.rb +4 -1
  25. data/lib/doorkeeper/oauth/token_request.rb +4 -18
  26. data/lib/doorkeeper/orm/active_record.rb +2 -2
  27. data/lib/doorkeeper/orm/active_record/application.rb +1 -1
  28. data/lib/doorkeeper/orm/active_record/redirect_uri_validator.rb +61 -0
  29. data/lib/doorkeeper/request.rb +6 -11
  30. data/lib/doorkeeper/request/authorization_code.rb +2 -0
  31. data/lib/doorkeeper/server.rb +2 -6
  32. data/lib/doorkeeper/version.rb +1 -1
  33. data/lib/generators/doorkeeper/templates/initializer.rb +33 -2
  34. data/lib/generators/doorkeeper/templates/migration.rb.erb +1 -1
  35. data/spec/controllers/authorizations_controller_spec.rb +127 -61
  36. data/spec/controllers/protected_resources_controller_spec.rb +3 -3
  37. data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +1 -1
  38. data/spec/lib/config_spec.rb +17 -0
  39. data/spec/lib/oauth/authorization_code_request_spec.rb +11 -1
  40. data/spec/lib/oauth/base_request_spec.rb +33 -16
  41. data/spec/lib/oauth/code_request_spec.rb +27 -28
  42. data/spec/lib/oauth/invalid_request_response_spec.rb +75 -0
  43. data/spec/lib/oauth/pre_authorization_spec.rb +80 -55
  44. data/spec/lib/oauth/refresh_token_request_spec.rb +1 -0
  45. data/spec/lib/oauth/token_request_spec.rb +20 -17
  46. data/spec/lib/server_spec.rb +0 -12
  47. data/spec/requests/endpoints/authorization_spec.rb +21 -5
  48. data/spec/requests/endpoints/token_spec.rb +1 -1
  49. data/spec/requests/flows/authorization_code_errors_spec.rb +1 -0
  50. data/spec/requests/flows/authorization_code_spec.rb +77 -23
  51. data/spec/requests/flows/client_credentials_spec.rb +38 -0
  52. data/spec/requests/flows/implicit_grant_errors_spec.rb +22 -10
  53. data/spec/requests/flows/implicit_grant_spec.rb +9 -8
  54. data/spec/requests/flows/password_spec.rb +37 -0
  55. data/spec/requests/flows/refresh_token_spec.rb +1 -1
  56. data/spec/support/helpers/request_spec_helper.rb +14 -2
  57. data/spec/validators/redirect_uri_validator_spec.rb +1 -1
  58. metadata +12 -4
  59. data/app/validators/redirect_uri_validator.rb +0 -60
@@ -172,7 +172,7 @@ describe "Refresh Token Flow" do
172
172
  post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
173
173
 
174
174
  should_not_have_json "refresh_token"
175
- should_have_json "error", "invalid_request"
175
+ should_have_json "error", "invalid_grant"
176
176
  end
177
177
  end
178
178
 
@@ -54,7 +54,7 @@ module RequestSpecHelper
54
54
  end
55
55
 
56
56
  def with_header(header, value)
57
- page.driver.header header, value
57
+ page.driver.header(header, value)
58
58
  end
59
59
 
60
60
  def basic_auth_header_for_client(client)
@@ -86,8 +86,20 @@ module RequestSpecHelper
86
86
  i_should_see translated_error_message(key)
87
87
  end
88
88
 
89
+ def i_should_not_see_translated_error_message(key)
90
+ i_should_not_see translated_error_message(key)
91
+ end
92
+
89
93
  def translated_error_message(key)
90
- I18n.translate key, scope: %i[doorkeeper errors messages]
94
+ I18n.translate(key, scope: %i[doorkeeper errors messages])
95
+ end
96
+
97
+ def i_should_see_translated_invalid_request_error_message(key, value)
98
+ i_should_see translated_invalid_request_error_message(key, value)
99
+ end
100
+
101
+ def translated_invalid_request_error_message(key, value)
102
+ I18n.translate key, scope: %i[doorkeeper errors messages invalid_request], value: value
91
103
  end
92
104
 
93
105
  def response_status_should_be(status)
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe RedirectUriValidator do
5
+ describe Doorkeeper::RedirectUriValidator do
6
6
  subject do
7
7
  FactoryBot.create(:application)
8
8
  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: 5.2.0.rc2
4
+ version: 5.2.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Elias Philipp
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-06-17 00:00:00.000000000 Z
14
+ date: 2019-08-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: railties
@@ -198,7 +198,6 @@ files:
198
198
  - app/controllers/doorkeeper/token_info_controller.rb
199
199
  - app/controllers/doorkeeper/tokens_controller.rb
200
200
  - app/helpers/doorkeeper/dashboard_helper.rb
201
- - app/validators/redirect_uri_validator.rb
202
201
  - app/views/doorkeeper/applications/_delete_form.html.erb
203
202
  - app/views/doorkeeper/applications/_form.html.erb
204
203
  - app/views/doorkeeper/applications/edit.html.erb
@@ -261,6 +260,7 @@ files:
261
260
  - lib/doorkeeper/oauth/helpers/scope_checker.rb
262
261
  - lib/doorkeeper/oauth/helpers/unique_token.rb
263
262
  - lib/doorkeeper/oauth/helpers/uri_checker.rb
263
+ - lib/doorkeeper/oauth/invalid_request_response.rb
264
264
  - lib/doorkeeper/oauth/invalid_token_response.rb
265
265
  - lib/doorkeeper/oauth/nonstandard.rb
266
266
  - lib/doorkeeper/oauth/password_access_token_request.rb
@@ -275,6 +275,7 @@ files:
275
275
  - lib/doorkeeper/orm/active_record/access_grant.rb
276
276
  - lib/doorkeeper/orm/active_record/access_token.rb
277
277
  - lib/doorkeeper/orm/active_record/application.rb
278
+ - lib/doorkeeper/orm/active_record/redirect_uri_validator.rb
278
279
  - lib/doorkeeper/orm/active_record/stale_records_cleaner.rb
279
280
  - lib/doorkeeper/rails/helpers.rb
280
281
  - lib/doorkeeper/rails/routes.rb
@@ -396,6 +397,7 @@ files:
396
397
  - spec/lib/oauth/helpers/scope_checker_spec.rb
397
398
  - spec/lib/oauth/helpers/unique_token_spec.rb
398
399
  - spec/lib/oauth/helpers/uri_checker_spec.rb
400
+ - spec/lib/oauth/invalid_request_response_spec.rb
399
401
  - spec/lib/oauth/invalid_token_response_spec.rb
400
402
  - spec/lib/oauth/password_access_token_request_spec.rb
401
403
  - spec/lib/oauth/pre_authorization_spec.rb
@@ -453,7 +455,12 @@ files:
453
455
  homepage: https://github.com/doorkeeper-gem/doorkeeper
454
456
  licenses:
455
457
  - MIT
456
- metadata: {}
458
+ metadata:
459
+ homepage_uri: https://github.com/doorkeeper-gem/doorkeeper
460
+ changelog_uri: https://github.com/doorkeeper-gem/doorkeeper/blob/master/CHANGELOG.md
461
+ source_code_uri: https://github.com/doorkeeper-gem/doorkeeper
462
+ bug_tracker_uri: https://github.com/doorkeeper-gem/doorkeeper/issues
463
+ documentation_uri: https://doorkeeper.gitbook.io/guides/
457
464
  post_install_message:
458
465
  rdoc_options: []
459
466
  require_paths:
@@ -557,6 +564,7 @@ test_files:
557
564
  - spec/lib/oauth/helpers/scope_checker_spec.rb
558
565
  - spec/lib/oauth/helpers/unique_token_spec.rb
559
566
  - spec/lib/oauth/helpers/uri_checker_spec.rb
567
+ - spec/lib/oauth/invalid_request_response_spec.rb
560
568
  - spec/lib/oauth/invalid_token_response_spec.rb
561
569
  - spec/lib/oauth/password_access_token_request_spec.rb
562
570
  - spec/lib/oauth/pre_authorization_spec.rb
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "uri"
4
-
5
- # ActiveModel validator for redirect URI validation in according
6
- # to OAuth standards and Doorkeeper configuration.
7
- #
8
- class RedirectUriValidator < ActiveModel::EachValidator
9
- def validate_each(record, attribute, value)
10
- if value.blank?
11
- return if Doorkeeper.configuration.allow_blank_redirect_uri?(record)
12
-
13
- record.errors.add(attribute, :blank)
14
- else
15
- value.split.each do |val|
16
- next if oob_redirect_uri?(val)
17
-
18
- uri = ::URI.parse(val)
19
- record.errors.add(attribute, :forbidden_uri) if forbidden_uri?(uri)
20
- record.errors.add(attribute, :fragment_present) unless uri.fragment.nil?
21
- record.errors.add(attribute, :unspecified_scheme) if unspecified_scheme?(uri)
22
- record.errors.add(attribute, :relative_uri) if relative_uri?(uri)
23
- record.errors.add(attribute, :secured_uri) if invalid_ssl_uri?(uri)
24
- end
25
- end
26
- rescue URI::InvalidURIError
27
- record.errors.add(attribute, :invalid_uri)
28
- end
29
-
30
- private
31
-
32
- def oob_redirect_uri?(uri)
33
- Doorkeeper::OAuth::NonStandard::IETF_WG_OAUTH2_OOB_METHODS.include?(uri)
34
- end
35
-
36
- def forbidden_uri?(uri)
37
- Doorkeeper.configuration.forbid_redirect_uri.call(uri)
38
- end
39
-
40
- def unspecified_scheme?(uri)
41
- return true if uri.opaque.present?
42
-
43
- %w[localhost].include?(uri.try(:scheme))
44
- end
45
-
46
- def relative_uri?(uri)
47
- uri.scheme.nil? && uri.host.nil?
48
- end
49
-
50
- def invalid_ssl_uri?(uri)
51
- forces_ssl = Doorkeeper.configuration.force_ssl_in_redirect_uri
52
- non_https = uri.try(:scheme) == "http"
53
-
54
- if forces_ssl.respond_to?(:call)
55
- forces_ssl.call(uri) && non_https
56
- else
57
- forces_ssl && non_https
58
- end
59
- end
60
- end