doorkeeper 4.4.3 → 5.0.3
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.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.gitlab-ci.yml +16 -0
- data/.travis.yml +7 -0
- data/Appraisals +2 -2
- data/Dangerfile +64 -0
- data/Gemfile +1 -1
- data/NEWS.md +98 -8
- data/README.md +110 -12
- data/Rakefile +6 -0
- data/UPGRADE.md +2 -0
- data/app/assets/stylesheets/doorkeeper/admin/application.css +2 -2
- data/app/controllers/doorkeeper/application_controller.rb +6 -3
- data/app/controllers/doorkeeper/application_metal_controller.rb +6 -0
- data/app/controllers/doorkeeper/applications_controller.rb +46 -24
- data/app/controllers/doorkeeper/authorizations_controller.rb +55 -12
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +21 -2
- data/app/controllers/doorkeeper/token_info_controller.rb +2 -0
- data/app/controllers/doorkeeper/tokens_controller.rb +4 -6
- data/app/helpers/doorkeeper/dashboard_helper.rb +9 -7
- data/app/validators/redirect_uri_validator.rb +5 -2
- data/app/views/doorkeeper/applications/_delete_form.html.erb +3 -1
- data/app/views/doorkeeper/applications/_form.html.erb +25 -24
- data/app/views/doorkeeper/applications/edit.html.erb +1 -1
- data/app/views/doorkeeper/applications/index.html.erb +17 -7
- data/app/views/doorkeeper/applications/new.html.erb +1 -1
- data/app/views/doorkeeper/applications/show.html.erb +6 -6
- data/app/views/doorkeeper/authorizations/error.html.erb +1 -1
- data/app/views/doorkeeper/authorizations/new.html.erb +4 -0
- data/app/views/layouts/doorkeeper/admin.html.erb +15 -15
- data/config/locales/en.yml +10 -1
- data/doorkeeper.gemspec +25 -26
- data/gemfiles/rails_5_2.gemfile +1 -1
- data/gemfiles/rails_master.gemfile +4 -1
- data/lib/doorkeeper/config.rb +81 -40
- data/lib/doorkeeper/engine.rb +6 -0
- data/lib/doorkeeper/errors.rb +17 -3
- data/lib/doorkeeper/grape/authorization_decorator.rb +2 -0
- data/lib/doorkeeper/grape/helpers.rb +3 -1
- data/lib/doorkeeper/helpers/controller.rb +9 -2
- data/lib/doorkeeper/models/access_grant_mixin.rb +73 -0
- data/lib/doorkeeper/models/access_token_mixin.rb +44 -25
- data/lib/doorkeeper/models/application_mixin.rb +2 -0
- data/lib/doorkeeper/models/concerns/accessible.rb +2 -0
- data/lib/doorkeeper/models/concerns/expirable.rb +2 -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 +33 -8
- data/lib/doorkeeper/oauth/authorization/context.rb +17 -0
- data/lib/doorkeeper/oauth/authorization/token.rb +38 -14
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +2 -0
- data/lib/doorkeeper/oauth/authorization_code_request.rb +29 -2
- data/lib/doorkeeper/oauth/base_request.rb +22 -9
- data/lib/doorkeeper/oauth/base_response.rb +2 -0
- data/lib/doorkeeper/oauth/client/credentials.rb +3 -1
- data/lib/doorkeeper/oauth/client.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +4 -1
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +7 -2
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +5 -5
- data/lib/doorkeeper/oauth/client_credentials_request.rb +1 -3
- data/lib/doorkeeper/oauth/code_request.rb +2 -0
- data/lib/doorkeeper/oauth/code_response.rb +2 -0
- data/lib/doorkeeper/oauth/error.rb +2 -0
- data/lib/doorkeeper/oauth/error_response.rb +21 -3
- data/lib/doorkeeper/oauth/forbidden_token_response.rb +9 -2
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +2 -8
- data/lib/doorkeeper/oauth/helpers/unique_token.rb +2 -0
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +5 -2
- data/lib/doorkeeper/oauth/invalid_token_response.rb +18 -0
- data/lib/doorkeeper/oauth/password_access_token_request.rb +9 -4
- data/lib/doorkeeper/oauth/pre_authorization.rb +43 -11
- data/lib/doorkeeper/oauth/refresh_token_request.rb +16 -3
- data/lib/doorkeeper/oauth/scopes.rb +3 -1
- data/lib/doorkeeper/oauth/token.rb +7 -2
- data/lib/doorkeeper/oauth/token_introspection.rb +4 -2
- data/lib/doorkeeper/oauth/token_request.rb +2 -0
- data/lib/doorkeeper/oauth/token_response.rb +6 -2
- data/lib/doorkeeper/oauth.rb +13 -0
- data/lib/doorkeeper/orm/active_record/application.rb +75 -12
- data/lib/doorkeeper/orm/active_record/stale_records_cleaner.rb +26 -0
- data/lib/doorkeeper/orm/active_record.rb +4 -0
- data/lib/doorkeeper/rails/helpers.rb +6 -4
- data/lib/doorkeeper/rails/routes/mapper.rb +2 -0
- data/lib/doorkeeper/rails/routes/mapping.rb +2 -0
- data/lib/doorkeeper/rails/routes.rb +23 -8
- data/lib/doorkeeper/rake/db.rake +40 -0
- data/lib/doorkeeper/rake/setup.rake +6 -0
- data/lib/doorkeeper/rake.rb +14 -0
- data/lib/doorkeeper/request/authorization_code.rb +1 -1
- data/lib/doorkeeper/request/client_credentials.rb +1 -1
- data/lib/doorkeeper/request/code.rb +1 -1
- data/lib/doorkeeper/request/password.rb +1 -1
- data/lib/doorkeeper/request/refresh_token.rb +1 -1
- data/lib/doorkeeper/request/strategy.rb +2 -0
- data/lib/doorkeeper/request/token.rb +1 -1
- data/lib/doorkeeper/request.rb +29 -34
- 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 +6 -24
- data/lib/doorkeeper.rb +20 -17
- data/lib/generators/doorkeeper/application_owner_generator.rb +23 -18
- data/lib/generators/doorkeeper/confidential_applications_generator.rb +32 -0
- data/lib/generators/doorkeeper/install_generator.rb +17 -9
- data/lib/generators/doorkeeper/migration_generator.rb +23 -18
- data/lib/generators/doorkeeper/pkce_generator.rb +32 -0
- data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +29 -24
- data/lib/generators/doorkeeper/templates/add_confidential_to_applications.rb.erb +13 -0
- data/lib/generators/doorkeeper/templates/enable_pkce_migration.rb.erb +6 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +96 -13
- data/lib/generators/doorkeeper/templates/migration.rb.erb +2 -3
- data/lib/generators/doorkeeper/views_generator.rb +3 -1
- data/spec/controllers/application_metal_controller_spec.rb +50 -0
- data/spec/controllers/applications_controller_spec.rb +123 -14
- data/spec/controllers/authorizations_controller_spec.rb +334 -51
- data/spec/controllers/protected_resources_controller_spec.rb +60 -18
- data/spec/controllers/token_info_controller_spec.rb +4 -12
- data/spec/controllers/tokens_controller_spec.rb +17 -20
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- 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 +5 -6
- data/spec/dummy/config/initializers/doorkeeper.rb +12 -6
- data/spec/dummy/config/initializers/new_framework_defaults.rb +2 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/routes.rb +3 -42
- 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/db/migrate/20170822064514_enable_pkce.rb +6 -0
- data/spec/dummy/db/migrate/{20180210183654_add_confidential_to_application.rb → 20180210183654_add_confidential_to_applications.rb} +1 -1
- data/spec/dummy/db/schema.rb +36 -36
- data/spec/dummy/script/rails +4 -3
- data/spec/factories.rb +6 -6
- data/spec/generators/application_owner_generator_spec.rb +1 -1
- data/spec/generators/confidential_applications_generator_spec.rb +45 -0
- data/spec/generators/install_generator_spec.rb +5 -2
- data/spec/generators/migration_generator_spec.rb +1 -1
- data/spec/generators/pkce_generator_spec.rb +43 -0
- data/spec/generators/previous_refresh_token_generator_spec.rb +1 -1
- data/spec/generators/templates/routes.rb +0 -1
- data/spec/generators/views_generator_spec.rb +2 -2
- data/spec/grape/grape_integration_spec.rb +2 -2
- data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +1 -1
- data/spec/lib/config_spec.rb +105 -39
- data/spec/lib/doorkeeper_spec.rb +6 -131
- data/spec/lib/models/expirable_spec.rb +0 -3
- data/spec/lib/models/revocable_spec.rb +0 -2
- data/spec/lib/models/scopes_spec.rb +0 -4
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +0 -4
- data/spec/lib/oauth/authorization_code_request_spec.rb +17 -7
- data/spec/lib/oauth/base_request_spec.rb +49 -11
- data/spec/lib/oauth/base_response_spec.rb +1 -1
- data/spec/lib/oauth/client/credentials_spec.rb +2 -4
- data/spec/lib/oauth/client_credentials/creator_spec.rb +5 -1
- data/spec/lib/oauth/client_credentials/issuer_spec.rb +24 -7
- data/spec/lib/oauth/client_credentials/validation_spec.rb +4 -4
- data/spec/lib/oauth/client_credentials_integration_spec.rb +2 -2
- data/spec/lib/oauth/client_credentials_request_spec.rb +3 -5
- data/spec/lib/oauth/client_spec.rb +0 -3
- data/spec/lib/oauth/code_request_spec.rb +5 -3
- data/spec/lib/oauth/code_response_spec.rb +1 -1
- data/spec/lib/oauth/error_response_spec.rb +0 -3
- data/spec/lib/oauth/error_spec.rb +0 -2
- data/spec/lib/oauth/forbidden_token_response_spec.rb +1 -4
- data/spec/lib/oauth/helpers/scope_checker_spec.rb +8 -11
- data/spec/lib/oauth/helpers/unique_token_spec.rb +0 -1
- data/spec/lib/oauth/helpers/uri_checker_spec.rb +22 -13
- data/spec/lib/oauth/invalid_token_response_spec.rb +1 -4
- data/spec/lib/oauth/password_access_token_request_spec.rb +53 -6
- data/spec/lib/oauth/pre_authorization_spec.rb +33 -4
- data/spec/lib/oauth/refresh_token_request_spec.rb +22 -14
- data/spec/lib/oauth/scopes_spec.rb +0 -3
- data/spec/lib/oauth/token_request_spec.rb +8 -9
- data/spec/lib/oauth/token_response_spec.rb +0 -1
- data/spec/lib/oauth/token_spec.rb +40 -14
- data/spec/lib/request/strategy_spec.rb +0 -1
- data/spec/lib/server_spec.rb +7 -7
- data/spec/lib/stale_records_cleaner_spec.rb +89 -0
- data/spec/models/doorkeeper/access_grant_spec.rb +44 -1
- data/spec/models/doorkeeper/access_token_spec.rb +80 -32
- data/spec/models/doorkeeper/application_spec.rb +293 -221
- data/spec/requests/applications/applications_request_spec.rb +134 -1
- data/spec/requests/applications/authorized_applications_spec.rb +1 -1
- data/spec/requests/endpoints/authorization_spec.rb +3 -3
- data/spec/requests/endpoints/token_spec.rb +7 -5
- data/spec/requests/flows/authorization_code_errors_spec.rb +2 -2
- data/spec/requests/flows/authorization_code_spec.rb +258 -2
- data/spec/requests/flows/client_credentials_spec.rb +46 -6
- data/spec/requests/flows/implicit_grant_errors_spec.rb +3 -3
- data/spec/requests/flows/implicit_grant_spec.rb +38 -11
- data/spec/requests/flows/password_spec.rb +61 -3
- data/spec/requests/flows/refresh_token_spec.rb +59 -2
- data/spec/requests/flows/revoke_token_spec.rb +20 -20
- data/spec/requests/flows/skip_authorization_spec.rb +16 -11
- data/spec/requests/protected_resources/metal_spec.rb +1 -1
- data/spec/requests/protected_resources/private_api_spec.rb +3 -3
- data/spec/routing/custom_controller_routes_spec.rb +59 -7
- data/spec/routing/default_routes_spec.rb +2 -2
- data/spec/routing/scoped_routes_spec.rb +16 -2
- data/spec/spec_helper.rb +54 -3
- data/spec/spec_helper_integration.rb +2 -74
- data/spec/support/dependencies/{factory_girl.rb → factory_bot.rb} +0 -0
- data/spec/support/doorkeeper_rspec.rb +20 -0
- data/spec/support/helpers/authorization_request_helper.rb +4 -4
- data/spec/support/helpers/model_helper.rb +8 -4
- data/spec/support/helpers/request_spec_helper.rb +10 -2
- data/spec/support/helpers/url_helper.rb +18 -14
- data/spec/support/http_method_shim.rb +12 -16
- data/spec/support/shared/controllers_shared_context.rb +56 -0
- data/spec/validators/redirect_uri_validator_spec.rb +9 -3
- data/spec/version/version_spec.rb +3 -3
- data/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css +4 -5
- metadata +54 -35
- data/lib/generators/doorkeeper/add_client_confidentiality_generator.rb +0 -31
- data/lib/generators/doorkeeper/templates/add_confidential_to_application_migration.rb.erb +0 -11
- data/spec/controllers/application_metal_controller.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 897eb14bd6b334b3b9f69f5cd54bfe524baddc09b3f96159f29a3c0b32b89d9b
|
4
|
+
data.tar.gz: b7bdd3e4d3cef46cb68fca0ac0bc854b5fa28c170c70a244b331b223d035d16f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff4eb6145d1a432a2cb31055ccf4fcbbaa0d91f3cb8c59ad061ede4d25b6ca345e1b5404c7180816524b5e0c650e359189d42790be61d025eeb940781accac52
|
7
|
+
data.tar.gz: 30463a001c175d07cecda2f760ed669c5c460c6fd0e3ed802b9988c8ca3b15e80fd335022f61b9cec9954d7906c53e160a3462df8988f9f0a756dff2a7452cb1
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
dependency_scanning:
|
2
|
+
image: docker:stable
|
3
|
+
variables:
|
4
|
+
DOCKER_DRIVER: overlay2
|
5
|
+
allow_failure: true
|
6
|
+
services:
|
7
|
+
- docker:stable-dind
|
8
|
+
script:
|
9
|
+
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
10
|
+
- docker run
|
11
|
+
--env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}"
|
12
|
+
--volume "$PWD:/code"
|
13
|
+
--volume /var/run/docker.sock:/var/run/docker.sock
|
14
|
+
"registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$SP_VERSION" /code
|
15
|
+
artifacts:
|
16
|
+
paths: [gl-dependency-scanning-report.json]
|
data/.travis.yml
CHANGED
@@ -8,6 +8,7 @@ rvm:
|
|
8
8
|
- 2.3
|
9
9
|
- 2.4
|
10
10
|
- 2.5
|
11
|
+
- ruby-2.6.0-preview1
|
11
12
|
|
12
13
|
before_install:
|
13
14
|
- gem update --system # Need for Ruby 2.5.0. https://github.com/travis-ci/travis-ci/issues/8978
|
@@ -21,6 +22,12 @@ gemfile:
|
|
21
22
|
- gemfiles/rails_master.gemfile
|
22
23
|
|
23
24
|
matrix:
|
25
|
+
fast_finish: true
|
26
|
+
# Run Danger only once
|
27
|
+
include:
|
28
|
+
- rvm: 2.5
|
29
|
+
gemfile: gemfiles/rails_5_2.gemfile
|
30
|
+
script: bundle exec danger
|
24
31
|
exclude:
|
25
32
|
- gemfile: gemfiles/rails_5_0.gemfile
|
26
33
|
rvm: 2.1
|
data/Appraisals
CHANGED
@@ -4,12 +4,12 @@ end
|
|
4
4
|
|
5
5
|
appraise "rails-5-0" do
|
6
6
|
gem "rails", "~> 5.0.0"
|
7
|
-
gem "rspec-rails", "~> 3.
|
7
|
+
gem "rspec-rails", "~> 3.7"
|
8
8
|
end
|
9
9
|
|
10
10
|
appraise "rails-5-1" do
|
11
11
|
gem "rails", "~> 5.1.0"
|
12
|
-
gem "rspec-rails", "~> 3.
|
12
|
+
gem "rspec-rails", "~> 3.7"
|
13
13
|
end
|
14
14
|
|
15
15
|
appraise "rails-master" do
|
data/Dangerfile
ADDED
@@ -0,0 +1,64 @@
|
|
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/).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
|
+
fail("Please include a changelog entry. \nYou can find it at [#{CHANGELOG_FILE}](#{GITHUB_REPO}/blob/master/#{CHANGELOG_FILE}).")
|
56
|
+
end
|
57
|
+
|
58
|
+
if git.commits.any? { |commit| commit.message =~ /^Merge branch '#{github.branch_for_base}'/ }
|
59
|
+
warn('Please rebase to get rid of the merge commits in this PR')
|
60
|
+
end
|
61
|
+
|
62
|
+
if git.commits.length > 1
|
63
|
+
warn('Please squash all your commits to a single one')
|
64
|
+
end
|
data/Gemfile
CHANGED
data/NEWS.md
CHANGED
@@ -1,25 +1,111 @@
|
|
1
1
|
# News
|
2
2
|
|
3
|
-
|
3
|
+
See https://github.com/doorkeeper-gem/doorkeeper/wiki/Migration-from-old-versions for
|
4
|
+
upgrade guides.
|
4
5
|
|
5
|
-
|
6
|
+
User-visible changes worth mentioning.
|
6
7
|
|
8
|
+
## 5.0.3
|
9
|
+
|
10
|
+
[#1371] Backport: Add #as_json method and attributes serialization restriction for Application model.
|
11
|
+
Fixes information disclosure vulnerability (CVE-2020-10187).
|
12
|
+
|
13
|
+
## 5.0.2
|
14
|
+
|
15
|
+
- [#1158] Fix initializer template: change `handle_auth_errors` option
|
16
|
+
- [#1157] Remove redundant index from migration template.
|
17
|
+
|
18
|
+
## 5.0.1
|
19
|
+
|
20
|
+
- [#1140] Allow rendering custom errors from exceptions (issue #844). Originally opened as [#944].
|
21
|
+
- [#1138] Revert regression bug (check for token expiration in Authorizations controller so authorization
|
22
|
+
triggers every time)
|
23
|
+
- [#1149] Fix for `URIChecker#valid_for_authorization?` false negative when query is blank, but `?` present.
|
24
|
+
- [#1151] Fix Refresh Token strategy: add proper validation of client credentials both for Public & Private clients.
|
25
|
+
- [#1152] Fix migration template: change resource owner data type from integer to Rails generic `references`
|
26
|
+
- [#1154] Refactor `StaleRecordsCleaner` to be ORM agnostic.
|
27
|
+
|
28
|
+
## 5.0.0
|
29
|
+
|
30
|
+
- [#1127] Change the token_type initials of the Banner Token to uppercase to comply with the RFC6750 specification.
|
31
|
+
|
32
|
+
## 5.0.0.rc2
|
33
|
+
|
34
|
+
- [#1106] Restrict access to AdminController with 'Forbidden 403' if admin_authenticator is not
|
35
|
+
configured by developers..
|
36
|
+
- [#1108] Simple formating of callback URLs when listing oauth applications
|
37
|
+
- [#1116] `AccessGrant`s will now be revoked along with `AccessToken`s when
|
38
|
+
hitting the `AuthorizedApplicationController#destroy` route.
|
39
|
+
- [#1114] Make token info endpoint's attributes consistent with token creation
|
40
|
+
- [#1119] Fix token revocation for OAuth apps using "implicit" grant flow
|
41
|
+
- [#1122] Fix AuthorizationsController#new error response to be in JSON format
|
42
|
+
|
43
|
+
## 5.0.0.rc1
|
44
|
+
|
45
|
+
- [#1103] Allow customizing use_refresh_token
|
46
|
+
- [#1089] Removed enable_pkce_without_secret configuration option
|
47
|
+
- [#1102] Expiration time based on scopes
|
48
|
+
- [#1099] All the configuration variables in `Doorkeeper.configuration` now
|
49
|
+
always return a non-nil value (`true` or `false`)
|
50
|
+
- [#1099] ORM / Query optimization: Do not revoke the refresh token if it is not enabled
|
51
|
+
in `doorkeeper.rb`
|
52
|
+
- [#996] Expiration Time Base On Grant Type
|
53
|
+
- [#997] Allow PKCE authorization_code flow as specified in RFC7636
|
54
|
+
- [#907] Fix lookup for matching tokens in certain edge-cases
|
55
|
+
- [#992] Add API option to use Doorkeeper without management views for API only
|
56
|
+
Rails applications (`api_only`)
|
57
|
+
- [#1045] Validate redirect_uri as the native URI when making authorization code requests
|
58
|
+
- [#1048] Remove deprecated `Doorkeeper#configured?`, `Doorkeeper#database_installed?`, and
|
59
|
+
`Doorkeeper#installed?` method
|
60
|
+
- [#1031] Allow public clients to authenticate without `client_secret`. Define an app as
|
61
|
+
either public or private/confidential
|
62
|
+
|
63
|
+
**[IMPORTANT]**: all the applications (clients) now are considered as private by default.
|
64
|
+
You need to manually change `confidential` column to `false` if you are using public clients,
|
65
|
+
in other case your mobile (or other) applications will not be able to authorize.
|
66
|
+
See [#1142](https://github.com/doorkeeper-gem/doorkeeper/issues/1142) for more details.
|
67
|
+
|
68
|
+
- [#1010] Add configuration to enforce configured scopes (`default_scopes` and
|
69
|
+
`optional_scopes`) for applications
|
70
|
+
- [#1060] Ensure that the native redirect_uri parameter matches with redirect_uri of the client
|
71
|
+
- [#1064] Add :before_successful_authorization and :after_successful_authorization hooks
|
72
|
+
- [#1069] Upgrade Bootstrap to 4 for Admin
|
73
|
+
- [#1068] Add rake task to cleanup databases that can become large over time
|
74
|
+
- [#1072] AuthorizationsController: Memoize strategy.authorize_response result to enable
|
75
|
+
subclasses to use the response object.
|
76
|
+
- [#1075] Call `before_successful_authorization` and `after_successful_authorization` hooks
|
77
|
+
on `create` action as well as `new`
|
78
|
+
- [#1082] Fix #916: remember routes mapping and use it required places (fix error with
|
79
|
+
customized Token Info route).
|
80
|
+
- [#1086, #1088] Fix bug with receiving default scopes in the token even if they are
|
81
|
+
not present in the application scopes (use scopes intersection).
|
82
|
+
- [#1076] Add config to enforce content type to application/x-www-form-urlencoded
|
83
|
+
- Fix bug with `force_ssl_in_redirect_uri` when it breaks existing applications with an
|
84
|
+
SSL redirect_uri.
|
85
|
+
|
7
86
|
## 4.4.3
|
8
|
-
|
9
|
-
|
10
|
-
https://github.com/doorkeeper-gem/doorkeeper/pull/1003
|
87
|
+
|
88
|
+
- [#1143] Adds a config option `opt_out_native_route_change` to opt out of the breaking api
|
89
|
+
changed introduced in https://github.com/doorkeeper-gem/doorkeeper/pull/1003
|
11
90
|
|
91
|
+
|
12
92
|
## 4.4.2
|
13
|
-
- [#1130] Backport fix for native redirect_uri from 5.x.
|
14
93
|
|
94
|
+
- [#1130] Backport fix for native redirect_uri from 5.x.
|
95
|
+
|
15
96
|
## 4.4.1
|
16
97
|
|
17
98
|
- [#1127] Backport token type to comply with the RFC6750 specification.
|
18
99
|
- [#1125] Backport Quote surround I18n yes/no keys
|
19
|
-
|
100
|
+
|
20
101
|
## 4.4.0
|
21
|
-
|
102
|
+
|
22
103
|
- [#1120] Backport security fix from 5.x for token revocation when using public clients
|
104
|
+
|
105
|
+
**[IMPORTANT]**: all the applications (clients) now are considered as private by default.
|
106
|
+
You need to manually change `confidential` column to `false` if you are using public clients,
|
107
|
+
in other case your mobile (or other) applications will not be able to authorize.
|
108
|
+
See [#1142](https://github.com/doorkeeper-gem/doorkeeper/issues/1142) for more details.
|
23
109
|
|
24
110
|
## 4.3.2
|
25
111
|
|
@@ -48,6 +134,10 @@ User-visible changes worth mentioning.
|
|
48
134
|
- [#985] Generate valid migration files for Rails >= 5
|
49
135
|
- [#972] Replace Struct subclassing with block-form initialization
|
50
136
|
- [#1003] Use URL query param to pass through native redirect auth code so automated apps can find it.
|
137
|
+
|
138
|
+
**[IMPORTANT]**: Previously authorization code response route was `/oauth/authorize/<code>`,
|
139
|
+
now it is `oauth/authorize/native?code=<code>` (in order to help applications to automatically find the code value).
|
140
|
+
|
51
141
|
- [#868] `Scopes#&` and `Scopes#+` now take an array or any other enumerable
|
52
142
|
object.
|
53
143
|
- [#1019] Remove translation not in use: `invalid_resource_owner`.
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# Doorkeeper
|
1
|
+
# Doorkeeper — awesome OAuth 2 provider for your Rails / Grape app.
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/doorkeeper.svg)](https://rubygems.org/gems/doorkeeper)
|
4
4
|
[![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper.svg?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper)
|
5
|
-
[![Dependency Status](https://gemnasium.com/doorkeeper-gem/doorkeeper.svg?travis)](https://gemnasium.com/doorkeeper-gem/doorkeeper)
|
6
5
|
[![Code Climate](https://codeclimate.com/github/doorkeeper-gem/doorkeeper.svg)](https://codeclimate.com/github/doorkeeper-gem/doorkeeper)
|
7
6
|
[![Coverage Status](https://coveralls.io/repos/github/doorkeeper-gem/doorkeeper/badge.svg?branch=master)](https://coveralls.io/github/doorkeeper-gem/doorkeeper?branch=master)
|
8
7
|
[![Security](https://hakiri.io/github/doorkeeper-gem/doorkeeper/master.svg)](https://hakiri.io/github/doorkeeper-gem/doorkeeper/master)
|
8
|
+
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
|
9
9
|
|
10
|
-
Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider
|
11
|
-
functionality to your Rails or Grape application.
|
10
|
+
Doorkeeper is a gem (Rails engine) that makes it easy to introduce OAuth 2 provider
|
11
|
+
functionality to your Ruby on Rails or Grape application.
|
12
12
|
|
13
13
|
Supported features:
|
14
14
|
|
@@ -19,15 +19,20 @@ Supported features:
|
|
19
19
|
- [Implicit grant](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.2)
|
20
20
|
- [Resource Owner Password Credentials](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.3)
|
21
21
|
- [Client Credentials](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.4)
|
22
|
+
- [Proof Key for Code Exchange](https://tools.ietf.org/html/rfc7636)
|
22
23
|
- [OAuth 2.0 Token Revocation](http://tools.ietf.org/html/rfc7009)
|
23
24
|
- [OAuth 2.0 Token Introspection](https://tools.ietf.org/html/rfc7662)
|
24
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
|
+
|
25
29
|
## Documentation valid for `master` branch
|
26
30
|
|
27
31
|
Please check the documentation for the version of doorkeeper you are using in:
|
28
32
|
https://github.com/doorkeeper-gem/doorkeeper/releases
|
29
33
|
|
30
|
-
- See the [
|
34
|
+
- See the [Wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki)
|
35
|
+
- See [upgrade guides](https://github.com/doorkeeper-gem/doorkeeper/wiki/Migration-from-old-versions)
|
31
36
|
- For general questions, please post in [Stack Overflow](http://stackoverflow.com/questions/tagged/doorkeeper)
|
32
37
|
- See [SECURITY.md](SECURITY.md) for this project's security disclose
|
33
38
|
policy
|
@@ -44,9 +49,12 @@ https://github.com/doorkeeper-gem/doorkeeper/releases
|
|
44
49
|
- [MongoDB](#mongodb)
|
45
50
|
- [Sequel](#sequel)
|
46
51
|
- [Couchbase](#couchbase)
|
52
|
+
- [API mode](#api-mode)
|
47
53
|
- [Routes](#routes)
|
48
54
|
- [Authenticating](#authenticating)
|
49
55
|
- [Internationalization (I18n)](#internationalization-i18n)
|
56
|
+
- [Customizing errors](#customizing-errors)
|
57
|
+
- [Rake Tasks](#rake-tasks)
|
50
58
|
- [Protecting resources with OAuth (a.k.a your API endpoint)](#protecting-resources-with-oauth-aka-your-api-endpoint)
|
51
59
|
- [Ruby on Rails controllers](#ruby-on-rails-controllers)
|
52
60
|
- [Grape endpoints](#grape-endpoints)
|
@@ -103,12 +111,26 @@ for each table that includes a `resource_owner_id` column:
|
|
103
111
|
add_foreign_key :table_name, :users, column: :resource_owner_id
|
104
112
|
```
|
105
113
|
|
114
|
+
If you want to enable [PKCE flow] for mobile apps, you need to generate another
|
115
|
+
migration:
|
116
|
+
|
117
|
+
[PKCE flow]: https://tools.ietf.org/html/rfc7636
|
118
|
+
|
119
|
+
```sh
|
120
|
+
rails generate doorkeeper:pkce
|
121
|
+
```
|
122
|
+
|
106
123
|
Then run migrations:
|
107
124
|
|
108
125
|
```sh
|
109
126
|
rake db:migrate
|
110
127
|
```
|
111
128
|
|
129
|
+
Ensure to use non-confidential apps for pkce. PKCE is created, because
|
130
|
+
you cannot trust its apps' secret. So whatever app needs pkce: it means, it cannot
|
131
|
+
be a confidential app by design.
|
132
|
+
|
133
|
+
|
112
134
|
Remember to add associations to your model so the related records are deleted.
|
113
135
|
If you don't do this an `ActiveRecord::InvalidForeignKey`-error will be raised
|
114
136
|
when you try to destroy a model with related access grants or access tokens.
|
@@ -146,6 +168,24 @@ Use [doorkeeper-couchbase] extension if you are using Couchbase database.
|
|
146
168
|
|
147
169
|
[doorkeeper-couchbase]: https://github.com/acaprojects/doorkeeper-couchbase
|
148
170
|
|
171
|
+
### API mode
|
172
|
+
|
173
|
+
By default Doorkeeper uses full Rails stack to provide all the OAuth 2 functionality
|
174
|
+
with additional features like administration area for managing applications. By the
|
175
|
+
way, starting from Doorkeeper 5 you can use API mode for your [API only Rails 5 applications](http://edgeguides.rubyonrails.org/api_app.html).
|
176
|
+
All you need is just to configure the gem to work in desired mode:
|
177
|
+
|
178
|
+
``` ruby
|
179
|
+
Doorkeeper.configure do
|
180
|
+
# ...
|
181
|
+
|
182
|
+
api_only
|
183
|
+
end
|
184
|
+
```
|
185
|
+
|
186
|
+
Keep in mind, that in this mode you will not be able to access `Applications` or
|
187
|
+
`Authorized Applications` controllers because they will be skipped. CSRF protections (which are otherwise enabled) will be skipped, and all the redirects will be returned as JSON response with corresponding locations.
|
188
|
+
|
149
189
|
### Routes
|
150
190
|
|
151
191
|
The installation script will also automatically add the Doorkeeper routes into
|
@@ -198,7 +238,44 @@ You may want to check other ways of authentication
|
|
198
238
|
|
199
239
|
### Internationalization (I18n)
|
200
240
|
|
201
|
-
See language files in
|
241
|
+
Doorkeeper support multiple languages. See language files in
|
242
|
+
[the I18n repository](https://github.com/doorkeeper-gem/doorkeeper-i18n).
|
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
|
+
|
252
|
+
### Rake Tasks
|
253
|
+
|
254
|
+
If you are using `rake`, you can load rake tasks provided by this gem, by adding
|
255
|
+
the following line to your `Rakefile`:
|
256
|
+
|
257
|
+
```ruby
|
258
|
+
Doorkeeper::Rake.load_tasks
|
259
|
+
```
|
260
|
+
|
261
|
+
#### Cleaning up
|
262
|
+
|
263
|
+
By default Doorkeeper is retaining expired and revoked access tokens and grants.
|
264
|
+
This allows to keep an audit log of those records, but it also leads to the
|
265
|
+
corresponding tables to grow large over the lifetime of your application.
|
266
|
+
|
267
|
+
If you are concerned about those tables growing too large,
|
268
|
+
you can regularly run the following rake task to remove stale entries
|
269
|
+
from the database:
|
270
|
+
|
271
|
+
```rake
|
272
|
+
rake doorkeeper:db:cleanup
|
273
|
+
```
|
274
|
+
|
275
|
+
Note that this will remove tokens that are expired according to the configured TTL
|
276
|
+
in `Doorkeeper.configuration.access_token_expires_in`. The specific `expires_in`
|
277
|
+
value of each access token **is not considered**. The same is true for access
|
278
|
+
grants.
|
202
279
|
|
203
280
|
## Protecting resources with OAuth (a.k.a your API endpoint)
|
204
281
|
|
@@ -210,7 +287,9 @@ protect. For example:
|
|
210
287
|
|
211
288
|
``` ruby
|
212
289
|
class Api::V1::ProductsController < Api::V1::ApiController
|
213
|
-
before_action :doorkeeper_authorize! #
|
290
|
+
before_action :doorkeeper_authorize! # Requires access token for all actions
|
291
|
+
|
292
|
+
# before_action -> { doorkeeper_authorize! :read, :write }
|
214
293
|
|
215
294
|
# your actions
|
216
295
|
end
|
@@ -305,7 +384,7 @@ end
|
|
305
384
|
Please note that there is a logical OR between multiple required scopes. In the
|
306
385
|
above example, `doorkeeper_authorize! :admin, :write` means that the access
|
307
386
|
token is required to have either `:admin` scope or `:write` scope, but does not
|
308
|
-
need have both of them.
|
387
|
+
need to have both of them.
|
309
388
|
|
310
389
|
If you want to require the access token to have multiple scopes at the same
|
311
390
|
time, use multiple `doorkeeper_authorize!`, for example:
|
@@ -381,8 +460,11 @@ token owner.
|
|
381
460
|
|
382
461
|
### Applications list
|
383
462
|
|
384
|
-
By default, the applications list (`/oauth/applications`) is publicly available.
|
385
|
-
|
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:
|
386
468
|
|
387
469
|
```ruby
|
388
470
|
# config/initializers/doorkeeper.rb
|
@@ -399,6 +481,22 @@ customize the controller used by the list or skip the controller all together.
|
|
399
481
|
For more information see the page
|
400
482
|
[in the wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
|
401
483
|
|
484
|
+
By default, everybody can create application with any scopes. However,
|
485
|
+
you can enforce users to create applications only with configured scopes
|
486
|
+
(`default_scopes` and `optional_scopes` from the Doorkeeper initializer):
|
487
|
+
|
488
|
+
```ruby
|
489
|
+
# config/initializers/doorkeeper.rb
|
490
|
+
Doorkeeper.configure do
|
491
|
+
# ...
|
492
|
+
|
493
|
+
default_scopes :read, :write
|
494
|
+
optional_scopes :create, :update
|
495
|
+
|
496
|
+
enforce_configured_scopes
|
497
|
+
end
|
498
|
+
```
|
499
|
+
|
402
500
|
## Other customizations
|
403
501
|
|
404
502
|
- [Associate users to OAuth applications (ownership)](https://github.com/doorkeeper-gem/doorkeeper/wiki/Associate-users-to-OAuth-applications-%28ownership%29)
|
@@ -412,7 +510,7 @@ Doorkeeper 4.3.0 it uses [ActiveSupport lazy loading hooks](http://api.rubyonrai
|
|
412
510
|
to load models. There are [known issue](https://github.com/doorkeeper-gem/doorkeeper/issues/1043)
|
413
511
|
with the `factory_bot_rails` gem (it executes factories building before `ActiveRecord::Base`
|
414
512
|
is initialized using hooks in gem railtie, so you can catch a `uninitialized constant` error).
|
415
|
-
It is recommended to use pure `factory_bot` gem to solve this problem.
|
513
|
+
It is recommended to use pure `factory_bot` gem to solve this problem.
|
416
514
|
|
417
515
|
## Upgrading
|
418
516
|
|
@@ -429,7 +527,7 @@ To run the local engine server:
|
|
429
527
|
|
430
528
|
```
|
431
529
|
bundle install
|
432
|
-
bundle exec
|
530
|
+
bundle exec rake doorkeeper:server
|
433
531
|
````
|
434
532
|
|
435
533
|
By default, it uses the latest Rails version with ActiveRecord. To run the
|
data/Rakefile
CHANGED
@@ -15,6 +15,12 @@ namespace :doorkeeper do
|
|
15
15
|
cd 'spec/dummy'
|
16
16
|
system 'bundle exec rails g doorkeeper:install --force'
|
17
17
|
end
|
18
|
+
|
19
|
+
desc 'Runs local test server'
|
20
|
+
task :server do
|
21
|
+
cd 'spec/dummy'
|
22
|
+
system 'bundle exec rails server'
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
Bundler::GemHelper.install_tasks
|
data/UPGRADE.md
ADDED
@@ -1,11 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Doorkeeper
|
2
4
|
class ApplicationController <
|
3
5
|
Doorkeeper.configuration.base_controller.constantize
|
4
6
|
|
5
7
|
include Helpers::Controller
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
unless Doorkeeper.configuration.api_only
|
10
|
+
protect_from_forgery with: :exception
|
11
|
+
helper 'doorkeeper/dashboard'
|
12
|
+
end
|
10
13
|
end
|
11
14
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Doorkeeper
|
2
4
|
class ApplicationMetalController < ActionController::Metal
|
3
5
|
MODULES = [
|
@@ -5,6 +7,7 @@ module Doorkeeper
|
|
5
7
|
AbstractController::Rendering,
|
6
8
|
ActionController::Rendering,
|
7
9
|
ActionController::Renderers::All,
|
10
|
+
AbstractController::Callbacks,
|
8
11
|
Helpers::Controller
|
9
12
|
].freeze
|
10
13
|
|
@@ -12,6 +15,9 @@ module Doorkeeper
|
|
12
15
|
include mod
|
13
16
|
end
|
14
17
|
|
18
|
+
before_action :enforce_content_type,
|
19
|
+
if: -> { Doorkeeper.configuration.enforce_content_type }
|
20
|
+
|
15
21
|
ActiveSupport.run_load_hooks(:doorkeeper_metal_controller, self)
|
16
22
|
end
|
17
23
|
end
|