doorkeeper 5.0.0 → 5.1.0.rc1
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.
- checksums.yaml +5 -5
- data/.travis.yml +12 -3
- data/Dangerfile +67 -0
- data/Gemfile +3 -1
- data/NEWS.md +49 -5
- data/README.md +19 -4
- data/app/controllers/doorkeeper/application_controller.rb +2 -0
- data/app/controllers/doorkeeper/application_metal_controller.rb +2 -0
- data/app/controllers/doorkeeper/applications_controller.rb +4 -2
- data/app/controllers/doorkeeper/authorizations_controller.rb +3 -3
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +2 -0
- data/app/controllers/doorkeeper/token_info_controller.rb +2 -0
- data/app/controllers/doorkeeper/tokens_controller.rb +8 -6
- data/app/helpers/doorkeeper/dashboard_helper.rb +2 -0
- data/app/validators/redirect_uri_validator.rb +2 -0
- data/app/views/doorkeeper/applications/show.html.erb +1 -1
- data/app/views/layouts/doorkeeper/admin.html.erb +5 -3
- data/bin/console +15 -0
- data/doorkeeper.gemspec +23 -22
- data/gemfiles/rails_4_2.gemfile +1 -0
- data/gemfiles/rails_5_0.gemfile +1 -0
- data/gemfiles/rails_5_1.gemfile +1 -0
- data/gemfiles/rails_5_2.gemfile +2 -1
- data/gemfiles/rails_master.gemfile +1 -0
- data/lib/doorkeeper/config.rb +80 -8
- data/lib/doorkeeper/engine.rb +2 -0
- data/lib/doorkeeper/errors.rb +17 -0
- data/lib/doorkeeper/grape/authorization_decorator.rb +2 -0
- data/lib/doorkeeper/grape/helpers.rb +2 -0
- data/lib/doorkeeper/helpers/controller.rb +5 -2
- data/lib/doorkeeper/models/access_grant_mixin.rb +13 -4
- data/lib/doorkeeper/models/access_token_mixin.rb +45 -12
- data/lib/doorkeeper/models/application_mixin.rb +54 -1
- data/lib/doorkeeper/models/concerns/accessible.rb +2 -0
- data/lib/doorkeeper/models/concerns/expirable.rb +2 -0
- data/lib/doorkeeper/models/concerns/hashable.rb +137 -0
- data/lib/doorkeeper/models/concerns/orderable.rb +2 -0
- data/lib/doorkeeper/models/concerns/ownership.rb +2 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +2 -0
- data/lib/doorkeeper/models/concerns/scopes.rb +3 -1
- data/lib/doorkeeper/oauth/authorization/code.rb +3 -1
- data/lib/doorkeeper/oauth/authorization/context.rb +2 -0
- data/lib/doorkeeper/oauth/authorization/token.rb +3 -1
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +2 -0
- data/lib/doorkeeper/oauth/authorization_code_request.rb +3 -1
- data/lib/doorkeeper/oauth/base_request.rb +2 -0
- data/lib/doorkeeper/oauth/base_response.rb +2 -0
- data/lib/doorkeeper/oauth/client/credentials.rb +2 -0
- data/lib/doorkeeper/oauth/client.rb +3 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +2 -0
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -0
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +6 -3
- data/lib/doorkeeper/oauth/client_credentials_request.rb +2 -0
- data/lib/doorkeeper/oauth/code_request.rb +2 -0
- data/lib/doorkeeper/oauth/code_response.rb +4 -2
- data/lib/doorkeeper/oauth/error.rb +2 -0
- data/lib/doorkeeper/oauth/error_response.rb +10 -0
- data/lib/doorkeeper/oauth/forbidden_token_response.rb +9 -2
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +25 -8
- data/lib/doorkeeper/oauth/helpers/unique_token.rb +2 -0
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +37 -2
- data/lib/doorkeeper/oauth/invalid_token_response.rb +18 -0
- data/lib/doorkeeper/oauth/password_access_token_request.rb +9 -2
- data/lib/doorkeeper/oauth/pre_authorization.rb +10 -3
- data/lib/doorkeeper/oauth/refresh_token_request.rb +14 -3
- data/lib/doorkeeper/oauth/scopes.rb +2 -0
- data/lib/doorkeeper/oauth/token.rb +2 -0
- data/lib/doorkeeper/oauth/token_introspection.rb +2 -0
- data/lib/doorkeeper/oauth/token_request.rb +2 -0
- data/lib/doorkeeper/oauth/token_response.rb +4 -2
- data/lib/doorkeeper/orm/active_record/access_grant.rb +22 -2
- data/lib/doorkeeper/orm/active_record/application.rb +16 -2
- data/lib/doorkeeper/orm/active_record.rb +2 -0
- data/lib/doorkeeper/rails/helpers.rb +4 -0
- data/lib/doorkeeper/rails/routes/mapper.rb +2 -0
- data/lib/doorkeeper/rails/routes/mapping.rb +2 -0
- data/lib/doorkeeper/rails/routes.rb +9 -2
- data/lib/doorkeeper/rake/db.rake +4 -4
- data/lib/doorkeeper/request/authorization_code.rb +2 -0
- data/lib/doorkeeper/request/client_credentials.rb +2 -0
- data/lib/doorkeeper/request/code.rb +2 -0
- data/lib/doorkeeper/request/password.rb +2 -0
- data/lib/doorkeeper/request/refresh_token.rb +2 -0
- data/lib/doorkeeper/request/strategy.rb +2 -0
- data/lib/doorkeeper/request/token.rb +2 -0
- data/lib/doorkeeper/request.rb +2 -0
- data/lib/doorkeeper/server.rb +2 -0
- data/lib/doorkeeper/stale_records_cleaner.rb +20 -0
- data/lib/doorkeeper/validations.rb +2 -0
- data/lib/doorkeeper/version.rb +4 -2
- data/lib/doorkeeper.rb +2 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +61 -3
- data/lib/generators/doorkeeper/templates/migration.rb.erb +2 -3
- data/spec/controllers/application_metal_controller_spec.rb +18 -4
- data/spec/controllers/applications_controller_spec.rb +37 -41
- data/spec/controllers/authorizations_controller_spec.rb +71 -18
- data/spec/controllers/protected_resources_controller_spec.rb +44 -2
- data/spec/controllers/tokens_controller_spec.rb +11 -16
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/controllers/application_controller.rb +1 -1
- data/spec/dummy/app/controllers/custom_authorizations_controller.rb +1 -1
- data/spec/dummy/app/controllers/home_controller.rb +1 -2
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/boot.rb +2 -4
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/doorkeeper.rb +2 -1
- data/spec/dummy/config/initializers/new_framework_defaults.rb +1 -3
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config.ru +1 -1
- data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +4 -4
- data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +1 -1
- data/spec/dummy/script/rails +4 -3
- data/spec/factories.rb +9 -9
- data/spec/generators/install_generator_spec.rb +4 -1
- data/spec/generators/templates/routes.rb +0 -1
- data/spec/generators/views_generator_spec.rb +1 -1
- data/spec/grape/grape_integration_spec.rb +1 -1
- data/spec/lib/config_spec.rb +109 -8
- data/spec/lib/doorkeeper_spec.rb +5 -5
- data/spec/lib/models/hashable_spec.rb +183 -0
- data/spec/lib/oauth/authorization_code_request_spec.rb +9 -6
- data/spec/lib/oauth/base_request_spec.rb +10 -10
- data/spec/lib/oauth/client/credentials_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +0 -2
- data/spec/lib/oauth/client_credentials/validation_spec.rb +5 -1
- data/spec/lib/oauth/client_credentials_integration_spec.rb +1 -1
- data/spec/lib/oauth/code_request_spec.rb +2 -2
- data/spec/lib/oauth/code_response_spec.rb +1 -1
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +52 -17
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +37 -8
- data/spec/lib/oauth/password_access_token_request_spec.rb +48 -15
- data/spec/lib/oauth/pre_authorization_spec.rb +24 -0
- data/spec/lib/oauth/refresh_token_request_spec.rb +11 -7
- data/spec/lib/oauth/token_request_spec.rb +5 -5
- data/spec/lib/oauth/token_response_spec.rb +13 -13
- data/spec/lib/oauth/token_spec.rb +18 -1
- data/spec/lib/server_spec.rb +6 -6
- data/spec/lib/{orm/active_record/stale_records_cleaner_spec.rb → stale_records_cleaner_spec.rb} +14 -4
- data/spec/models/doorkeeper/access_grant_spec.rb +61 -0
- data/spec/models/doorkeeper/access_token_spec.rb +137 -10
- data/spec/models/doorkeeper/application_spec.rb +41 -4
- data/spec/requests/applications/applications_request_spec.rb +2 -2
- data/spec/requests/endpoints/authorization_spec.rb +2 -2
- data/spec/requests/flows/authorization_code_errors_spec.rb +1 -1
- data/spec/requests/flows/authorization_code_spec.rb +115 -15
- data/spec/requests/flows/implicit_grant_errors_spec.rb +2 -2
- data/spec/requests/flows/password_spec.rb +10 -4
- data/spec/requests/flows/refresh_token_spec.rb +57 -0
- data/spec/requests/flows/revoke_token_spec.rb +23 -39
- data/spec/requests/protected_resources/private_api_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -1
- data/spec/support/doorkeeper_rspec.rb +2 -1
- data/spec/support/helpers/model_helper.rb +8 -4
- data/spec/support/helpers/url_helper.rb +11 -11
- data/spec/support/ruby_2_6_rails_4_2_patch.rb +14 -0
- data/spec/support/shared/controllers_shared_context.rb +56 -0
- data/spec/support/shared/hashing_shared_context.rb +29 -0
- data/spec/validators/redirect_uri_validator_spec.rb +2 -2
- metadata +31 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5773ab2b97881fdf1bb6fa66a4e176299d58c536f354ea9e9f4f7bb6dc0dcdea
|
|
4
|
+
data.tar.gz: 69ac6937d7eb7786a8c9ac331f540ef5aa1321b7c0624a0778c7437151764569
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e4b8470847ab8e642d50d27972838c0b5181b3c97c4a25afca18861b3878e513346f7b72d5c5d6c31b5d8513d90c1e6426e0cfcfce51a06b1e04e563ae09ab0
|
|
7
|
+
data.tar.gz: 79c4363faf9a3f41bc639ee6e6ec756efbd99a96e4670e788bc4201b6f69eb992ffc95f2f56e3efbcd5645f2ed76e2c8d29f6e9807ffb6841becd31d868c6963
|
data/.travis.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
cache: bundler
|
|
2
1
|
language: ruby
|
|
2
|
+
cache: bundler
|
|
3
3
|
sudo: false
|
|
4
4
|
|
|
5
5
|
rvm:
|
|
@@ -8,10 +8,12 @@ rvm:
|
|
|
8
8
|
- 2.3
|
|
9
9
|
- 2.4
|
|
10
10
|
- 2.5
|
|
11
|
-
-
|
|
11
|
+
- 2.6
|
|
12
|
+
- ruby-head
|
|
12
13
|
|
|
13
14
|
before_install:
|
|
14
|
-
-
|
|
15
|
+
- "find /home/travis/.rvm/rubies -wholename '*default/bundler-*.gemspec' -delete"
|
|
16
|
+
- rvm @global do gem uninstall bundler -a -x -I || true
|
|
15
17
|
- gem install bundler -v '~> 1.10'
|
|
16
18
|
|
|
17
19
|
gemfile:
|
|
@@ -23,6 +25,11 @@ gemfile:
|
|
|
23
25
|
|
|
24
26
|
matrix:
|
|
25
27
|
fast_finish: true
|
|
28
|
+
# Run Danger only once
|
|
29
|
+
include:
|
|
30
|
+
- rvm: 2.5
|
|
31
|
+
gemfile: gemfiles/rails_5_2.gemfile
|
|
32
|
+
script: bundle exec danger
|
|
26
33
|
exclude:
|
|
27
34
|
- gemfile: gemfiles/rails_5_0.gemfile
|
|
28
35
|
rvm: 2.1
|
|
@@ -36,5 +43,7 @@ matrix:
|
|
|
36
43
|
rvm: 2.2
|
|
37
44
|
- gemfile: gemfiles/rails_master.gemfile
|
|
38
45
|
rvm: 2.3
|
|
46
|
+
- gemfile: gemfiles/rails_master.gemfile
|
|
47
|
+
rvm: 2.4
|
|
39
48
|
allow_failures:
|
|
40
49
|
- gemfile: gemfiles/rails_master.gemfile
|
data/Dangerfile
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
CHANGELOG_FILE = 'NEWS.md'
|
|
2
|
+
GITHUB_REPO = 'https://github.com/doorkeeper-gem/doorkeeper'
|
|
3
|
+
|
|
4
|
+
def changelog_changed?
|
|
5
|
+
git.modified_files.include?(CHANGELOG_FILE) || git.added_files.include?(CHANGELOG_FILE)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def changelog_entry_example
|
|
9
|
+
pr_number = github.pr_json['number']
|
|
10
|
+
pr_title = github.pr_title
|
|
11
|
+
.sub(/[?.!,;]?$/, '')
|
|
12
|
+
.capitalize
|
|
13
|
+
|
|
14
|
+
"- [##{pr_number}]: #{pr_title}."
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# --------------------------------------------------------------------------------------------------------------------
|
|
18
|
+
# Has any changes happened inside the actual library code?
|
|
19
|
+
# --------------------------------------------------------------------------------------------------------------------
|
|
20
|
+
has_app_changes = !git.modified_files.grep(/lib|app/).empty?
|
|
21
|
+
has_spec_changes = !git.modified_files.grep(/spec/).empty?
|
|
22
|
+
|
|
23
|
+
# --------------------------------------------------------------------------------------------------------------------
|
|
24
|
+
# You've made changes to lib, but didn't write any tests?
|
|
25
|
+
# --------------------------------------------------------------------------------------------------------------------
|
|
26
|
+
if has_app_changes && !has_spec_changes
|
|
27
|
+
warn("There're library changes, but not tests. That's OK as long as you're refactoring existing code.", sticky: false)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# --------------------------------------------------------------------------------------------------------------------
|
|
31
|
+
# You've made changes to specs, but no library code has changed?
|
|
32
|
+
# --------------------------------------------------------------------------------------------------------------------
|
|
33
|
+
if !has_app_changes && has_spec_changes
|
|
34
|
+
message('We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!', sticky: false)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Mainly to encourage writing up some reasoning about the PR, rather than
|
|
38
|
+
# just leaving a title
|
|
39
|
+
if github.pr_body.length < 10
|
|
40
|
+
fail "Please provide a summary in the Pull Request description"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# --------------------------------------------------------------------------------------------------------------------
|
|
44
|
+
# Have you updated CHANGELOG.md?
|
|
45
|
+
# --------------------------------------------------------------------------------------------------------------------
|
|
46
|
+
# Add a CHANGELOG entry for app changes
|
|
47
|
+
if has_app_changes && !changelog_changed?
|
|
48
|
+
markdown <<-MARKDOWN
|
|
49
|
+
Here's an example of a #{CHANGELOG_FILE} entry:
|
|
50
|
+
```markdown
|
|
51
|
+
#{changelog_entry_example}
|
|
52
|
+
```
|
|
53
|
+
MARKDOWN
|
|
54
|
+
|
|
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
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
if git.commits.any? { |commit| commit.message =~ /^Merge branch '#{github.branch_for_base}'/ }
|
|
62
|
+
warn('Please rebase to get rid of the merge commits in this PR')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
if git.commits.length > 1
|
|
66
|
+
warn('Please squash all your commits to a single one')
|
|
67
|
+
end
|
data/Gemfile
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
source "https://rubygems.org"
|
|
2
2
|
|
|
3
|
-
gem "rails", "
|
|
3
|
+
gem "rails", ">= 5.2.1.1", "< 6.0"
|
|
4
4
|
|
|
5
5
|
gem "appraisal"
|
|
6
6
|
|
|
7
|
+
gem "bcrypt", "~> 3.1"
|
|
8
|
+
|
|
7
9
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
8
10
|
gem "sqlite3", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
9
11
|
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
|
data/NEWS.md
CHANGED
|
@@ -7,7 +7,30 @@ User-visible changes worth mentioning.
|
|
|
7
7
|
|
|
8
8
|
## master
|
|
9
9
|
|
|
10
|
-
- [#
|
|
10
|
+
- [#1188] Use `params` instead of `request.POST` in tokens controller (fixes #1183).
|
|
11
|
+
- [#1179] Authorization Code Grant Flow without client id returns invalid_client error.
|
|
12
|
+
- [#1182] Fix loopback IP redirect URIs to conform with RFC8252, p. 7.3 (fixes #1170).
|
|
13
|
+
- [#1177] Allow to limit `scopes` for certain `grant_types`
|
|
14
|
+
- [#1162] Fix `enforce_content_type` for requests without body.
|
|
15
|
+
- [#1164] Fix error when `root_path` is not defined.
|
|
16
|
+
- [#1175] Internal refactor: use `scopes_string` inside `scopes`.
|
|
17
|
+
- [#1176] Fix test factory support for `factory_bot_rails`
|
|
18
|
+
- [#1168]: Allow optional hashing of tokens and secrets.
|
|
19
|
+
|
|
20
|
+
## 5.0.2
|
|
21
|
+
|
|
22
|
+
- [#1158] Fix initializer template: change `handle_auth_errors` option
|
|
23
|
+
- [#1157] Remove redundant index from migration template.
|
|
24
|
+
|
|
25
|
+
## 5.0.1
|
|
26
|
+
|
|
27
|
+
- [#1140] Allow rendering custom errors from exceptions (issue #844). Originally opened as [#944].
|
|
28
|
+
- [#1138] Revert regression bug (check for token expiration in Authorizations controller so authorization
|
|
29
|
+
triggers every time)
|
|
30
|
+
- [#1149] Fix for `URIChecker#valid_for_authorization?` false negative when query is blank, but `?` present.
|
|
31
|
+
- [#1151] Fix Refresh Token strategy: add proper validation of client credentials both for Public & Private clients.
|
|
32
|
+
- [#1152] Fix migration template: change resource owner data type from integer to Rails generic `references`
|
|
33
|
+
- [#1154] Refactor `StaleRecordsCleaner` to be ORM agnostic.
|
|
11
34
|
|
|
12
35
|
## 5.0.0
|
|
13
36
|
|
|
@@ -43,6 +66,12 @@ User-visible changes worth mentioning.
|
|
|
43
66
|
`Doorkeeper#installed?` method
|
|
44
67
|
- [#1031] Allow public clients to authenticate without `client_secret`. Define an app as
|
|
45
68
|
either public or private/confidential
|
|
69
|
+
|
|
70
|
+
**[IMPORTANT]**: all the applications (clients) now are considered as private by default.
|
|
71
|
+
You need to manually change `confidential` column to `false` if you are using public clients,
|
|
72
|
+
in other case your mobile (or other) applications will not be able to authorize.
|
|
73
|
+
See [#1142](https://github.com/doorkeeper-gem/doorkeeper/issues/1142) for more details.
|
|
74
|
+
|
|
46
75
|
- [#1010] Add configuration to enforce configured scopes (`default_scopes` and
|
|
47
76
|
`optional_scopes`) for applications
|
|
48
77
|
- [#1060] Ensure that the native redirect_uri parameter matches with redirect_uri of the client
|
|
@@ -60,20 +89,31 @@ User-visible changes worth mentioning.
|
|
|
60
89
|
- [#1076] Add config to enforce content type to application/x-www-form-urlencoded
|
|
61
90
|
- Fix bug with `force_ssl_in_redirect_uri` when it breaks existing applications with an
|
|
62
91
|
SSL redirect_uri.
|
|
63
|
-
|
|
92
|
+
|
|
93
|
+
## 4.4.3
|
|
94
|
+
|
|
95
|
+
- [#1143] Adds a config option `opt_out_native_route_change` to opt out of the breaking api
|
|
96
|
+
changed introduced in https://github.com/doorkeeper-gem/doorkeeper/pull/1003
|
|
97
|
+
|
|
98
|
+
|
|
64
99
|
## 4.4.2
|
|
65
100
|
|
|
66
101
|
- [#1130] Backport fix for native redirect_uri from 5.x.
|
|
67
|
-
|
|
102
|
+
|
|
68
103
|
## 4.4.1
|
|
69
104
|
|
|
70
105
|
- [#1127] Backport token type to comply with the RFC6750 specification.
|
|
71
106
|
- [#1125] Backport Quote surround I18n yes/no keys
|
|
72
|
-
|
|
107
|
+
|
|
73
108
|
## 4.4.0
|
|
74
|
-
|
|
109
|
+
|
|
75
110
|
- [#1120] Backport security fix from 5.x for token revocation when using public clients
|
|
76
111
|
|
|
112
|
+
**[IMPORTANT]**: all the applications (clients) now are considered as private by default.
|
|
113
|
+
You need to manually change `confidential` column to `false` if you are using public clients,
|
|
114
|
+
in other case your mobile (or other) applications will not be able to authorize.
|
|
115
|
+
See [#1142](https://github.com/doorkeeper-gem/doorkeeper/issues/1142) for more details.
|
|
116
|
+
|
|
77
117
|
## 4.3.2
|
|
78
118
|
|
|
79
119
|
- [#1053] Support authorizing with query params in the request `redirect_uri` if explicitly present in app's `Application#redirect_uri`
|
|
@@ -101,6 +141,10 @@ User-visible changes worth mentioning.
|
|
|
101
141
|
- [#985] Generate valid migration files for Rails >= 5
|
|
102
142
|
- [#972] Replace Struct subclassing with block-form initialization
|
|
103
143
|
- [#1003] Use URL query param to pass through native redirect auth code so automated apps can find it.
|
|
144
|
+
|
|
145
|
+
**[IMPORTANT]**: Previously authorization code response route was `/oauth/authorize/<code>`,
|
|
146
|
+
now it is `oauth/authorize/native?code=<code>` (in order to help applications to automatically find the code value).
|
|
147
|
+
|
|
104
148
|
- [#868] `Scopes#&` and `Scopes#+` now take an array or any other enumerable
|
|
105
149
|
object.
|
|
106
150
|
- [#1019] Remove translation not in use: `invalid_resource_owner`.
|
data/README.md
CHANGED
|
@@ -23,6 +23,9 @@ Supported features:
|
|
|
23
23
|
- [OAuth 2.0 Token Revocation](http://tools.ietf.org/html/rfc7009)
|
|
24
24
|
- [OAuth 2.0 Token Introspection](https://tools.ietf.org/html/rfc7662)
|
|
25
25
|
|
|
26
|
+
See [list of tutorials](https://github.com/doorkeeper-gem/doorkeeper/wiki#how-tos--tutorials) in order to
|
|
27
|
+
learn how to use the gem or integrate it with other solutions / gems.
|
|
28
|
+
|
|
26
29
|
## Documentation valid for `master` branch
|
|
27
30
|
|
|
28
31
|
Please check the documentation for the version of doorkeeper you are using in:
|
|
@@ -50,6 +53,7 @@ https://github.com/doorkeeper-gem/doorkeeper/releases
|
|
|
50
53
|
- [Routes](#routes)
|
|
51
54
|
- [Authenticating](#authenticating)
|
|
52
55
|
- [Internationalization (I18n)](#internationalization-i18n)
|
|
56
|
+
- [Customizing errors](#customizing-errors)
|
|
53
57
|
- [Rake Tasks](#rake-tasks)
|
|
54
58
|
- [Protecting resources with OAuth (a.k.a your API endpoint)](#protecting-resources-with-oauth-aka-your-api-endpoint)
|
|
55
59
|
- [Ruby on Rails controllers](#ruby-on-rails-controllers)
|
|
@@ -113,7 +117,7 @@ migration:
|
|
|
113
117
|
[PKCE flow]: https://tools.ietf.org/html/rfc7636
|
|
114
118
|
|
|
115
119
|
```sh
|
|
116
|
-
|
|
120
|
+
rails generate doorkeeper:pkce
|
|
117
121
|
```
|
|
118
122
|
|
|
119
123
|
Then run migrations:
|
|
@@ -237,6 +241,14 @@ You may want to check other ways of authentication
|
|
|
237
241
|
Doorkeeper support multiple languages. See language files in
|
|
238
242
|
[the I18n repository](https://github.com/doorkeeper-gem/doorkeeper-i18n).
|
|
239
243
|
|
|
244
|
+
### Customizing errors
|
|
245
|
+
|
|
246
|
+
If you don't want to use default Doorkeeper error responses you can raise and rescue it's
|
|
247
|
+
exceptions. All you need is to set configuration option `handle_auth_errors` to `:raise`.
|
|
248
|
+
In this case Doorkeeper will raise `Doorkeeper::Errors::TokenForbidden`,
|
|
249
|
+
`Doorkeeper::Errors::TokenExpired`, `Doorkeeper::Errors::TokenRevoked` or other exceptions
|
|
250
|
+
that you need to care about.
|
|
251
|
+
|
|
240
252
|
### Rake Tasks
|
|
241
253
|
|
|
242
254
|
If you are using `rake`, you can load rake tasks provided by this gem, by adding
|
|
@@ -372,7 +384,7 @@ end
|
|
|
372
384
|
Please note that there is a logical OR between multiple required scopes. In the
|
|
373
385
|
above example, `doorkeeper_authorize! :admin, :write` means that the access
|
|
374
386
|
token is required to have either `:admin` scope or `:write` scope, but does not
|
|
375
|
-
need have both of them.
|
|
387
|
+
need to have both of them.
|
|
376
388
|
|
|
377
389
|
If you want to require the access token to have multiple scopes at the same
|
|
378
390
|
time, use multiple `doorkeeper_authorize!`, for example:
|
|
@@ -448,8 +460,11 @@ token owner.
|
|
|
448
460
|
|
|
449
461
|
### Applications list
|
|
450
462
|
|
|
451
|
-
By default, the applications list (`/oauth/applications`) is publicly available.
|
|
452
|
-
|
|
463
|
+
By default, the applications list (`/oauth/applications`) is publicly available (before 5.0 release).
|
|
464
|
+
Starting from Doorkeeper 5.0 it returns 403 Forbidden if `admin_authenticator` option is not configured
|
|
465
|
+
by developers.
|
|
466
|
+
|
|
467
|
+
To change the protection rules of this endpoint you should uncomment these lines:
|
|
453
468
|
|
|
454
469
|
```ruby
|
|
455
470
|
# config/initializers/doorkeeper.rb
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Doorkeeper
|
|
2
4
|
class ApplicationsController < Doorkeeper::ApplicationController
|
|
3
5
|
layout 'doorkeeper/admin' unless Doorkeeper.configuration.api_only
|
|
@@ -77,8 +79,8 @@ module Doorkeeper
|
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
def application_params
|
|
80
|
-
params.require(:doorkeeper_application)
|
|
81
|
-
permit(:name, :redirect_uri, :scopes, :confidential)
|
|
82
|
+
params.require(:doorkeeper_application)
|
|
83
|
+
.permit(:name, :redirect_uri, :scopes, :confidential)
|
|
82
84
|
end
|
|
83
85
|
end
|
|
84
86
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Doorkeeper
|
|
2
4
|
class AuthorizationsController < Doorkeeper::ApplicationController
|
|
3
5
|
before_action :authenticate_resource_owner!
|
|
@@ -41,13 +43,11 @@ module Doorkeeper
|
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
def matching_token?
|
|
44
|
-
|
|
46
|
+
AccessToken.matching_token_for(
|
|
45
47
|
pre_auth.client,
|
|
46
48
|
current_resource_owner.id,
|
|
47
49
|
pre_auth.scopes
|
|
48
50
|
)
|
|
49
|
-
|
|
50
|
-
token && token.accessible?
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def redirect_or_render(auth)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module Doorkeeper
|
|
2
4
|
class TokensController < Doorkeeper::ApplicationMetalController
|
|
3
5
|
def create
|
|
4
6
|
response = authorize_response
|
|
5
|
-
headers.merge!
|
|
7
|
+
headers.merge!(response.headers)
|
|
6
8
|
self.response_body = response.body.to_json
|
|
7
9
|
self.status = response.status
|
|
8
|
-
rescue Errors::DoorkeeperError =>
|
|
9
|
-
handle_token_exception
|
|
10
|
+
rescue Errors::DoorkeeperError => error
|
|
11
|
+
handle_token_exception(error)
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
# OAuth 2.0 Token Revocation - http://tools.ietf.org/html/rfc7009
|
|
@@ -73,12 +75,12 @@ module Doorkeeper
|
|
|
73
75
|
end
|
|
74
76
|
|
|
75
77
|
def token
|
|
76
|
-
@token ||= AccessToken.by_token(
|
|
77
|
-
AccessToken.by_refresh_token(
|
|
78
|
+
@token ||= AccessToken.by_token(params['token']) ||
|
|
79
|
+
AccessToken.by_refresh_token(params['token'])
|
|
78
80
|
end
|
|
79
81
|
|
|
80
82
|
def strategy
|
|
81
|
-
@strategy ||= server.token_request
|
|
83
|
+
@strategy ||= server.token_request(params[:grant_type])
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
def authorize_response
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<p><code class="bg-light" id="application_id"><%= @application.uid %></code></p>
|
|
9
9
|
|
|
10
10
|
<h4><%= t('.secret') %>:</h4>
|
|
11
|
-
<p><code class="bg-light" id="secret"><%= @application.
|
|
11
|
+
<p><code class="bg-light" id="secret"><%= @application.plaintext_secret %></code></p>
|
|
12
12
|
|
|
13
13
|
<h4><%= t('.scopes') %>:</h4>
|
|
14
14
|
<p><code class="bg-light" id="scopes"><%= @application.scopes.presence || raw(' ') %></code></p>
|
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
<li class="nav-item <%= 'active' if request.path == oauth_applications_path %>">
|
|
18
18
|
<%= link_to t('doorkeeper.layouts.admin.nav.applications'), oauth_applications_path, class: 'nav-link' %>
|
|
19
19
|
</li>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
<% if respond_to?(:root_path) %>
|
|
21
|
+
<li class="nav-item">
|
|
22
|
+
<%= link_to t('doorkeeper.layouts.admin.nav.home'), root_path, class: 'nav-link' %>
|
|
23
|
+
</li>
|
|
24
|
+
<% end %>
|
|
23
25
|
</ul>
|
|
24
26
|
</div>
|
|
25
27
|
</nav>
|
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'rails/all'
|
|
5
|
+
require 'doorkeeper'
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start(__FILE__)
|
data/doorkeeper.gemspec
CHANGED
|
@@ -2,29 +2,30 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
|
2
2
|
|
|
3
3
|
require 'doorkeeper/version'
|
|
4
4
|
|
|
5
|
-
Gem::Specification.new do |
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
Gem::Specification.new do |gem|
|
|
6
|
+
gem.name = 'doorkeeper'
|
|
7
|
+
gem.version = Doorkeeper.gem_version
|
|
8
|
+
gem.authors = ['Felipe Elias Philipp', 'Tute Costa', 'Jon Moss', 'Nikita Bulai']
|
|
9
|
+
gem.email = %w(bulaj.nikita@gmail.com)
|
|
10
|
+
gem.homepage = 'https://github.com/doorkeeper-gem/doorkeeper'
|
|
11
|
+
gem.summary = 'OAuth 2 provider for Rails and Grape'
|
|
12
|
+
gem.description = 'Doorkeeper is an OAuth 2 provider for Rails and Grape.'
|
|
13
|
+
gem.license = 'MIT'
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
|
16
|
+
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
|
17
|
+
gem.require_paths = ['lib']
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
gem.add_dependency 'railties', '>= 4.2'
|
|
20
|
+
gem.required_ruby_version = '>= 2.1'
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
gem.add_development_dependency 'capybara', '~> 2.18'
|
|
23
|
+
gem.add_development_dependency 'coveralls'
|
|
24
|
+
gem.add_development_dependency 'danger', '~> 5.0'
|
|
25
|
+
gem.add_development_dependency 'grape'
|
|
26
|
+
gem.add_development_dependency 'database_cleaner', '~> 1.6'
|
|
27
|
+
gem.add_development_dependency 'factory_bot', '~> 4.8'
|
|
28
|
+
gem.add_development_dependency 'generator_spec', '~> 0.9.3'
|
|
29
|
+
gem.add_development_dependency 'rake', '>= 11.3.0'
|
|
30
|
+
gem.add_development_dependency 'rspec-rails'
|
|
30
31
|
end
|
data/gemfiles/rails_4_2.gemfile
CHANGED
data/gemfiles/rails_5_0.gemfile
CHANGED
data/gemfiles/rails_5_1.gemfile
CHANGED
data/gemfiles/rails_5_2.gemfile
CHANGED
|
@@ -6,6 +6,7 @@ gem "rails", git: 'https://github.com/rails/rails'
|
|
|
6
6
|
gem "arel", git: 'https://github.com/rails/arel'
|
|
7
7
|
|
|
8
8
|
gem "appraisal"
|
|
9
|
+
gem "bcrypt", "~> 3.1"
|
|
9
10
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
10
11
|
gem "sqlite3", platform: [:ruby, :mswin, :mingw, :x64_mingw]
|
|
11
12
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw]
|