doorkeeper 5.0.2 → 5.1.0.rc2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +17 -4
  3. data/Appraisals +29 -3
  4. data/Dangerfile +5 -2
  5. data/Gemfile +14 -4
  6. data/NEWS.md +64 -19
  7. data/README.md +68 -487
  8. data/app/controllers/doorkeeper/token_info_controller.rb +1 -1
  9. data/app/controllers/doorkeeper/tokens_controller.rb +7 -7
  10. data/app/views/doorkeeper/applications/show.html.erb +1 -1
  11. data/app/views/layouts/doorkeeper/admin.html.erb +5 -3
  12. data/bin/console +15 -0
  13. data/doorkeeper.gemspec +3 -2
  14. data/gemfiles/rails_4_2.gemfile +8 -4
  15. data/gemfiles/rails_5_0.gemfile +9 -5
  16. data/gemfiles/rails_5_1.gemfile +9 -5
  17. data/gemfiles/rails_5_2.gemfile +9 -5
  18. data/gemfiles/rails_6_0.gemfile +16 -0
  19. data/gemfiles/rails_master.gemfile +8 -9
  20. data/lib/doorkeeper/config.rb +164 -11
  21. data/lib/doorkeeper/helpers/controller.rb +3 -2
  22. data/lib/doorkeeper/models/access_grant_mixin.rb +16 -1
  23. data/lib/doorkeeper/models/access_token_mixin.rb +54 -10
  24. data/lib/doorkeeper/models/application_mixin.rb +42 -1
  25. data/lib/doorkeeper/models/concerns/expirable.rb +3 -2
  26. data/lib/doorkeeper/models/concerns/reusable.rb +19 -0
  27. data/lib/doorkeeper/models/concerns/scopes.rb +5 -1
  28. data/lib/doorkeeper/models/concerns/secret_storable.rb +106 -0
  29. data/lib/doorkeeper/oauth/authorization/code.rb +1 -1
  30. data/lib/doorkeeper/oauth/authorization/token.rb +4 -2
  31. data/lib/doorkeeper/oauth/authorization_code_request.rb +1 -1
  32. data/lib/doorkeeper/oauth/client.rb +1 -1
  33. data/lib/doorkeeper/oauth/client_credentials/validation.rb +4 -3
  34. data/lib/doorkeeper/oauth/code_response.rb +2 -2
  35. data/lib/doorkeeper/oauth/error_response.rb +5 -1
  36. data/lib/doorkeeper/oauth/helpers/scope_checker.rb +23 -8
  37. data/lib/doorkeeper/oauth/helpers/unique_token.rb +12 -1
  38. data/lib/doorkeeper/oauth/helpers/uri_checker.rb +32 -0
  39. data/lib/doorkeeper/oauth/invalid_token_response.rb +4 -0
  40. data/lib/doorkeeper/oauth/password_access_token_request.rb +7 -2
  41. data/lib/doorkeeper/oauth/pre_authorization.rb +8 -3
  42. data/lib/doorkeeper/oauth/refresh_token_request.rb +4 -1
  43. data/lib/doorkeeper/oauth/token_introspection.rb +72 -6
  44. data/lib/doorkeeper/oauth/token_response.rb +2 -2
  45. data/lib/doorkeeper/orm/active_record/access_grant.rb +23 -2
  46. data/lib/doorkeeper/orm/active_record/application.rb +20 -2
  47. data/lib/doorkeeper/secret_storing/base.rb +63 -0
  48. data/lib/doorkeeper/secret_storing/bcrypt.rb +59 -0
  49. data/lib/doorkeeper/secret_storing/plain.rb +33 -0
  50. data/lib/doorkeeper/secret_storing/sha256_hash.rb +25 -0
  51. data/lib/doorkeeper/version.rb +3 -3
  52. data/lib/doorkeeper.rb +7 -0
  53. data/lib/generators/doorkeeper/templates/initializer.rb +90 -8
  54. data/spec/controllers/application_metal_controller_spec.rb +18 -4
  55. data/spec/controllers/authorizations_controller_spec.rb +3 -3
  56. data/spec/controllers/token_info_controller_spec.rb +1 -1
  57. data/spec/controllers/tokens_controller_spec.rb +85 -41
  58. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  59. data/spec/dummy/config/application.rb +12 -1
  60. data/spec/factories.rb +3 -3
  61. data/spec/lib/config_spec.rb +168 -0
  62. data/spec/lib/models/expirable_spec.rb +12 -0
  63. data/spec/lib/models/reusable_spec.rb +40 -0
  64. data/spec/lib/models/scopes_spec.rb +13 -1
  65. data/spec/lib/models/secret_storable_spec.rb +113 -0
  66. data/spec/lib/oauth/authorization_code_request_spec.rb +18 -1
  67. data/spec/lib/oauth/base_request_spec.rb +7 -7
  68. data/spec/lib/oauth/client_credentials/creator_spec.rb +51 -7
  69. data/spec/lib/oauth/client_credentials/validation_spec.rb +3 -0
  70. data/spec/lib/oauth/error_response_spec.rb +7 -1
  71. data/spec/lib/oauth/helpers/scope_checker_spec.rb +52 -17
  72. data/spec/lib/oauth/helpers/uri_checker_spec.rb +20 -2
  73. data/spec/lib/oauth/password_access_token_request_spec.rb +43 -12
  74. data/spec/lib/oauth/pre_authorization_spec.rb +24 -0
  75. data/spec/lib/oauth/token_request_spec.rb +16 -1
  76. data/spec/lib/oauth/token_response_spec.rb +13 -13
  77. data/spec/lib/oauth/token_spec.rb +14 -0
  78. data/spec/lib/secret_storing/base_spec.rb +60 -0
  79. data/spec/lib/secret_storing/bcrypt_spec.rb +49 -0
  80. data/spec/lib/secret_storing/plain_spec.rb +44 -0
  81. data/spec/lib/secret_storing/sha256_hash_spec.rb +48 -0
  82. data/spec/models/doorkeeper/access_grant_spec.rb +61 -0
  83. data/spec/models/doorkeeper/access_token_spec.rb +123 -0
  84. data/spec/models/doorkeeper/application_spec.rb +56 -0
  85. data/spec/requests/flows/authorization_code_spec.rb +41 -1
  86. data/spec/requests/flows/client_credentials_spec.rb +2 -2
  87. data/spec/requests/flows/implicit_grant_spec.rb +1 -1
  88. data/spec/requests/flows/password_spec.rb +7 -5
  89. data/spec/requests/flows/revoke_token_spec.rb +14 -30
  90. data/spec/routing/custom_controller_routes_spec.rb +4 -0
  91. data/spec/spec_helper.rb +2 -1
  92. data/spec/support/ruby_2_6_rails_4_2_patch.rb +14 -0
  93. data/spec/support/shared/hashing_shared_context.rb +36 -0
  94. metadata +59 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3a0fa2d314b8aa479233379028c00d8107830f46
4
- data.tar.gz: c0bb3f5658cbbc4f7b640e08ae418afab36d7225
2
+ SHA256:
3
+ metadata.gz: 4933a46b121732bd9b6cc44f53947863ab243f448224e444e6106890bb8d78ca
4
+ data.tar.gz: d2dd4869d2c08ab587908ab79edec49e307e8c2e73b7c54af4706620bc8fcb83
5
5
  SHA512:
6
- metadata.gz: 45411b41e6ca7e5b3016b6831efa7cb6df93dcca172ac1902a8561ca004f6701ebaf4364d5e12d439bd0867533aa4b98133224482cd91ce015b835b26753dc64
7
- data.tar.gz: 89aaf99254db0422ce86ed21f6e604ce8ecac6eb6c58070170b88be0fa02c338b71e7683d95f557319d75936e53f464e47118fbc85c35ac8a97cfd1588202622
6
+ metadata.gz: dcd3f3b72d7d3cfdd783dd89eb61be9e21cfd4460a48cea0919a398e10a6aad8e6472a325c338988ad6b888167b2d5037c2e41631e9d43a4fd24532d52dd69a9
7
+ data.tar.gz: 6dd4f697b11faa4f3702482071fba8383c196bccc448fde8b3a1fb6ef0bf10e687a8dbc8bc3385c857a071c57816cdfc82061061029ef9acaa9ac96fea0ce193
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
- cache: bundler
2
1
  language: ruby
3
- sudo: false
2
+ cache: bundler
4
3
 
5
4
  rvm:
6
5
  - 2.1
@@ -8,10 +7,12 @@ rvm:
8
7
  - 2.3
9
8
  - 2.4
10
9
  - 2.5
11
- - ruby-2.6.0-preview1
10
+ - 2.6.1
11
+ - ruby-head
12
12
 
13
13
  before_install:
14
- - gem update --system # Need for Ruby 2.5.0. https://github.com/travis-ci/travis-ci/issues/8978
14
+ - "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
15
+ - rvm @global do gem uninstall bundler -a -x -I || true
15
16
  - gem install bundler -v '~> 1.10'
16
17
 
17
18
  gemfile:
@@ -19,6 +20,7 @@ gemfile:
19
20
  - gemfiles/rails_5_0.gemfile
20
21
  - gemfiles/rails_5_1.gemfile
21
22
  - gemfiles/rails_5_2.gemfile
23
+ - gemfiles/rails_6_0.gemfile
22
24
  - gemfiles/rails_master.gemfile
23
25
 
24
26
  matrix:
@@ -35,11 +37,22 @@ matrix:
35
37
  rvm: 2.1
36
38
  - gemfile: gemfiles/rails_5_2.gemfile
37
39
  rvm: 2.1
40
+ - gemfile: gemfiles/rails_6_0.gemfile
41
+ rvm: 2.1
42
+ - gemfile: gemfiles/rails_6_0.gemfile
43
+ rvm: 2.2
44
+ - gemfile: gemfiles/rails_6_0.gemfile
45
+ rvm: 2.3
46
+ - gemfile: gemfiles/rails_6_0.gemfile
47
+ rvm: 2.4
38
48
  - gemfile: gemfiles/rails_master.gemfile
39
49
  rvm: 2.1
40
50
  - gemfile: gemfiles/rails_master.gemfile
41
51
  rvm: 2.2
42
52
  - gemfile: gemfiles/rails_master.gemfile
43
53
  rvm: 2.3
54
+ - gemfile: gemfiles/rails_master.gemfile
55
+ rvm: 2.4
44
56
  allow_failures:
45
57
  - gemfile: gemfiles/rails_master.gemfile
58
+ - rvm: ruby-head
data/Appraisals CHANGED
@@ -1,18 +1,44 @@
1
1
  appraise "rails-4-2" do
2
2
  gem "rails", "~> 4.2.0"
3
+ gem "grape", '~> 0.16', '< 0.19.2'
4
+ gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
3
5
  end
4
6
 
5
7
  appraise "rails-5-0" do
6
8
  gem "rails", "~> 5.0.0"
7
- gem "rspec-rails", "~> 3.7"
9
+ gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
8
10
  end
9
11
 
10
12
  appraise "rails-5-1" do
11
13
  gem "rails", "~> 5.1.0"
12
- gem "rspec-rails", "~> 3.7"
14
+ gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
15
+ end
16
+
17
+ appraise "rails-5-2" do
18
+ gem "rails", "~> 5.2.0"
19
+ gem "sqlite3", "~> 1.3", "< 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
20
+ end
21
+
22
+ appraise "rails-6-0" do
23
+ gem "rails", "~> 6.0.0.beta2"
24
+ gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
25
+
26
+ # TODO: Remove when rspec-rails 4.0 released
27
+ gem "rspec-core", github: "rspec/rspec-core"
28
+ gem "rspec-expectations", github: "rspec/rspec-expectations"
29
+ gem "rspec-mocks", github: "rspec/rspec-mocks"
30
+ gem "rspec-rails", github: "rspec/rspec-rails", branch: "4-0-dev"
31
+ gem "rspec-support", github: "rspec/rspec-support"
13
32
  end
14
33
 
15
34
  appraise "rails-master" do
16
35
  gem "rails", git: 'https://github.com/rails/rails'
17
- gem "arel", git: 'https://github.com/rails/arel'
36
+ gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
37
+
38
+ # TODO: Remove when rspec-rails 4.0 released
39
+ gem "rspec-core", github: "rspec/rspec-core"
40
+ gem "rspec-expectations", github: "rspec/rspec-expectations"
41
+ gem "rspec-mocks", github: "rspec/rspec-mocks"
42
+ gem "rspec-rails", github: "rspec/rspec-rails", branch: "4-0-dev"
43
+ gem "rspec-support", github: "rspec/rspec-support"
18
44
  end
data/Dangerfile CHANGED
@@ -17,7 +17,7 @@ end
17
17
  # --------------------------------------------------------------------------------------------------------------------
18
18
  # Has any changes happened inside the actual library code?
19
19
  # --------------------------------------------------------------------------------------------------------------------
20
- has_app_changes = !git.modified_files.grep(/lib/).empty?
20
+ has_app_changes = !git.modified_files.grep(/lib|app/).empty?
21
21
  has_spec_changes = !git.modified_files.grep(/spec/).empty?
22
22
 
23
23
  # --------------------------------------------------------------------------------------------------------------------
@@ -52,7 +52,10 @@ Here's an example of a #{CHANGELOG_FILE} entry:
52
52
  ```
53
53
  MARKDOWN
54
54
 
55
- fail("Please include a changelog entry. \nYou can find it at [#{CHANGELOG_FILE}](#{GITHUB_REPO}/blob/master/#{CHANGELOG_FILE}).")
55
+ warn(
56
+ "Please include a changelog entry. \nYou can find it at [#{CHANGELOG_FILE}](#{GITHUB_REPO}/blob/master/#{CHANGELOG_FILE})." +
57
+ "You can skip this warning only if you made some typo fix or other small changes that didn't affect the API."
58
+ )
56
59
  end
57
60
 
58
61
  if git.commits.any? { |commit| commit.message =~ /^Merge branch '#{github.branch_for_base}'/ }
data/Gemfile CHANGED
@@ -1,10 +1,20 @@
1
1
  source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
2
3
 
3
- gem "rails", "~> 5.2"
4
+ gemspec
5
+
6
+ gem "rails", "~> 6.0.0.beta3"
7
+
8
+ # TODO: Remove when rspec-rails 4.0 released
9
+ gem "rspec-core", github: "rspec/rspec-core"
10
+ gem "rspec-expectations", github: "rspec/rspec-expectations"
11
+ gem "rspec-mocks", github: "rspec/rspec-mocks"
12
+ gem "rspec-rails", github: "rspec/rspec-rails", branch: "4-0-dev"
13
+ gem "rspec-support", github: "rspec/rspec-support"
4
14
 
5
- gem "appraisal"
15
+ gem "bcrypt", "~> 3.1", require: false
6
16
 
7
17
  gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
8
- gem "sqlite3", platform: [:ruby, :mswin, :mingw, :x64_mingw]
18
+ gem "sqlite3", "~> 1.4", platform: [:ruby, :mswin, :mingw, :x64_mingw]
19
+
9
20
  gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
10
- gemspec
data/NEWS.md CHANGED
@@ -7,7 +7,52 @@ User-visible changes worth mentioning.
7
7
 
8
8
  ## master
9
9
 
10
- - [#] Add your description here.
10
+ - [#1208] Unify hashing implementation into secret storing strategies
11
+
12
+ **[IMPORTANT]**: If you have been using the master branch of doorkeeper with bcrypt in your Gemfile.lock,
13
+ your application secrets have been hashed using BCrypt. To restore this behavior, use the initializer option
14
+ `use_application_hashing using: 'Doorkeeper::SecretStoring::BCrypt`.
15
+
16
+ - [#1216] Add nil check to `expires_at` method.
17
+ - [#1215] Fix deprecates for Rails 6.
18
+ - [#1214] Scopes field accepts array.
19
+ - [#1209] Fix tokens validation for Token Introspection request.
20
+ - [#1202] Use correct HTTP status codes for error responses.
21
+
22
+ **[IMPORTANT]**: this change might break your application if you were relying on the previous
23
+ 401 status codes, this is now a 400 by default, or a 401 for `invalid_client` and `invalid_token` errors.
24
+
25
+ - [#1201] Fix custom TTL block `client` parameter to always be an `Doorkeeper::Application` instance.
26
+
27
+ **[IMPORTANT]**: those who defined `custom_access_token_expires_in` configuration option need to check
28
+ their block implementation: if you are using `oauth_client.application` to get `Doorkeeper::Application`
29
+ instance, then you need to replace it with just `oauth_client`.
30
+
31
+ - [#1200] Increase default Doorkeeper access token value complexity (`urlsafe_base64` instead of just `hex`)
32
+ matching RFC6749/RFC6750.
33
+
34
+ **[IMPORTANT]**: this change have possible side-effects in case you have custom database constraints for
35
+ access token value, application secrets, refresh tokens or you patched Doorkeeper models and introduced
36
+ token value validations, or you are using database with case-insensitive WHERE clause like MySQL
37
+ (you can face some collisions). Before this change access token value matched `[a-f0-9]` regex, and now
38
+ it matches `[a-zA-Z0-9\-_]`. In case you have such restrictions and your don't use custom token generator
39
+ please change configuration option `default_generator_method ` to `:hex`.
40
+
41
+ - [#1195] Allow to customize Token Introspection response (fixes #1194).
42
+ - [#1189] Option to set `token_reuse_limit`.
43
+ - [#1191] Try to load bcrypt for hashing of application secrets, but add fallback.
44
+
45
+ ## 5.1.0.rc1
46
+
47
+ - [#1188] Use `params` instead of `request.POST` in tokens controller (fixes #1183).
48
+ - [#1182] Fix loopback IP redirect URIs to conform with RFC8252, p. 7.3 (fixes #1170).
49
+ - [#1179] Authorization Code Grant Flow without client id returns invalid_client error.
50
+ - [#1177] Allow to limit `scopes` for certain `grant_types`
51
+ - [#1176] Fix test factory support for `factory_bot_rails`
52
+ - [#1175] Internal refactor: use `scopes_string` inside `scopes`.
53
+ - [#1168] Allow optional hashing of tokens and secrets.
54
+ - [#1164] Fix error when `root_path` is not defined.
55
+ - [#1162] Fix `enforce_content_type` for requests without body.
11
56
 
12
57
  ## 5.0.2
13
58
 
@@ -16,13 +61,13 @@ User-visible changes worth mentioning.
16
61
 
17
62
  ## 5.0.1
18
63
 
64
+ - [#1154] Refactor `StaleRecordsCleaner` to be ORM agnostic.
65
+ - [#1152] Fix migration template: change resource owner data type from integer to Rails generic `references`
66
+ - [#1151] Fix Refresh Token strategy: add proper validation of client credentials both for Public & Private clients.
67
+ - [#1149] Fix for `URIChecker#valid_for_authorization?` false negative when query is blank, but `?` present.
19
68
  - [#1140] Allow rendering custom errors from exceptions (issue #844). Originally opened as [#944].
20
69
  - [#1138] Revert regression bug (check for token expiration in Authorizations controller so authorization
21
70
  triggers every time)
22
- - [#1149] Fix for `URIChecker#valid_for_authorization?` false negative when query is blank, but `?` present.
23
- - [#1151] Fix Refresh Token strategy: add proper validation of client credentials both for Public & Private clients.
24
- - [#1152] Fix migration template: change resource owner data type from integer to Rails generic `references`
25
- - [#1154] Refactor `StaleRecordsCleaner` to be ORM agnostic.
26
71
 
27
72
  ## 5.0.0
28
73
 
@@ -30,14 +75,14 @@ User-visible changes worth mentioning.
30
75
 
31
76
  ## 5.0.0.rc2
32
77
 
33
- - [#1106] Restrict access to AdminController with 'Forbidden 403' if admin_authenticator is not
34
- configured by developers..
35
- - [#1108] Simple formating of callback URLs when listing oauth applications
78
+ - [#1122] Fix AuthorizationsController#new error response to be in JSON format
79
+ - [#1119] Fix token revocation for OAuth apps using "implicit" grant flow
36
80
  - [#1116] `AccessGrant`s will now be revoked along with `AccessToken`s when
37
81
  hitting the `AuthorizedApplicationController#destroy` route.
38
82
  - [#1114] Make token info endpoint's attributes consistent with token creation
39
- - [#1119] Fix token revocation for OAuth apps using "implicit" grant flow
40
- - [#1122] Fix AuthorizationsController#new error response to be in JSON format
83
+ - [#1108] Simple formating of callback URLs when listing oauth applications
84
+ - [#1106] Restrict access to AdminController with 'Forbidden 403' if admin_authenticator is not
85
+ configured by developers.
41
86
 
42
87
  ## 5.0.0.rc1
43
88
 
@@ -58,12 +103,12 @@ User-visible changes worth mentioning.
58
103
  `Doorkeeper#installed?` method
59
104
  - [#1031] Allow public clients to authenticate without `client_secret`. Define an app as
60
105
  either public or private/confidential
61
-
106
+
62
107
  **[IMPORTANT]**: all the applications (clients) now are considered as private by default.
63
108
  You need to manually change `confidential` column to `false` if you are using public clients,
64
109
  in other case your mobile (or other) applications will not be able to authorize.
65
110
  See [#1142](https://github.com/doorkeeper-gem/doorkeeper/issues/1142) for more details.
66
-
111
+
67
112
  - [#1010] Add configuration to enforce configured scopes (`default_scopes` and
68
113
  `optional_scopes`) for applications
69
114
  - [#1060] Ensure that the native redirect_uri parameter matches with redirect_uri of the client
@@ -81,26 +126,26 @@ User-visible changes worth mentioning.
81
126
  - [#1076] Add config to enforce content type to application/x-www-form-urlencoded
82
127
  - Fix bug with `force_ssl_in_redirect_uri` when it breaks existing applications with an
83
128
  SSL redirect_uri.
84
-
129
+
85
130
  ## 4.4.3
86
-
131
+
87
132
  - [#1143] Adds a config option `opt_out_native_route_change` to opt out of the breaking api
88
133
  changed introduced in https://github.com/doorkeeper-gem/doorkeeper/pull/1003
89
134
 
90
-
135
+
91
136
  ## 4.4.2
92
137
 
93
138
  - [#1130] Backport fix for native redirect_uri from 5.x.
94
-
139
+
95
140
  ## 4.4.1
96
141
 
97
142
  - [#1127] Backport token type to comply with the RFC6750 specification.
98
143
  - [#1125] Backport Quote surround I18n yes/no keys
99
-
144
+
100
145
  ## 4.4.0
101
-
146
+
102
147
  - [#1120] Backport security fix from 5.x for token revocation when using public clients
103
-
148
+
104
149
  **[IMPORTANT]**: all the applications (clients) now are considered as private by default.
105
150
  You need to manually change `confidential` column to `false` if you are using public clients,
106
151
  in other case your mobile (or other) applications will not be able to authorize.