doorkeeper 4.2.6 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of doorkeeper might be problematic. Click here for more details.

Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +19 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +17 -0
  4. data/.gitignore +1 -1
  5. data/.hound.yml +2 -13
  6. data/.rubocop.yml +13 -0
  7. data/.travis.yml +13 -5
  8. data/Appraisals +6 -2
  9. data/CODE_OF_CONDUCT.md +46 -0
  10. data/Gemfile +1 -1
  11. data/NEWS.md +24 -0
  12. data/README.md +39 -9
  13. data/SECURITY.md +13 -0
  14. data/app/controllers/doorkeeper/application_controller.rb +1 -5
  15. data/app/controllers/doorkeeper/applications_controller.rb +14 -1
  16. data/app/controllers/doorkeeper/tokens_controller.rb +13 -1
  17. data/app/helpers/doorkeeper/dashboard_helper.rb +4 -2
  18. data/app/validators/redirect_uri_validator.rb +12 -2
  19. data/app/views/doorkeeper/applications/_form.html.erb +1 -1
  20. data/app/views/doorkeeper/authorized_applications/index.html.erb +0 -1
  21. data/config/locales/en.yml +3 -5
  22. data/doorkeeper.gemspec +4 -3
  23. data/gemfiles/rails_4_2.gemfile +6 -4
  24. data/gemfiles/rails_5_0.gemfile +4 -4
  25. data/gemfiles/rails_5_1.gemfile +6 -7
  26. data/gemfiles/rails_5_2.gemfile +12 -0
  27. data/gemfiles/rails_master.gemfile +14 -0
  28. data/lib/doorkeeper.rb +1 -0
  29. data/lib/doorkeeper/config.rb +55 -55
  30. data/lib/doorkeeper/engine.rb +3 -3
  31. data/lib/doorkeeper/grape/helpers.rb +13 -8
  32. data/lib/doorkeeper/helpers/controller.rb +8 -4
  33. data/lib/doorkeeper/models/access_token_mixin.rb +14 -7
  34. data/lib/doorkeeper/models/application_mixin.rb +11 -6
  35. data/lib/doorkeeper/models/concerns/expirable.rb +7 -5
  36. data/lib/doorkeeper/oauth/authorization/token.rb +22 -18
  37. data/lib/doorkeeper/oauth/authorization_code_request.rb +6 -1
  38. data/lib/doorkeeper/oauth/base_request.rb +5 -5
  39. data/lib/doorkeeper/oauth/client.rb +2 -2
  40. data/lib/doorkeeper/oauth/client/credentials.rb +2 -2
  41. data/lib/doorkeeper/oauth/error.rb +2 -2
  42. data/lib/doorkeeper/oauth/error_response.rb +1 -2
  43. data/lib/doorkeeper/oauth/forbidden_token_response.rb +1 -1
  44. data/lib/doorkeeper/oauth/invalid_token_response.rb +2 -3
  45. data/lib/doorkeeper/oauth/password_access_token_request.rb +1 -0
  46. data/lib/doorkeeper/oauth/refresh_token_request.rb +1 -0
  47. data/lib/doorkeeper/oauth/scopes.rb +18 -8
  48. data/lib/doorkeeper/oauth/token.rb +1 -1
  49. data/lib/doorkeeper/oauth/token_introspection.rb +128 -0
  50. data/lib/doorkeeper/orm/active_record.rb +20 -8
  51. data/lib/doorkeeper/orm/active_record/access_grant.rb +1 -1
  52. data/lib/doorkeeper/orm/active_record/access_token.rb +1 -23
  53. data/lib/doorkeeper/orm/active_record/application.rb +1 -1
  54. data/lib/doorkeeper/orm/active_record/base_record.rb +11 -0
  55. data/lib/doorkeeper/rails/helpers.rb +5 -6
  56. data/lib/doorkeeper/rails/routes.rb +9 -7
  57. data/lib/doorkeeper/request.rb +7 -1
  58. data/lib/doorkeeper/validations.rb +3 -2
  59. data/lib/doorkeeper/version.rb +13 -1
  60. data/lib/generators/doorkeeper/application_owner_generator.rb +11 -2
  61. data/lib/generators/doorkeeper/migration_generator.rb +13 -1
  62. data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +7 -1
  63. data/lib/generators/doorkeeper/templates/{add_owner_to_application_migration.rb → add_owner_to_application_migration.rb.erb} +1 -1
  64. data/lib/generators/doorkeeper/templates/{add_previous_refresh_token_to_access_tokens.rb → add_previous_refresh_token_to_access_tokens.rb.erb} +1 -1
  65. data/lib/generators/doorkeeper/templates/initializer.rb +19 -3
  66. data/lib/generators/doorkeeper/templates/{migration.rb → migration.rb.erb} +1 -1
  67. data/spec/controllers/applications_controller_spec.rb +15 -4
  68. data/spec/controllers/authorizations_controller_spec.rb +5 -5
  69. data/spec/controllers/protected_resources_controller_spec.rb +28 -19
  70. data/spec/controllers/token_info_controller_spec.rb +17 -13
  71. data/spec/controllers/tokens_controller_spec.rb +138 -4
  72. data/spec/dummy/config/initializers/doorkeeper.rb +1 -1
  73. data/spec/dummy/config/initializers/{active_record_belongs_to_required_by_default.rb → new_framework_defaults.rb} +1 -1
  74. data/spec/dummy/config/initializers/secret_token.rb +0 -1
  75. data/spec/factories.rb +1 -1
  76. data/spec/generators/application_owner_generator_spec.rb +24 -5
  77. data/spec/generators/migration_generator_spec.rb +24 -3
  78. data/spec/generators/previous_refresh_token_generator_spec.rb +57 -0
  79. data/spec/grape/grape_integration_spec.rb +135 -0
  80. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +1 -1
  81. data/spec/lib/config_spec.rb +115 -12
  82. data/spec/lib/models/revocable_spec.rb +2 -2
  83. data/spec/lib/oauth/authorization_code_request_spec.rb +39 -11
  84. data/spec/lib/oauth/base_request_spec.rb +2 -7
  85. data/spec/lib/oauth/client_credentials/creator_spec.rb +1 -1
  86. data/spec/lib/oauth/client_credentials_integration_spec.rb +1 -1
  87. data/spec/lib/oauth/client_credentials_request_spec.rb +1 -0
  88. data/spec/lib/oauth/code_request_spec.rb +1 -3
  89. data/spec/lib/oauth/helpers/uri_checker_spec.rb +5 -0
  90. data/spec/lib/oauth/invalid_token_response_spec.rb +1 -1
  91. data/spec/lib/oauth/password_access_token_request_spec.rb +9 -3
  92. data/spec/lib/oauth/refresh_token_request_spec.rb +19 -7
  93. data/spec/lib/oauth/scopes_spec.rb +28 -1
  94. data/spec/lib/oauth/token_request_spec.rb +6 -8
  95. data/spec/lib/server_spec.rb +10 -0
  96. data/spec/models/doorkeeper/access_grant_spec.rb +1 -1
  97. data/spec/models/doorkeeper/access_token_spec.rb +72 -48
  98. data/spec/models/doorkeeper/application_spec.rb +51 -18
  99. data/spec/requests/applications/applications_request_spec.rb +5 -5
  100. data/spec/requests/endpoints/token_spec.rb +8 -1
  101. data/spec/requests/flows/authorization_code_spec.rb +1 -0
  102. data/spec/requests/flows/client_credentials_spec.rb +1 -1
  103. data/spec/requests/flows/implicit_grant_errors_spec.rb +2 -2
  104. data/spec/requests/flows/refresh_token_spec.rb +4 -4
  105. data/spec/requests/flows/revoke_token_spec.rb +15 -15
  106. data/spec/requests/protected_resources/metal_spec.rb +1 -1
  107. data/spec/requests/protected_resources/private_api_spec.rb +1 -1
  108. data/spec/routing/custom_controller_routes_spec.rb +4 -0
  109. data/spec/routing/default_routes_spec.rb +5 -1
  110. data/spec/spec_helper_integration.rb +15 -4
  111. data/spec/support/dependencies/factory_girl.rb +2 -2
  112. data/spec/support/helpers/access_token_request_helper.rb +1 -1
  113. data/spec/support/helpers/model_helper.rb +9 -4
  114. data/spec/support/helpers/request_spec_helper.rb +7 -3
  115. data/spec/support/helpers/url_helper.rb +8 -8
  116. data/spec/support/shared/controllers_shared_context.rb +2 -6
  117. data/spec/support/shared/models_shared_examples.rb +4 -4
  118. data/spec/validators/redirect_uri_validator_spec.rb +51 -6
  119. data/spec/version/version_spec.rb +15 -0
  120. metadata +42 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4b94e7f1fb4975a36ad84ccfda9bcfb0b5e2bd7
4
- data.tar.gz: fc5914c689e55572a9313caa07f2644c29f37574
3
+ metadata.gz: 323927e89a9c1c31f4f5dda92873c1959f2455a9
4
+ data.tar.gz: 956c2a288dbc09fa8cc4bcb7d809ef5dd53bd4ba
5
5
  SHA512:
6
- metadata.gz: f90cc508667ce0ec9693925a187fbc9ae5b9eeaf95b74648c9981ceea9eaef305d9981f75d48a8b8f0e00929bcc748a51da4b013b814ffa8a9344a4fc44257e1
7
- data.tar.gz: 433cafea0488b8d0ab2d7d9b164b9510191f9a6d6534443674064e60c8ea2c0007494a9015b8c9d96a44b603182217496d4221db752c21d1cc5e56b1e377ae86
6
+ metadata.gz: a1dbfedef840dc12c3e3ce33ba854963df84aaed81b97bc1828b177ef3c9d9ab4454dda6f37abe75f855eb39561a8e524a047bdffd9ddf44bf8a80d9d24b5c59
7
+ data.tar.gz: 27d2b543b67f67e750e8c317680b38583bb53473d8a0350aecccb7f9723ec00238b0ac07c72df3b2ace2ce74522f67d6e14811eb20acbb136497f71a368e4b2c
@@ -0,0 +1,19 @@
1
+ ### Steps to reproduce
2
+ What we need to do to see your problem or bug?
3
+
4
+ The more detailed the issue, the more likely that we will fix it ASAP.
5
+
6
+ Don't use GitHub issues for questions like "How can I do that?" —
7
+ use [StackOverflow](https://stackoverflow.com/questions/tagged/doorkeeper)
8
+ instead with the corresponding tag.
9
+
10
+ ### Expected behavior
11
+ Tell us what should happen
12
+
13
+ ### Actual behavior
14
+ Tell us what happens instead
15
+
16
+ ### System configuration
17
+ **Ruby version**:
18
+
19
+ **Gemfile.lock**
@@ -0,0 +1,17 @@
1
+ ### Summary
2
+
3
+ Provide a general description of the code changes in your pull
4
+ request... were there any bugs you had fixed? If so, mention them. If
5
+ these bugs have open GitHub issues, be sure to tag them here as well,
6
+ to keep the conversation linked together.
7
+
8
+ ### Other Information
9
+
10
+ If there's anything else that's important and relevant to your pull
11
+ request, mention that information here. This could include
12
+ benchmarks, or other information.
13
+
14
+ If you are updating NEWS.md file or are asked to update it by reviewers,
15
+ please add the changelog entry at the top of the file.
16
+
17
+ Thanks for contributing to Doorkeeper project!
data/.gitignore CHANGED
@@ -6,9 +6,9 @@ pkg/
6
6
  spec/dummy/db/*.sqlite3
7
7
  spec/dummy/log/*.log
8
8
  spec/dummy/tmp/
9
+ spec/generators/tmp
9
10
  Gemfile.lock
10
11
  gemfiles/*.lock
11
- spec/generators/tmp
12
12
  .rvmrc
13
13
  *.swp
14
14
  .idea
data/.hound.yml CHANGED
@@ -1,13 +1,2 @@
1
- AllCops:
2
- Exclude:
3
- - "spec/dummy/db/*"
4
-
5
- LineLength:
6
- Exclude:
7
- - spec/**/*
8
-
9
- StringLiterals:
10
- Enabled: false
11
-
12
- TrailingBlankLines:
13
- Enabled: true
1
+ ruby:
2
+ config_file: .rubocop.yml
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "spec/dummy/db/*"
4
+
5
+ LineLength:
6
+ Exclude:
7
+ - spec/**/*
8
+
9
+ StringLiterals:
10
+ Enabled: false
11
+
12
+ TrailingBlankLines:
13
+ Enabled: true
@@ -4,17 +4,21 @@ sudo: false
4
4
 
5
5
  rvm:
6
6
  - 2.1
7
- - 2.2.6
8
- - 2.3.3
9
- - 2.4.0
7
+ - 2.2.9
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
10
11
 
11
12
  before_install:
13
+ - gem update --system # Need for Ruby 2.5.0. https://github.com/travis-ci/travis-ci/issues/8978
12
14
  - gem install bundler -v '~> 1.10'
13
15
 
14
16
  gemfile:
15
17
  - gemfiles/rails_4_2.gemfile
16
18
  - gemfiles/rails_5_0.gemfile
17
19
  - gemfiles/rails_5_1.gemfile
20
+ - gemfiles/rails_5_2.gemfile
21
+ - gemfiles/rails_master.gemfile
18
22
 
19
23
  matrix:
20
24
  exclude:
@@ -22,5 +26,9 @@ matrix:
22
26
  rvm: 2.1
23
27
  - gemfile: gemfiles/rails_5_1.gemfile
24
28
  rvm: 2.1
25
- allowed_failures:
26
- - gemfile: gemfiles/rails_5_1.gemfile
29
+ - gemfile: gemfiles/rails_5_2.gemfile
30
+ rvm: 2.1
31
+ - gemfile: gemfiles/rails_master.gemfile
32
+ rvm: 2.1
33
+ allow_failures:
34
+ - gemfile: gemfiles/rails_master.gemfile
data/Appraisals CHANGED
@@ -8,7 +8,11 @@ appraise "rails-5-0" do
8
8
  end
9
9
 
10
10
  appraise "rails-5-1" do
11
- gem "rails", github: "rails/rails"
12
- gem "arel", github: "rails/arel"
11
+ gem "rails", "~> 5.1.0"
13
12
  gem "rspec-rails", "~> 3.5"
14
13
  end
14
+
15
+ appraise "rails-master" do
16
+ gem "rails", git: 'https://github.com/rails/rails'
17
+ gem "arel", git: 'https://github.com/rails/arel'
18
+ end
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team members or current maintainer email, specified in gemspec. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "rails", "~> 4.2.0"
3
+ gem "rails", "~> 5.1"
4
4
 
5
5
  gem "appraisal"
6
6
 
data/NEWS.md CHANGED
@@ -4,7 +4,31 @@ User-visible changes worth mentioning.
4
4
 
5
5
  ## master
6
6
 
7
+ - [#976] Fix to invalidate the second redirect URI when the first URI is the native URI
8
+ - [#1035] Allow `Application#redirect_uri=` to handle array of URIs.
9
+ - [#1036] Allow to forbid Application redirect URI's with specific rules.
10
+ - [#1029] Deprecate `order_method` and introduce `ordered_by`. Sort applications
11
+ by `created_at` in index action.
12
+ - [#1033] Allow Doorkeeper configuration option #force_ssl_in_redirect_uri to be a callable object.
13
+ - Fix Grape integration & add specs for it
14
+ - [#913] Deferred ORM (ActiveRecord) models loading
15
+ - [#943] Fix Access Token token generation when certain errors occur in custom token generators
16
+ - [#1026] Implement RFC7662 - OAuth 2.0 Token Introspection
17
+ - [#985] Generate valid migration files for Rails >= 5
18
+ - [#972] Replace Struct subclassing with block-form initialization
19
+ - [#1003] Use URL query param to pass through native redirect auth code so automated apps can find it.
20
+ - [#868] `Scopes#&` and `Scopes#+` now take an array or any other enumerable
21
+ object.
22
+ - [#1019] Remove translation not in use: `invalid_resource_owner`.
23
+ - Use Ruby 2 hash style syntax (min required Ruby version = 2.1)
24
+ - [#948] Make Scopes.<=> work with any "other" value.
7
25
  - [#970] Escape certain attributes in authorization forms.
26
+ - [#974] Redirect URI is checked without query params within AuthorizationCodeRequest.
27
+ - [#1004] More explicit help text for `native_redirect_uri`.
28
+ - [#1023] Update Ruby versions and test against 2.5.0 on Travis CI.
29
+ - [#1024] Migrate from FactoryGirl to FactoryBot.
30
+ - [#1025] Improve documentation for adding foreign keys
31
+ - [#1028] Make it possible to have composit strategy names.
8
32
 
9
33
  ## 4.2.5
10
34
 
data/README.md CHANGED
@@ -1,16 +1,26 @@
1
1
  # Doorkeeper - awesome OAuth2 provider for your Rails app.
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/doorkeeper.svg)](https://rubygems.org/gems/doorkeeper)
3
4
  [![Build Status](https://travis-ci.org/doorkeeper-gem/doorkeeper.svg?branch=master)](https://travis-ci.org/doorkeeper-gem/doorkeeper)
4
5
  [![Dependency Status](https://gemnasium.com/doorkeeper-gem/doorkeeper.svg?travis)](https://gemnasium.com/doorkeeper-gem/doorkeeper)
5
6
  [![Code Climate](https://codeclimate.com/github/doorkeeper-gem/doorkeeper.svg)](https://codeclimate.com/github/doorkeeper-gem/doorkeeper)
6
- [![Gem Version](https://badge.fury.io/rb/doorkeeper.svg)](https://rubygems.org/gems/doorkeeper)
7
+ [![Coverage Status](https://coveralls.io/repos/github/doorkeeper-gem/doorkeeper/badge.svg?branch=master)](https://coveralls.io/github/doorkeeper-gem/doorkeeper?branch=master)
7
8
  [![Security](https://hakiri.io/github/doorkeeper-gem/doorkeeper/master.svg)](https://hakiri.io/github/doorkeeper-gem/doorkeeper/master)
8
9
 
9
10
  Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider
10
11
  functionality to your Rails or Grape application.
11
12
 
12
- [PR 567]: https://github.com/doorkeeper-gem/doorkeeper/pull/567
13
+ Supported features:
13
14
 
15
+ - [The OAuth 2.0 Authorization Framework](https://tools.ietf.org/html/rfc6749)
16
+ - [Authorization Code Flow](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.1)
17
+ - [Access Token Scopes](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.3)
18
+ - [Refresh token](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-1.5)
19
+ - [Implicit grant](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.2)
20
+ - [Resource Owner Password Credentials](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.3)
21
+ - [Client Credentials](http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-4.4)
22
+ - [OAuth 2.0 Token Revocation](http://tools.ietf.org/html/rfc7009)
23
+ - [OAuth 2.0 Token Introspection](https://tools.ietf.org/html/rfc7662)
14
24
 
15
25
  ## Documentation valid for `master` branch
16
26
 
@@ -19,6 +29,8 @@ https://github.com/doorkeeper-gem/doorkeeper/releases
19
29
 
20
30
  - See the [wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki)
21
31
  - For general questions, please post in [Stack Overflow](http://stackoverflow.com/questions/tagged/doorkeeper)
32
+ - See [SECURITY.md](SECURITY.md) for this project's security disclose
33
+ policy
22
34
 
23
35
  ## Table of Contents
24
36
 
@@ -27,8 +39,10 @@ https://github.com/doorkeeper-gem/doorkeeper/releases
27
39
 
28
40
  - [Installation](#installation)
29
41
  - [Configuration](#configuration)
30
- - [Active Record](#active-record)
31
- - [Other ORMs](#other-orms)
42
+ - [ORM](#orm)
43
+ - [Active Record](#active-record)
44
+ - [MongoDB](#mongodb)
45
+ - [Sequel](#sequel)
32
46
  - [Routes](#routes)
33
47
  - [Authenticating](#authenticating)
34
48
  - [Internationalization (I18n)](#internationalization-i18n)
@@ -69,7 +83,9 @@ This will install the doorkeeper initializer into `config/initializers/doorkeepe
69
83
 
70
84
  ## Configuration
71
85
 
72
- ### Active Record
86
+ ### ORM
87
+
88
+ #### Active Record
73
89
 
74
90
  By default doorkeeper is configured to use active record, so to start you have
75
91
  to generate the migration tables:
@@ -84,19 +100,32 @@ for each table that includes a `resource_owner_id` column:
84
100
  add_foreign_key :table_name, :users, column: :resource_owner_id
85
101
  ```
86
102
 
103
+ Remember to add associations to your model so the related records are deleted.
104
+ If you don't do this an `ActiveRecord::InvalidForeignKey`-error will be raised
105
+ when you try to destroy a model with related access grants or access tokens.
106
+
107
+ ```ruby
108
+ class User < ApplicationRecord
109
+ has_many :access_grants, class_name: "Doorkeeper::AccessGrant", foreign_key: :resource_owner_id, dependent: :delete_all # or :destroy if you need callbacks
110
+ has_many :access_tokens, class_name: "Doorkeeper::AccessToken", foreign_key: :resource_owner_id, dependent: :delete_all # or :destroy if you need callbacks
111
+ end
112
+ ```
113
+
87
114
  Then run migrations:
88
115
 
89
116
  ```sh
90
117
  rake db:migrate
91
118
  ```
92
119
 
93
- ### Other ORMs
120
+ #### MongoDB
94
121
 
95
122
  See [doorkeeper-mongodb project] for Mongoid and MongoMapper support. Follow along
96
123
  the implementation in that repository to extend doorkeeper with other ORMs.
97
124
 
98
125
  [doorkeeper-mongodb project]: https://github.com/doorkeeper-gem/doorkeeper-mongodb
99
126
 
127
+ #### Sequel
128
+
100
129
  If you are using [Sequel gem] then you can add [doorkeeper-sequel extension] to your project.
101
130
  Follow configuration instructions for setting up the necessary Doorkeeper ORM.
102
131
 
@@ -117,12 +146,13 @@ end
117
146
 
118
147
  This will mount following routes:
119
148
 
120
- GET /oauth/authorize/:code
149
+ GET /oauth/authorize/native?code
121
150
  GET /oauth/authorize
122
151
  POST /oauth/authorize
123
152
  DELETE /oauth/authorize
124
153
  POST /oauth/token
125
154
  POST /oauth/revoke
155
+ POST /oauth/introspect
126
156
  resources /oauth/applications
127
157
  GET /oauth/authorized_applications
128
158
  DELETE /oauth/authorized_applications/:id
@@ -198,8 +228,8 @@ module API
198
228
  doorkeeper_authorize!
199
229
  end
200
230
 
201
- route_setting :scopes, ['user:email']
202
- get :emails do
231
+ # route_setting :scopes, ['user:email'] - for old versions of Grape
232
+ get :emails, scopes: [:user, :write] do
203
233
  [{'email' => current_user.email}]
204
234
  end
205
235
 
@@ -0,0 +1,13 @@
1
+ # Reporting security issues in Doorkeeper
2
+
3
+ Hello! Thank you for wanting to disclose a possible security
4
+ vulnerability within the Doorkeeper gem! Please follow our disclosure
5
+ policy as outlined below:
6
+
7
+ 1. Do NOT open up a GitHub issue with your report. Security reports
8
+ should be kept private until a possible fix is determined.
9
+ 2. Send an email to Jon Moss, Doorkeeper's maintainer, at doorkeeper AT jonathanmoss.me. You should receive a prompt response.
10
+ 3. Be patient. Since Doorkeeper is in a stable maintenance phase, we want to
11
+ do as little as possible to rock the boat of the project.
12
+
13
+ Thank you very much for adhering for these policies!
@@ -4,11 +4,7 @@ module Doorkeeper
4
4
 
5
5
  include Helpers::Controller
6
6
 
7
- if ::Rails.version.to_i < 4
8
- protect_from_forgery
9
- else
10
- protect_from_forgery with: :exception
11
- end
7
+ protect_from_forgery with: :exception
12
8
 
13
9
  helper 'doorkeeper/dashboard'
14
10
  end
@@ -6,9 +6,20 @@ module Doorkeeper
6
6
  before_action :set_application, only: [:show, :edit, :update, :destroy]
7
7
 
8
8
  def index
9
- @applications = Application.all
9
+ @applications = if Application.respond_to?(:ordered_by)
10
+ Application.ordered_by(:created_at)
11
+ else
12
+ ActiveSupport::Deprecation.warn <<-MSG.squish
13
+ Doorkeeper #{Doorkeeper.configuration.orm} extension must implement #ordered_by
14
+ method for it's models as it will be used by default in Doorkeeper 5.
15
+ MSG
16
+
17
+ Application.all
18
+ end
10
19
  end
11
20
 
21
+ def show; end
22
+
12
23
  def new
13
24
  @application = Application.new
14
25
  end
@@ -23,6 +34,8 @@ module Doorkeeper
23
34
  end
24
35
  end
25
36
 
37
+ def edit; end
38
+
26
39
  def update
27
40
  if @application.update_attributes(application_params)
28
41
  flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :update])
@@ -4,7 +4,7 @@ module Doorkeeper
4
4
  response = authorize_response
5
5
  headers.merge! response.headers
6
6
  self.response_body = response.body.to_json
7
- self.status = response.status
7
+ self.status = response.status
8
8
  rescue Errors::DoorkeeperError => e
9
9
  handle_token_exception e
10
10
  end
@@ -27,6 +27,18 @@ module Doorkeeper
27
27
  render json: {}, status: 200
28
28
  end
29
29
 
30
+ def introspect
31
+ introspection = OAuth::TokenIntrospection.new(server, token)
32
+
33
+ if introspection.authorized?
34
+ render json: introspection.to_json, status: 200
35
+ else
36
+ error = OAuth::ErrorResponse.new(name: introspection.error)
37
+ response.headers.merge!(error.headers)
38
+ render json: error.body, status: error.status
39
+ end
40
+ end
41
+
30
42
  private
31
43
 
32
44
  # OAuth 2.0 Section 2.1 defines two client types, "public" & "confidential".
@@ -2,11 +2,13 @@ module Doorkeeper
2
2
  module DashboardHelper
3
3
  def doorkeeper_errors_for(object, method)
4
4
  if object.errors[method].present?
5
- object.errors[method].map do |msg|
5
+ output = object.errors[method].map do |msg|
6
6
  content_tag(:span, class: 'help-block') do
7
7
  msg.capitalize
8
8
  end
9
- end.join.html_safe
9
+ end
10
+
11
+ safe_join(output)
10
12
  end
11
13
  end
12
14